forked from TFMM/silent-auction
85 lines
2.8 KiB
PHP
85 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources;
|
|
|
|
use App\Filament\Resources\CarShowWinnerResource\Pages;
|
|
use App\Filament\Resources\CarShowWinnerResource\RelationManagers;
|
|
use App\Models\CarShowWinner;
|
|
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\Select;
|
|
use App\Models\Vehicles;
|
|
use App\Models\CarShowCategory;
|
|
use UnitEnum;
|
|
use BackedEnum;
|
|
use Filament\Schemas\Schema;
|
|
|
|
class CarShowWinnerResource extends Resource
|
|
{
|
|
protected static ?string $model = CarShowWinner::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('vehicle')
|
|
->label('Vehicle')
|
|
->options(Vehicles::all()->pluck('owner', 'id'))
|
|
->searchable(),
|
|
Select::make('category')
|
|
->label('Category')
|
|
->options(CarShowCategory::all()->pluck('category_name', 'id'))
|
|
->searchable(),
|
|
]);
|
|
}
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
TextColumn::make('awardCategory.category_name')->label('Category')->sortable(),
|
|
TextColumn::make('awardVehicle.owner')->label('Vehicle Number')->sortable(),
|
|
TextColumn::make('total_score')->label('Total Score')->sortable(),
|
|
TextColumn::make('awardVehicle.year')->label('Year')->sortable(),
|
|
TextColumn::make('awardVehicle.make')->label('Make')->sortable(),
|
|
TextColumn::make('awardVehicle.model')->label('Model')->sortable(),
|
|
])
|
|
->filters([
|
|
//
|
|
])
|
|
->actions([
|
|
Tables\Actions\EditAction::make(),
|
|
])
|
|
->bulkActions([
|
|
Tables\Actions\BulkActionGroup::make([
|
|
Tables\Actions\DeleteBulkAction::make(),
|
|
]),
|
|
]);
|
|
}
|
|
|
|
public static function getRelations(): array
|
|
{
|
|
return [
|
|
RelationManagers\AwardVehicleRelationManager::class,
|
|
RelationManagers\AwardCategoryRelationManager::class,
|
|
];
|
|
}
|
|
|
|
public static function getPages(): array
|
|
{
|
|
return [
|
|
'index' => Pages\ListCarShowWinners::route('/'),
|
|
'create' => Pages\CreateCarShowWinner::route('/create'),
|
|
'edit' => Pages\EditCarShowWinner::route('/{record}/edit'),
|
|
];
|
|
}
|
|
}
|