Files

149 lines
4.9 KiB
PHP
Executable File

<?php
namespace App\Filament\Resources\RadioRanks;
use App\Models\RadioRank;
use Filament\Actions\DeleteBulkAction;
use Filament\Actions\EditAction;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Resources\Resource;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Schema;
use Filament\Tables\Columns\IconColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
class RadioRankResource extends Resource
{
#[\Override]
protected static ?string $model = RadioRank::class;
#[\Override]
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-musical-note';
#[\Override]
protected static string|\UnitEnum|null $navigationGroup = 'Radio';
#[\Override]
protected static ?string $slug = 'radio/ranks';
#[\Override]
public static function form(Schema $schema): Schema
{
return $schema
->components([
Section::make('Rank Informatie')
->schema([
TextInput::make('name')
->autofocus()
->maxLength(255)
->required()
->label('Naam'),
TextInput::make('description')
->maxLength(255)
->label('Beschrijving'),
TextInput::make('badge_code')
->maxLength(255)
->label('Badge Code'),
]),
Section::make('Sollicitatie Instellingen')
->schema([
Toggle::make('accepts_applications')
->label('Accepteert Sollicitaties')
->helperText('Zet aan als je wilt dat mensen voor deze rank kunnen solliciteren')
->live(),
Select::make('application_rank')
->label('Sollicitatie Type')
->options([
'all' => 'Alle Ranks',
'proef_dj' => 'Alleen Proef DJ',
'dj' => 'Alleen DJ',
'hoofd_dj' => 'Alleen Hoofd DJ',
])
->helperText('Selecteer voor welke rank mensen mogen solliciteren')
->visible(fn ($get) => $get('accepts_applications'))
->required(fn ($get) => $get('accepts_applications')),
]),
]);
}
#[\Override]
public static function table(Table $table): Table
{
return $table
->defaultSort('id', 'desc')
->columns([
TextColumn::make('id')
->label('ID'),
TextColumn::make('name')
->label('Naam'),
TextColumn::make('description')
->label('Beschrijving'),
TextColumn::make('badge_code')
->label('Badge Code'),
IconColumn::make('accepts_applications')
->label('Sollicitaties')
->boolean()
->trueIcon('heroicon-o-check-circle')
->falseIcon('heroicon-o-x-circle')
->trueColor('success')
->falseColor('danger'),
TextColumn::make('application_rank')
->label('Type')
->badge()
->formatStateUsing(fn (string $state): string => match ($state) {
'all' => 'Alle',
'proef_dj' => 'Proef DJ',
'dj' => 'DJ',
'hoofd_dj' => 'Hoofd DJ',
default => $state,
})
->color(fn (string $state): string => match ($state) {
'all' => 'gray',
'proef_dj' => 'info',
'dj' => 'warning',
'hoofd_dj' => 'success',
default => 'gray',
}),
])
->filters([
//
])
->actions([
EditAction::make(),
])
->headerActions([
DeleteBulkAction::make(),
]);
}
#[\Override]
public static function getRelations(): array
{
return [
//
];
}
#[\Override]
public static function getPages(): array
{
return [
'index' => Pages\ListRadioRanks::route('/'),
'create' => Pages\CreateRadioRank::route('/create'),
'edit' => Pages\EditRadioRank::route('/{record}/edit'),
];
}
}