<?php

namespace App\Filament\Clusters\Cards\CardOrders;

use App\Filament\Clusters\Cards\CardOrders\Pages\CreateCardOrder;
use App\Filament\Clusters\Cards\CardOrders\Pages\EditCardOrder;
use App\Filament\Clusters\Cards\CardOrders\Pages\ListCardOrders;
use App\Filament\Clusters\Cards\CardOrders\Schemas\CardOrderForm;
use App\Filament\Clusters\Cards\CardOrders\Tables\CardOrdersTable;
use App\Filament\Clusters\Cards\CardsCluster;
use App\Modules\CardOrder\Models\CardOrder;
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;

class CardOrderResource extends Resource
{
    protected static ?int $navigationSort = 2;

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

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

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

    protected static string|BackedEnum|null $activeNavigationIcon = Heroicon::DocumentPlus;

    protected static ?string $recordTitleAttribute = 'unique_id';

    public static function getNavigationLabel(): string
    {
        return __('New card order');
    }

    public static function getModelLabel(): string
    {
        return __('Card order');
    }

    public static function getPluralModelLabel(): string
    {
        return __('Card orders');
    }

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

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

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

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

    /**
     * @return Builder<\App\Modules\CardOrder\Models\CardOrder>
     */
    public static function getRecordRouteBindingEloquentQuery(): Builder
    {
        return parent::getRecordRouteBindingEloquentQuery()
            ->withoutGlobalScopes([
                SoftDeletingScope::class,
            ]);
    }
}
