<?php

declare(strict_types=1);

namespace Maestro\Core\Providers;

use Illuminate\Support\ServiceProvider;
use Maestro\Core\DataTables\DataTableQueryApplier;
use Maestro\Core\DataTables\DataTableRegistry;
use Maestro\Core\DataTables\Resources\ActivityLogDataTable;
use Maestro\Core\DataTables\Resources\RolesDataTable;
use Maestro\Core\DataTables\Resources\UsersDataTable;

final class DataTablesServiceProvider extends ServiceProvider
{
    public function register(): void
    {
        $this->app->singleton(DataTableQueryApplier::class, fn (): DataTableQueryApplier => new DataTableQueryApplier);

        $this->app->singleton(DataTableRegistry::class, function (): DataTableRegistry {
            $registry = new DataTableRegistry;
            $registry->register(UsersDataTable::class, 'users');
            $registry->register(RolesDataTable::class, 'roles');
            $registry->register(ActivityLogDataTable::class, 'activity-log');

            return $registry;
        });
    }
}
