You've already forked Atomcms-edit
Initial commit
This commit is contained in:
@@ -0,0 +1,265 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\RadioApplications;
|
||||
|
||||
use App\Models\RadioApplication;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Tables\Table;
|
||||
|
||||
class RadioApplicationResource extends Resource
|
||||
{
|
||||
#[\Override]
|
||||
protected static ?string $model = RadioApplication::class;
|
||||
|
||||
#[\Override]
|
||||
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-microphone';
|
||||
|
||||
#[\Override]
|
||||
protected static string|\UnitEnum|null $navigationGroup = 'Radio';
|
||||
|
||||
#[\Override]
|
||||
protected static ?string $slug = 'radio/applications';
|
||||
|
||||
#[\Override]
|
||||
public static function getNavigationLabel(): string
|
||||
{
|
||||
return 'DJ Aanmeldingen';
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function getModelLabel(): string
|
||||
{
|
||||
return 'DJ Aanmelding';
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function getPluralModelLabel(): string
|
||||
{
|
||||
return 'DJ Aanmeldingen';
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function canCreate(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema
|
||||
->components([
|
||||
Section::make('Persoonlijke Gegevens')
|
||||
->schema([
|
||||
Select::make('user_id')
|
||||
->relationship('user', 'username')
|
||||
->required()
|
||||
->searchable()
|
||||
->label('Gebruiker'),
|
||||
|
||||
TextInput::make('real_name')
|
||||
->required()
|
||||
->label('Echte Naam'),
|
||||
|
||||
TextInput::make('age')
|
||||
->required()
|
||||
->numeric()
|
||||
->label('Leeftijd'),
|
||||
]),
|
||||
|
||||
Section::make('DJ Gegevens')
|
||||
->schema([
|
||||
Textarea::make('availability')
|
||||
->required()
|
||||
->label('Beschikbaarheid')
|
||||
->helperText('Wanneer kan je draaien? (bijv. maandag 20:00-22:00)')
|
||||
->rows(3),
|
||||
|
||||
Textarea::make('experience')
|
||||
->label('Ervaring')
|
||||
->helperText('Heb je ervaring als DJ?')
|
||||
->rows(3),
|
||||
|
||||
Textarea::make('motivation')
|
||||
->required()
|
||||
->label('Motivatie')
|
||||
->helperText('Waarom wil je DJ worden?')
|
||||
->rows(3),
|
||||
|
||||
Textarea::make('music_style')
|
||||
->label('Muziekstijl')
|
||||
->helperText('Welke muziekstijl draai je graag?')
|
||||
->rows(2),
|
||||
|
||||
TextInput::make('discord_username')
|
||||
->label('Discord Gebruikersnaam')
|
||||
->helperText('Voor contact'),
|
||||
|
||||
Select::make('rank_id')
|
||||
->relationship('rank', 'name')
|
||||
->label('Gewenste Rank')
|
||||
->nullable(),
|
||||
]),
|
||||
|
||||
Section::make('Status')
|
||||
->schema([
|
||||
Select::make('status')
|
||||
->options([
|
||||
'pending' => 'In afwachting',
|
||||
'approved' => 'Goedgekeurd',
|
||||
'rejected' => 'Afgewezen',
|
||||
])
|
||||
->required()
|
||||
->label('Status'),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->defaultSort('created_at', 'desc')
|
||||
->columns([
|
||||
TextColumn::make('user.username')
|
||||
->label('Gebruiker')
|
||||
->sortable()
|
||||
->searchable(),
|
||||
|
||||
TextColumn::make('real_name')
|
||||
->label('Naam')
|
||||
->sortable()
|
||||
->searchable(),
|
||||
|
||||
TextColumn::make('age')
|
||||
->label('Leeftijd')
|
||||
->sortable(),
|
||||
|
||||
TextColumn::make('rank.name')
|
||||
->label('Gewenste Rank')
|
||||
->sortable(),
|
||||
|
||||
TextColumn::make('status')
|
||||
->label('Status')
|
||||
->badge()
|
||||
->formatStateUsing(fn (?string $state) => match ($state) {
|
||||
'pending' => 'In afwachting',
|
||||
'approved' => 'Goedgekeurd',
|
||||
'rejected' => 'Afgewezen',
|
||||
default => 'In afwachting',
|
||||
})
|
||||
->color(fn (?string $state) => [
|
||||
'pending' => 'warning',
|
||||
'approved' => 'success',
|
||||
'rejected' => 'danger',
|
||||
][$state ?? 'pending'] ?? 'gray')
|
||||
->sortable(),
|
||||
|
||||
TextColumn::make('created_at')
|
||||
->label('Aangemeld op')
|
||||
->dateTime('d-m-Y H:i')
|
||||
->sortable(),
|
||||
])
|
||||
->filters([
|
||||
SelectFilter::make('status')
|
||||
->options([
|
||||
'pending' => 'In afwachting',
|
||||
'approved' => 'Goedgekeurd',
|
||||
'rejected' => 'Afgewezen',
|
||||
])
|
||||
->label('Status'),
|
||||
])
|
||||
->recordActions([
|
||||
Action::make('approve')
|
||||
->label('Goedkeuren')
|
||||
->icon('heroicon-o-check-circle')
|
||||
->color('success')
|
||||
->visible(fn (RadioApplication $record) => $record->status === 'pending')
|
||||
->requiresConfirmation()
|
||||
->modalHeading('DJ Aanmelding Goedkeuren')
|
||||
->modalDescription('Weet je zeker dat je deze aanmelding wilt goedkeuren?')
|
||||
->action(function (RadioApplication $record) {
|
||||
$record->update([
|
||||
'status' => 'approved',
|
||||
'approved_by' => auth()->id(),
|
||||
'approved_at' => now(),
|
||||
]);
|
||||
|
||||
Notification::make()
|
||||
->success()
|
||||
->title('Goedgekeurd')
|
||||
->body("De aanmelding van {$record->user->username} is goedgekeurd.")
|
||||
->send();
|
||||
}),
|
||||
|
||||
Action::make('reject')
|
||||
->label('Afwijzen')
|
||||
->icon('heroicon-o-x-circle')
|
||||
->color('danger')
|
||||
->visible(fn (RadioApplication $record) => in_array($record->status, ['pending', 'approved']))
|
||||
->requiresConfirmation()
|
||||
->modalHeading('DJ Aanmelding Afwijzen')
|
||||
->modalDescription('Weet je zeker dat je deze aanmelding wilt afwijzen?')
|
||||
->action(function (RadioApplication $record) {
|
||||
$record->update([
|
||||
'status' => 'rejected',
|
||||
'rejected_by' => auth()->id(),
|
||||
'rejected_at' => now(),
|
||||
]);
|
||||
|
||||
Notification::make()
|
||||
->success()
|
||||
->title('Afgewezen')
|
||||
->body("De aanmelding van {$record->user->username} is afgewezen.")
|
||||
->send();
|
||||
}),
|
||||
|
||||
Action::make('reopen')
|
||||
->label('Heropenen')
|
||||
->icon('heroicon-o-arrow-path')
|
||||
->color('warning')
|
||||
->visible(fn (RadioApplication $record) => $record->status === 'rejected')
|
||||
->requiresConfirmation()
|
||||
->modalHeading('Aanmelding Heropenen')
|
||||
->modalDescription('Dit zet de status terug naar "In afwachting".')
|
||||
->action(function (RadioApplication $record) {
|
||||
$record->update([
|
||||
'status' => 'pending',
|
||||
'rejected_by' => null,
|
||||
'rejected_at' => null,
|
||||
]);
|
||||
|
||||
Notification::make()
|
||||
->success()
|
||||
->title('Heropend')
|
||||
->body('De aanmelding is heropend.')
|
||||
->send();
|
||||
}),
|
||||
|
||||
DeleteAction::make(),
|
||||
])
|
||||
->toolbarActions([
|
||||
DeleteBulkAction::make(),
|
||||
]);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListRadioApplications::route('/'),
|
||||
'edit' => Pages\EditRadioApplication::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user