silent-auction/app/Filament/Resources/VehicleScoresResource.php

83 lines
2.5 KiB
PHP
Raw Normal View History

2022-08-06 15:39:24 -04:00
<?php
namespace App\Filament\Resources;
use App\Filament\Resources\VehicleScoresResource\Pages;
use App\Filament\Resources\VehicleScoresResource\RelationManagers;
use App\Models\VehicleScores;
use Filament\Forms;
use Filament\Resources\Form;
use Filament\Resources\Resource;
use Filament\Resources\Table;
use Filament\Tables;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope;
2022-08-07 12:48:05 -04:00
use Filament\Tables\Columns\TextColumn;
use Filament\Forms\Components\TextInput;
2022-08-08 20:56:28 -04:00
use Filament\Forms\Components\Select;
use App\Models\Vehicles;
use App\Models\Judges;
2022-08-06 15:39:24 -04:00
class VehicleScoresResource extends Resource
{
protected static ?string $model = VehicleScores::class;
protected static ?string $navigationIcon = 'heroicon-o-collection';
2022-08-07 13:07:31 -04:00
protected static ?string $navigationGroup = 'Car Show';
2022-08-06 15:39:24 -04:00
public static function form(Form $form): Form
{
return $form
->schema([
2022-08-08 20:56:28 -04:00
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'),
2022-08-06 15:39:24 -04:00
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
2022-08-08 21:07:15 -04:00
TextColumn::make('judge.judge_number')->label('Judge')->sortable(),
TextColumn::make('scoredVehicle.owner')->label('Vehicle Number')->sortable(),
TextColumn::make('overall_score')->label('Score')->sortable(),
2022-08-06 15:39:24 -04:00
])
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\DeleteBulkAction::make(),
]);
}
public static function getRelations(): array
{
return [
2022-08-08 20:56:28 -04:00
RelationManagers\JudgeRelationManager::class,
RelationManagers\ScoredVehicleRelationManager::class,
2022-08-06 15:39:24 -04:00
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListVehicleScores::route('/'),
'create' => Pages\CreateVehicleScores::route('/create'),
'edit' => Pages\EditVehicleScores::route('/{record}/edit'),
];
}
}