You've already forked Atomcms-edit
135 lines
3.7 KiB
PHP
Executable File
135 lines
3.7 KiB
PHP
Executable File
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Filament\Resources\RadioHistory;
|
|
|
|
use App\Filament\Resources\RadioHistory\Pages\ManageRadioHistory;
|
|
use App\Models\RadioHistory;
|
|
use Filament\Actions\DeleteAction;
|
|
use Filament\Actions\DeleteBulkAction;
|
|
use Filament\Actions\EditAction;
|
|
use Filament\Forms\Components\DateTimePicker;
|
|
use Filament\Forms\Components\Select;
|
|
use Filament\Forms\Components\Textarea;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Resources\Resource;
|
|
use Filament\Schemas\Components\Section;
|
|
use Filament\Schemas\Schema;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Table;
|
|
|
|
class RadioHistoryResource extends Resource
|
|
{
|
|
#[\Override]
|
|
protected static ?string $model = RadioHistory::class;
|
|
|
|
#[\Override]
|
|
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-clock';
|
|
|
|
#[\Override]
|
|
protected static string|\UnitEnum|null $navigationGroup = 'Radio';
|
|
|
|
#[\Override]
|
|
protected static ?string $slug = 'radio/history';
|
|
|
|
#[\Override]
|
|
public static function getNavigationLabel(): string
|
|
{
|
|
return 'DJ Geschiedenis';
|
|
}
|
|
|
|
#[\Override]
|
|
public static function getModelLabel(): string
|
|
{
|
|
return 'DJ Sessie';
|
|
}
|
|
|
|
#[\Override]
|
|
public static function getPluralModelLabel(): string
|
|
{
|
|
return 'DJ Geschiedenis';
|
|
}
|
|
|
|
#[\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'),
|
|
|
|
TextInput::make('show_name')
|
|
->label('Show Naam')
|
|
->maxLength(255),
|
|
|
|
DateTimePicker::make('started_at')
|
|
->required()
|
|
->label('Start Tijd'),
|
|
|
|
DateTimePicker::make('ended_at')
|
|
->label('Eind Tijd'),
|
|
|
|
TextInput::make('listeners_count')
|
|
->label('Aantal Luisteraars')
|
|
->numeric()
|
|
->default(0),
|
|
|
|
Textarea::make('notes')
|
|
->label('Notities')
|
|
->rows(3),
|
|
]),
|
|
]);
|
|
}
|
|
|
|
#[\Override]
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->defaultSort('started_at', 'desc')
|
|
->columns([
|
|
TextColumn::make('user.username')
|
|
->label('DJ')
|
|
->searchable(),
|
|
|
|
TextColumn::make('show_name')
|
|
->label('Show')
|
|
->searchable(),
|
|
|
|
TextColumn::make('started_at')
|
|
->label('Gestart')
|
|
->dateTime('d-m-Y H:i'),
|
|
|
|
TextColumn::make('ended_at')
|
|
->label('Gestopt')
|
|
->dateTime('d-m-Y H:i'),
|
|
|
|
TextColumn::make('duration')
|
|
->label('Duur'),
|
|
|
|
TextColumn::make('listeners_count')
|
|
->label('Luisteraars'),
|
|
])
|
|
->actions([
|
|
EditAction::make(),
|
|
DeleteAction::make(),
|
|
])
|
|
->headerActions([
|
|
DeleteBulkAction::make(),
|
|
]);
|
|
}
|
|
|
|
#[\Override]
|
|
public static function getPages(): array
|
|
{
|
|
return [
|
|
'index' => ManageRadioHistory::route('/'),
|
|
];
|
|
}
|
|
}
|