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

79 lines
2.3 KiB
PHP
Raw Normal View History

2022-08-06 15:39:24 -04:00
<?php
namespace App\Filament\Resources;
use App\Filament\Resources\PeoplesChoiceResource\Pages;
use App\Filament\Resources\PeoplesChoiceResource\RelationManagers;
use App\Models\PeoplesChoice;
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-07 13:17:10 -04:00
use App\Models\Vehicles;
use Filament\Forms\Components\Select;
2022-08-06 15:39:24 -04:00
class PeoplesChoiceResource extends Resource
{
protected static ?string $model = PeoplesChoice::class;
protected static ?string $navigationIcon = 'heroicon-o-collection';
2022-08-07 13:07:31 -04:00
protected static ?string $navigationGroup = 'Car Show';
2022-08-07 13:09:46 -04:00
protected static ?string $pluralModelLabel = 'Peoples Choice';
2022-08-06 15:39:24 -04:00
public static function form(Form $form): Form
{
return $form
->schema([
2022-08-07 13:17:10 -04:00
Select::make('vehicle')
->label('Vehicle')
2022-08-07 13:21:50 -04:00
->options(Vehicles::all()->orderBy('owner', 'asc')->pluck('owner', 'id'))
2022-08-07 13:17:10 -04:00
->searchable(),
TextInput::make('pc_count'),
2022-08-06 15:39:24 -04:00
]);
}
public static function table(Table $table): Table
{
return $table
->columns([
2022-08-07 13:17:10 -04:00
TextColumn::make('pc_count')->label('PC Vote Count'),
2022-08-07 13:18:48 -04:00
TextColumn::make('vehicles.owner')->label('Vehicle Number'),
TextColumn::make('vehicles.year')->label('Year'),
TextColumn::make('vehicles.make')->label('Make'),
TextColumn::make('vehicles.model')->label('Model'),
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 [
//
];
}
public static function getPages(): array
{
return [
'index' => Pages\ListPeoplesChoices::route('/'),
'create' => Pages\CreatePeoplesChoice::route('/create'),
'edit' => Pages\EditPeoplesChoice::route('/{record}/edit'),
];
}
}