<?php

declare(strict_types=1);

namespace App\Filament\Resources\Explanations;

use App\Enums\NavigationGroup;
use App\Filament\Concerns\HasHrResourceLabels;
use App\Filament\Resources\Explanations\Pages\CreateExplanation;
use App\Filament\Resources\Explanations\Pages\EditExplanation;
use App\Filament\Resources\Explanations\Pages\ListExplanations;
use App\Filament\Resources\Explanations\Pages\ViewExplanation;
use App\Filament\Resources\Explanations\Schemas\ExplanationForm;
use App\Filament\Resources\Explanations\Schemas\ExplanationInfolist;
use App\Filament\Resources\Explanations\Tables\ExplanationsTable;
use App\Models\Explanation;
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 ExplanationResource extends Resource
{
    use HasHrResourceLabels;

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

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

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

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

    protected static ?int $navigationSort = 2;

    protected static ?string $recordTitleAttribute = 'reason';

    protected static bool $isGloballySearchable = false;

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

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

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

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

    public static function getPages(): array
    {
        return [
            'index' => ListExplanations::route('/'),
            'create' => CreateExplanation::route('/create'),
            'view' => ViewExplanation::route('/{record}'),
            'edit' => EditExplanation::route('/{record}/edit'),
        ];
    }

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