<?php

declare(strict_types=1);

namespace App\Filament\Resources\UnpaidLeaves;

use App\Enums\NavigationGroup;
use App\Filament\Concerns\HasHrResourceLabels;
use App\Filament\Resources\UnpaidLeaves\Pages\CreateUnpaidLeave;
use App\Filament\Resources\UnpaidLeaves\Pages\EditUnpaidLeave;
use App\Filament\Resources\UnpaidLeaves\Pages\ListUnpaidLeaves;
use App\Filament\Resources\UnpaidLeaves\Pages\ViewUnpaidLeave;
use App\Filament\Resources\UnpaidLeaves\Schemas\UnpaidLeaveForm;
use App\Filament\Resources\UnpaidLeaves\Schemas\UnpaidLeaveInfolist;
use App\Filament\Resources\UnpaidLeaves\Tables\UnpaidLeavesTable;
use App\Models\UnpaidLeave;
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 UnpaidLeaveResource extends Resource
{
    use HasHrResourceLabels;

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

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

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

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

    protected static ?int $navigationSort = 3;

    protected static ?string $recordTitleAttribute = 'id';

    protected static bool $isGloballySearchable = false;

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

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

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

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

    public static function getPages(): array
    {
        return [
            'index' => ListUnpaidLeaves::route('/'),
            'create' => CreateUnpaidLeave::route('/create'),
            'view' => ViewUnpaidLeave::route('/{record}'),
            'edit' => EditUnpaidLeave::route('/{record}/edit'),
        ];
    }

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