2022-08-06 15:39:24 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Filament\Resources;
|
|
|
|
|
|
|
|
use App\Filament\Resources\CarShowWinnerResource\Pages;
|
|
|
|
use App\Filament\Resources\CarShowWinnerResource\RelationManagers;
|
|
|
|
use App\Models\CarShowWinner;
|
|
|
|
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\Select;
|
|
|
|
use App\Models\Vehicles;
|
|
|
|
use App\Models\CarShowCategory;
|
2022-08-06 15:39:24 -04:00
|
|
|
|
|
|
|
class CarShowWinnerResource extends Resource
|
|
|
|
{
|
|
|
|
protected static ?string $model = CarShowWinner::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-07 12:48:05 -04:00
|
|
|
Select::make('vehicle')
|
|
|
|
->label('Vehicle')
|
2022-08-07 12:52:59 -04:00
|
|
|
->options(Vehicles::all()->pluck('owner', 'id'))
|
2022-08-07 12:48:05 -04:00
|
|
|
->searchable(),
|
|
|
|
Select::make('category')
|
|
|
|
->label('Category')
|
2022-08-07 12:52:59 -04:00
|
|
|
->options(CarShowCategory::all()->pluck('category_name', 'id'))
|
2022-08-07 12:48:05 -04:00
|
|
|
->searchable(),
|
2022-08-06 15:39:24 -04:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function table(Table $table): Table
|
|
|
|
{
|
|
|
|
return $table
|
|
|
|
->columns([
|
2022-08-07 12:48:05 -04:00
|
|
|
TextColumn::make('awardCategory.category_name')->label('Category'),
|
2022-08-07 12:54:40 -04:00
|
|
|
TextColumn::make('awardVehicle.owner')->label('Vehicle Number'),
|
|
|
|
TextColumn::make('awardVehicle.year')->label('Year'),
|
|
|
|
TextColumn::make('awardVehicle.make')->label('Make'),
|
|
|
|
TextColumn::make('awardVehicle.model')->label('Model'),
|
2022-08-07 12:48:05 -04:00
|
|
|
])
|
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:38:29 -04:00
|
|
|
RelationManagers\AwardVehicleRelationManager::class,
|
2022-08-06 15:39:24 -04:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function getPages(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'index' => Pages\ListCarShowWinners::route('/'),
|
|
|
|
'create' => Pages\CreateCarShowWinner::route('/create'),
|
|
|
|
'edit' => Pages\EditCarShowWinner::route('/{record}/edit'),
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|