<?php

declare(strict_types=1);

namespace App\Filament\Resources\SickLeaves;

use App\Enums\NavigationGroup;
use App\Filament\Concerns\HasHrResourceLabels;
use App\Filament\Resources\SickLeaves\Pages\CreateSickLeave;
use App\Filament\Resources\SickLeaves\Pages\EditSickLeave;
use App\Filament\Resources\SickLeaves\Pages\ListSickLeaves;
use App\Filament\Resources\SickLeaves\Pages\ViewSickLeave;
use App\Filament\Resources\SickLeaves\Schemas\SickLeaveForm;
use App\Filament\Resources\SickLeaves\Schemas\SickLeaveInfolist;
use App\Filament\Resources\SickLeaves\Tables\SickLeavesTable;
use App\Models\SickLeave;
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 SickLeaveResource extends Resource
{
    use HasHrResourceLabels;

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

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

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

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

    protected static ?int $navigationSort = 2;

    protected static ?string $recordTitleAttribute = 'id';

    protected static bool $isGloballySearchable = false;

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

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

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

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

    public static function getPages(): array
    {
        return [
            'index' => ListSickLeaves::route('/'),
            'create' => CreateSickLeave::route('/create'),
            'view' => ViewSickLeave::route('/{record}'),
            'edit' => EditSickLeave::route('/{record}/edit'),
        ];
    }

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