<?php

namespace App\Filament\Resources\Usernames;

use App\Filament\Resources\Usernames\Pages\CreateUsername;
use App\Filament\Resources\Usernames\Pages\EditUsername;
use App\Filament\Resources\Usernames\Pages\ListUsernames;
use App\Filament\Resources\Usernames\Schemas\UsernameForm;
use App\Filament\Resources\Usernames\Tables\UsernamesTable;
use App\Models\Username;
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 UsernameResource extends Resource
{
    protected static ?string $model = Username::class;

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

    protected static string|null|\UnitEnum $navigationGroup = 'Email';

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

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

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

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

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