<?php

namespace App\Filament\Resources;

use App\Filament\Resources\CarShowCategoryResource\Pages;
use App\Filament\Resources\CarShowCategoryResource\RelationManagers;
use App\Filament\Resources\CarShowCategoryResource\RelationManagers\VehicleRelationManager;
use App\Models\CarShowCategory;
use Filament\Resources\Resource;
use Filament\Tables\Table;
use Filament\Tables;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
use Filament\Tables\Columns\IconColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use UnitEnum;
use BackedEnum;
use Filament\Schemas\Schema;
use Filament\Actions\EditAction;
use Filament\Actions\BulkActionGroup;
use Filament\Actions\DeleteBulkAction;

class CarShowCategoryResource extends Resource
{
    protected static ?string $model = CarShowCategory::class;

    protected static string | BackedEnum | null $navigationIcon = 'heroicon-o-rectangle-stack';

    protected static string | UnitEnum | null $navigationGroup = 'Car Show';


    public static function form(Schema $schema): Schema
    {
        return $schema
            ->components([
                TextInput::make('category_name'),
                Toggle::make('vehicle_type')->inline(false)
            ]);
    }

    public static function table(Table $table): Table
    {
        return $table
            ->columns([
                TextColumn::make('category_name')->sortable(),
                IconColumn::make('vehicle_type')->boolean()->sortable(),
            ])
            ->filters([
                //
            ])
            ->recordActions([
                EditAction::make(),
            ])
            ->toolbarActions([
                BulkActionGroup::make([
                    DeleteBulkAction::make(),
                ]),
            ])
            ->defaultSort('category_name');
    }
    
    public static function getRelations(): array
    {
        return [
            RelationManagers\VehicleRelationManager::class,
        ];
    }
    
    public static function getPages(): array
    {
        return [
            'index' => Pages\ListCarShowCategories::route('/'),
            'create' => Pages\CreateCarShowCategory::route('/create'),
            'edit' => Pages\EditCarShowCategory::route('/{record}/edit'),
        ];
    }    
}
