79 lines
2.3 KiB
PHP
79 lines
2.3 KiB
PHP
<?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;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Forms\Components\TextInput;
|
|
use App\Models\Vehicles;
|
|
use Filament\Forms\Components\Select;
|
|
|
|
class PeoplesChoiceResource extends Resource
|
|
{
|
|
protected static ?string $model = PeoplesChoice::class;
|
|
|
|
protected static ?string $navigationIcon = 'heroicon-o-collection';
|
|
|
|
protected static ?string $navigationGroup = 'Car Show';
|
|
|
|
protected static ?string $pluralModelLabel = 'Peoples Choice';
|
|
|
|
public static function form(Form $form): Form
|
|
{
|
|
return $form
|
|
->schema([
|
|
Select::make('vehicle')
|
|
->label('Vehicle')
|
|
->options(Vehicles::all()->sortBy('owner', 'asc')->pluck('owner', 'id'))
|
|
->searchable(),
|
|
TextInput::make('pc_count'),
|
|
]);
|
|
}
|
|
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->columns([
|
|
TextColumn::make('pc_count')->label('PC Vote Count'),
|
|
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'),
|
|
])
|
|
->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'),
|
|
];
|
|
}
|
|
}
|