<?php

declare(strict_types=1);

namespace App\Filament\Resources\Gifts;

use App\Enums\NavigationGroup;
use App\Filament\Concerns\HasHrResourceLabels;
use App\Filament\Resources\Gifts\Pages\CreateGift;
use App\Filament\Resources\Gifts\Pages\EditGift;
use App\Filament\Resources\Gifts\Pages\ListGifts;
use App\Filament\Resources\Gifts\Pages\ViewGift;
use App\Filament\Resources\Gifts\Schemas\GiftForm;
use App\Filament\Resources\Gifts\Schemas\GiftInfolist;
use App\Filament\Resources\Gifts\Tables\GiftsTable;
use App\Models\Gift;
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 GiftResource extends Resource
{
    use HasHrResourceLabels;

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

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

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

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

    protected static ?int $navigationSort = 4;

    protected static ?string $recordTitleAttribute = 'gift_name';

    protected static bool $isGloballySearchable = false;

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

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

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

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

    public static function getPages(): array
    {
        return [
            'index' => ListGifts::route('/'),
            'create' => CreateGift::route('/create'),
            'view' => ViewGift::route('/{record}'),
            'edit' => EditGift::route('/{record}/edit'),
        ];
    }

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