<?php

declare(strict_types=1);

namespace App\Filament\Resources\Bonuses;

use App\Enums\NavigationGroup;
use App\Filament\Concerns\HasHrResourceLabels;
use App\Filament\Resources\Bonuses\Pages\CreateBonus;
use App\Filament\Resources\Bonuses\Pages\EditBonus;
use App\Filament\Resources\Bonuses\Pages\ListBonuses;
use App\Filament\Resources\Bonuses\Pages\ViewBonus;
use App\Filament\Resources\Bonuses\Schemas\BonusForm;
use App\Filament\Resources\Bonuses\Schemas\BonusInfolist;
use App\Filament\Resources\Bonuses\Tables\BonusesTable;
use App\Models\Bonus;
use BackedEnum;
use Filament\Resources\Resource;
use Filament\Schemas\Schema;
use Filament\Support\Icons\Heroicon;
use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use UnitEnum;

class BonusResource extends Resource
{
    use HasHrResourceLabels;

    protected static ?string $model = Bonus::class;

    protected static function hrLabelKeys(): array
    {
        return [
            'model' => 'bonus',
            'plural' => 'bonuses',
        ];
    }

    protected static string|BackedEnum|null $navigationIcon = Heroicon::OutlinedCurrencyDollar;

    protected static string|UnitEnum|null $navigationGroup = NavigationGroup::Records;

    protected static ?int $navigationSort = 3;

    protected static ?string $recordTitleAttribute = 'reason';

    protected static bool $isGloballySearchable = false;

    public static function form(Schema $schema): Schema
    {
        return BonusForm::configure($schema);
    }

    public static function infolist(Schema $schema): Schema
    {
        return BonusInfolist::configure($schema);
    }

    public static function table(Table $table): Table
    {
        return BonusesTable::configure($table);
    }

    public static function getRelations(): array
    {
        return [
            //
        ];
    }

    public static function getPages(): array
    {
        return [
            'index' => ListBonuses::route('/'),
            'create' => CreateBonus::route('/create'),
            'view' => ViewBonus::route('/{record}'),
            'edit' => EditBonus::route('/{record}/edit'),
        ];
    }

    public static function getRecordRouteBindingEloquentQuery(): Builder
    {
        return parent::getRecordRouteBindingEloquentQuery()
            ->withoutGlobalScopes([
                SoftDeletingScope::class,
            ]);
    }
}
