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

116 lines
3.8 KiB
PHP
Raw Normal View History

2022-08-06 15:39:24 -04:00
<?php
namespace App\Filament\Resources;
use App\Filament\Resources\VehiclesResource\Pages;
use App\Filament\Resources\VehiclesResource\RelationManagers;
use App\Models\Vehicles;
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\BooleanColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Forms\Components\TextInput;
2022-08-28 15:08:15 -04:00
use Filament\Forms\Components\Select;
2022-08-07 12:48:05 -04:00
use Filament\Forms\Components\Toggle;
2022-08-28 15:08:15 -04:00
use App\Models\Bidders;
use App\Models\CarShowCategory;
2022-08-06 15:39:24 -04:00
class VehiclesResource extends Resource
{
protected static ?string $model = Vehicles::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-28 15:08:15 -04:00
Select::make('owner')
2022-09-12 07:57:09 -04:00
->label('Owner')
->options(Bidders::all()->pluck('bidder_assigned_number', 'idbidders'))
->searchable(),
2022-08-28 15:08:15 -04:00
TextInput::make('year')
2022-09-12 07:57:09 -04:00
->label('Year'),
2022-08-28 15:08:15 -04:00
TextInput::make('make')
2022-09-12 07:57:09 -04:00
->label('Make'),
2022-08-28 15:08:15 -04:00
TextInput::make('model')
2022-09-12 07:57:09 -04:00
->label('Model'),
2022-08-28 15:08:15 -04:00
Select::make('type')
2022-09-12 07:57:09 -04:00
->label('Type')
2022-09-26 19:12:15 -04:00
->options(CarShowCategory::vehtype()->pluck('category_name', 'id'))
->searchable(),
2022-08-06 15:39:24 -04:00
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
2022-08-16 18:10:49 -04:00
TextColumn::make('vehicleOwner.bidder_assigned_number')
2022-08-14 11:32:00 -04:00
->label('Number')
->sortable(),
TextColumn::make('year')
->label('Year')
->sortable(),
TextColumn::make('make')
->label('Make')
->sortable(),
TextColumn::make('model')
->label('Model')
->sortable(),
TextColumn::make('vehicleType.category_name')
->label('Type')
->sortable(),
BooleanColumn::make('doNotJudge')
->label('Judged?')
->sortable()
->falseIcon('heroicon-o-badge-check')
->trueIcon('heroicon-o-x-circle')
->trueColor('danger')
->falseColor('success'),
TextColumn::make('vehicleOwner.bidder_fname')
->label('First Name')
->sortable(),
TextColumn::make('vehicleOwner.bidder_lname')
->label('Last Name')
->sortable(),
2022-08-06 15:39:24 -04:00
])
->filters([
//
])
->actions([
Tables\Actions\EditAction::make(),
])
->bulkActions([
Tables\Actions\DeleteBulkAction::make(),
2022-09-26 19:12:15 -04:00
])
->defaultSort('vehicleOwner.bidder_assigned_number');
2022-08-06 15:39:24 -04:00
}
public static function getRelations(): array
{
return [
2022-08-28 15:08:15 -04:00
RelationManagers\VehicleOwnerRelationManager::class,
RelationManagers\VehicleScoresRelationManager::class,
RelationManagers\VehicleTypeRelationManager::class,
2023-03-16 13:19:31 -04:00
RelationManagers\CarShowWinnerRelationManager::class,
2022-08-06 15:39:24 -04:00
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListVehicles::route('/'),
'create' => Pages\CreateVehicles::route('/create'),
'edit' => Pages\EditVehicles::route('/{record}/edit'),
];
}
}