You've already forked Atomcms-edit
162 lines
4.9 KiB
PHP
Executable File
162 lines
4.9 KiB
PHP
Executable File
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Filament\Resources\RadioSchedules;
|
|
|
|
use App\Filament\Resources\RadioSchedules\Pages\ManageRadioSchedules;
|
|
use App\Models\RadioSchedule;
|
|
use Filament\Actions\DeleteAction;
|
|
use Filament\Actions\DeleteBulkAction;
|
|
use Filament\Actions\EditAction;
|
|
use Filament\Forms\Components\Select;
|
|
use Filament\Forms\Components\Textarea;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Forms\Components\TimePicker;
|
|
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\Filters\SelectFilter;
|
|
use Filament\Tables\Table;
|
|
|
|
class RadioScheduleResource extends Resource
|
|
{
|
|
#[\Override]
|
|
protected static ?string $model = RadioSchedule::class;
|
|
|
|
#[\Override]
|
|
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-calendar';
|
|
|
|
#[\Override]
|
|
protected static string|\UnitEnum|null $navigationGroup = 'Radio';
|
|
|
|
#[\Override]
|
|
protected static ?string $slug = 'radio/schedules';
|
|
|
|
#[\Override]
|
|
public static function getNavigationLabel(): string
|
|
{
|
|
return 'DJ Rooster';
|
|
}
|
|
|
|
#[\Override]
|
|
public static function getModelLabel(): string
|
|
{
|
|
return 'DJ Slot';
|
|
}
|
|
|
|
#[\Override]
|
|
public static function getPluralModelLabel(): string
|
|
{
|
|
return 'DJ Rooster';
|
|
}
|
|
|
|
#[\Override]
|
|
public static function form(Schema $schema): Schema
|
|
{
|
|
return $schema
|
|
->components([
|
|
Section::make()
|
|
->schema([
|
|
Select::make('user_id')
|
|
->relationship('user', 'username')
|
|
->required()
|
|
->searchable()
|
|
->label('DJ'),
|
|
|
|
Select::make('day')
|
|
->required()
|
|
->label('Dag')
|
|
->options([
|
|
'monday' => 'Maandag',
|
|
'tuesday' => 'Dinsdag',
|
|
'wednesday' => 'Woensdag',
|
|
'thursday' => 'Donderdag',
|
|
'friday' => 'Vrijdag',
|
|
'saturday' => 'Zaterdag',
|
|
'sunday' => 'Zondag',
|
|
]),
|
|
|
|
TimePicker::make('start_time')
|
|
->required()
|
|
->label('Start Tijd'),
|
|
|
|
TimePicker::make('end_time')
|
|
->required()
|
|
->label('Eind Tijd'),
|
|
|
|
TextInput::make('show_name')
|
|
->label('Show Naam')
|
|
->placeholder('Bijv. Friday Night Fever')
|
|
->maxLength(255),
|
|
|
|
Textarea::make('description')
|
|
->label('Beschrijving')
|
|
->placeholder('Beschrijving van de show')
|
|
->rows(2),
|
|
|
|
Toggle::make('is_active')
|
|
->label('Actief')
|
|
->default(true),
|
|
]),
|
|
]);
|
|
}
|
|
|
|
#[\Override]
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->defaultSort('start_time')
|
|
->columns([
|
|
TextColumn::make('day_name')
|
|
->label('Dag'),
|
|
|
|
TextColumn::make('time_range')
|
|
->label('Tijd'),
|
|
|
|
TextColumn::make('user.username')
|
|
->label('DJ')
|
|
->searchable(),
|
|
|
|
TextColumn::make('show_name')
|
|
->label('Show')
|
|
->searchable(),
|
|
|
|
IconColumn::make('is_active')
|
|
->label('Actief')
|
|
->boolean(),
|
|
])
|
|
->filters([
|
|
SelectFilter::make('day')
|
|
->options([
|
|
'monday' => 'Maandag',
|
|
'tuesday' => 'Dinsdag',
|
|
'wednesday' => 'Woensdag',
|
|
'thursday' => 'Donderdag',
|
|
'friday' => 'Vrijdag',
|
|
'saturday' => 'Zaterdag',
|
|
'sunday' => 'Zondag',
|
|
])
|
|
->label('Dag'),
|
|
])
|
|
->actions([
|
|
EditAction::make(),
|
|
DeleteAction::make(),
|
|
])
|
|
->headerActions([
|
|
DeleteBulkAction::make(),
|
|
]);
|
|
}
|
|
|
|
#[\Override]
|
|
public static function getPages(): array
|
|
{
|
|
return [
|
|
'index' => ManageRadioSchedules::route('/'),
|
|
];
|
|
}
|
|
}
|