<?php

namespace App\Filament\Resources;

use App\Filament\Clusters\RareAdmin\RareAdminCluster;
use App\Filament\Resources\RetentionOverrideResource\Pages\CreateRetentionOverride;
use App\Filament\Resources\RetentionOverrideResource\Pages\EditRetentionOverride;
use App\Filament\Resources\RetentionOverrideResource\Pages\ListRetentionOverrides;
use App\Filament\Resources\RetentionOverrideResource\Schemas\RetentionOverrideForm;
use App\Filament\Resources\RetentionOverrideResource\Tables\RetentionOverrideTable;
use App\Models\RetentionOverride;
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 UnitEnum;

class RetentionOverrideResource extends Resource
{
    protected static ?string $model = RetentionOverride::class;

    protected static ?string $cluster = RareAdminCluster::class;

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

    protected static UnitEnum|string|null $navigationGroup = null;

    protected static ?int $navigationSort = 55;

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

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

    public static function getNavigationLabel(): string
    {
        return __('admin.retention_overrides.navigation.label');
    }

    public static function getNavigationGroup(): UnitEnum|string|null
    {
        return __('admin.nav.platform');
    }

    public static function getEloquentQuery(): Builder
    {
        return parent::getEloquentQuery()->with(['tenant', 'event', 'createdBy', 'releasedBy']);
    }

    public static function getPages(): array
    {
        return [
            'index' => ListRetentionOverrides::route('/'),
            'create' => CreateRetentionOverride::route('/create'),
            'edit' => EditRetentionOverride::route('/{record}/edit'),
        ];
    }

    public static function canDelete($record): bool
    {
        return false;
    }

    public static function canDeleteAny(): bool
    {
        return false;
    }
}
