mirror of
https://github.com/alexjustesen/speedtest-tracker.git
synced 2026-06-23 07:30:09 +00:00
59 lines
1.6 KiB
PHP
59 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Pages;
|
|
|
|
use App\Jobs\DeleteResultsData;
|
|
use Filament\Actions\Action;
|
|
use Filament\Notifications\Notification;
|
|
use Filament\Pages\Page;
|
|
|
|
class DeleteData extends Page
|
|
{
|
|
protected static ?string $navigationGroup = 'System';
|
|
|
|
protected static ?string $navigationIcon = 'heroicon-o-trash';
|
|
|
|
protected static ?int $navigationSort = 2;
|
|
|
|
protected static ?string $slug = 'system/delete-data';
|
|
|
|
protected static string $view = 'filament.pages.delete-data';
|
|
|
|
protected ?string $maxContentWidth = '3xl';
|
|
|
|
public function mount(): void
|
|
{
|
|
abort_unless(auth()->user()->is_admin, 403);
|
|
}
|
|
|
|
public static function shouldRegisterNavigation(): bool
|
|
{
|
|
return auth()->user()->is_admin;
|
|
}
|
|
|
|
public function getHeaderActions(): array
|
|
{
|
|
return [
|
|
Action::make('delete')
|
|
->color('danger')
|
|
->icon('heroicon-o-trash')
|
|
->action(fn () => $this->deleteData())
|
|
->requiresConfirmation()
|
|
->modalHeading('Confirmation')
|
|
->modalDescription('This will delete all results data from the database, this cannot be undone. You have been warned!')
|
|
->modalSubmitActionLabel('Yes, I am sure'),
|
|
];
|
|
}
|
|
|
|
protected function deleteData()
|
|
{
|
|
DeleteResultsData::dispatch();
|
|
|
|
Notification::make()
|
|
->title('Deleting results data')
|
|
->body('The job has been added to the queue and will be completed shortly.')
|
|
->warning()
|
|
->send();
|
|
}
|
|
}
|