defaultSort('created_at', 'desc') ->columns([ TextColumn::make('type') ->label('Type') ->formatStateUsing(fn (string $state): string => ucfirst(str_replace('_', ' ', $state))) ->searchable(), BadgeColumn::make('severity') ->label('Severity') ->colors([ 'info' => 'info', 'warning' => 'warning', 'error' => 'error', 'danger' => 'critical', ]) ->formatStateUsing(fn (string $state): string => ucfirst($state)), TextColumn::make('message') ->label('Message') ->limit(50) ->tooltip(fn (AlertLog $record): ?string => $record->message), TextColumn::make('created_at') ->label('Time') ->dateTime('d M Y, H:i:s') ->sortable(), BadgeColumn::make('is_read') ->label('Status') ->colors([ 'secondary' => false, 'success' => true, ]) ->formatStateUsing(fn (bool $state): string => $state ? 'Read' : 'Unread'), BadgeColumn::make('sent_via_email') ->label('Email') ->colors([ 'success' => true, 'secondary' => false, ]) ->formatStateUsing(fn (bool $state): string => $state ? 'Yes' : 'No'), BadgeColumn::make('sent_via_discord') ->label('Discord') ->colors([ 'success' => true, 'secondary' => false, ]) ->formatStateUsing(fn (bool $state): string => $state ? 'Yes' : 'No'), ]) ->filters([ SelectFilter::make('severity') ->options([ 'info' => 'Info', 'warning' => 'Warning', 'error' => 'Error', 'critical' => 'Critical', ]), TernaryFilter::make('is_read') ->label('Read Status'), ]) ->recordActions([ Action::make('mark_read') ->label('Mark as Read') ->action(fn (AlertLog $record) => $record->markAsRead()) ->visible(fn (AlertLog $record) => ! $record->is_read) ->icon('heroicon-o-check'), Action::make('delete') ->label('Delete') ->action(fn (AlertLog $record) => $record->delete()) ->icon('heroicon-o-trash') ->color('danger') ->requiresConfirmation(), ]) ->toolbarActions([ Action::make('mark_all_read') ->label('Mark All as Read') ->action(fn () => AlertLog::where('is_read', false)->update(['is_read' => true, 'read_at' => now()])) ->icon('heroicon-o-check-circle'), Action::make('delete_all') ->label('Delete All Logs') ->action(fn () => AlertLog::truncate()) ->icon('heroicon-o-trash') ->color('danger') ->requiresConfirmation(), Action::make('clear_all_logs') ->label('Leeg Alle Logs (Systeem)') ->icon('heroicon-o-trash') ->color('gray') ->action(function () { $updateService = new EmulatorUpdateService; $result = $updateService->clearAllLogs(); Cache::flush(); AlertLog::truncate(); Notification::make() ->success() ->title('🗑️ Alle Logs Geleegd!') ->body($result['message']) ->send(); }) ->requiresConfirmation(), ]); } #[\Override] public static function getPages(): array { return [ 'index' => Pages\ListAlertLogs::route('/'), ]; } }