Files
silent-auction/app/Filament/Resources/VehicleScoresResource.php
2026-04-20 14:06:25 -04:00

89 lines
2.7 KiB
PHP

<?php
namespace App\Filament\Resources;
use App\Filament\Resources\VehicleScoresResource\Pages;
use App\Filament\Resources\VehicleScoresResource\RelationManagers;
use App\Models\VehicleScores;
use UnitEnum;
use BackedEnum;
use Filament\Schemas\Schema;
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\TextColumn;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Select;
use App\Models\Vehicles;
use App\Models\Judges;
use Filament\Actions\EditAction;
use Filament\Actions\BulkActionGroup;
use Filament\Actions\DeleteBulkAction;
class VehicleScoresResource extends Resource
{
protected static ?string $model = VehicleScores::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([
Select::make('judge')
->label('Judge')
->options(Judges::all()->pluck('judge_number', 'id'))
->searchable(),
Select::make('vehicle')
->label('Vehicle')
->options(Vehicles::all()->pluck('owner', 'id'))
->searchable(),
TextInput::make('overall_score')
->label('Overall Score'),
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
TextColumn::make('judges.judge_number')->label('Judge')->sortable(),
TextColumn::make('scoredVehicle.owner')->label('Vehicle Number')->sortable(),
TextColumn::make('overall_score')->label('Score')->sortable(),
])
->filters([
//
])
->recordActions([
EditAction::make(),
])
->toolbarActions([
BulkActionGroup::make([
DeleteBulkAction::make(),
]),
]);
}
public static function getRelations(): array
{
return [
RelationManagers\JudgeRelationManager::class,
RelationManagers\ScoredVehicleRelationManager::class,
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListVehicleScores::route('/'),
'create' => Pages\CreateVehicleScores::route('/create'),
'edit' => Pages\EditVehicleScores::route('/{record}/edit'),
];
}
}