You've already forked Atomcms-edit
98 lines
2.7 KiB
PHP
Executable File
98 lines
2.7 KiB
PHP
Executable File
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Filament\Resources\RadioSongPlay;
|
|
|
|
use App\Filament\Resources\RadioSongPlay\Pages\ManageRadioSongPlays;
|
|
use App\Models\RadioSongPlay;
|
|
use Filament\Actions\DeleteAction;
|
|
use Filament\Actions\DeleteBulkAction;
|
|
use Filament\Resources\Resource;
|
|
use Filament\Schemas\Schema;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Filters\SelectFilter;
|
|
use Filament\Tables\Table;
|
|
|
|
class RadioSongPlayResource extends Resource
|
|
{
|
|
#[\Override]
|
|
protected static ?string $model = RadioSongPlay::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/song-plays';
|
|
|
|
#[\Override]
|
|
public static function getNavigationLabel(): string
|
|
{
|
|
return 'Song Geschiedenis';
|
|
}
|
|
|
|
#[\Override]
|
|
public static function getLabel(): string
|
|
{
|
|
return 'Song Play';
|
|
}
|
|
|
|
#[\Override]
|
|
public static function getPluralLabel(): string
|
|
{
|
|
return 'Song Geschiedenis';
|
|
}
|
|
|
|
#[\Override]
|
|
public static function table(Table $table): Table
|
|
{
|
|
return $table
|
|
->query(RadioSongPlay::query())
|
|
->defaultSort('played_at', 'desc')
|
|
->columns([
|
|
TextColumn::make('title')
|
|
->label('Titel')
|
|
->searchable()
|
|
->sortable(),
|
|
TextColumn::make('artist')
|
|
->label('Artiest')
|
|
->searchable()
|
|
->sortable(),
|
|
TextColumn::make('played_at')
|
|
->label('Gespeeld op')
|
|
->dateTime('d-m-Y H:i:s')
|
|
->sortable(),
|
|
TextColumn::make('duration')
|
|
->label('Duur')
|
|
->formatStateUsing(fn ($state) => $state ? gmdate('i:s', $state) : '-')
|
|
->sortable(),
|
|
])
|
|
->filters([
|
|
SelectFilter::make('artist')
|
|
->label('Artiest')
|
|
->options(fn () => RadioSongPlay::distinct()->whereNotNull('artist')->pluck('artist', 'artist')->toArray())
|
|
->searchable(),
|
|
])
|
|
->actions([
|
|
DeleteAction::make()
|
|
->label('Verwijderen'),
|
|
])
|
|
->bulkActions([
|
|
DeleteBulkAction::make()
|
|
->label('Selectie verwijderen'),
|
|
])
|
|
->poll('30s');
|
|
}
|
|
|
|
#[\Override]
|
|
public static function getPages(): array
|
|
{
|
|
return [
|
|
'index' => ManageRadioSongPlays::route('/'),
|
|
];
|
|
}
|
|
}
|