forked from alexjustesen/speedtest-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeleteData.php
More file actions
58 lines (45 loc) · 1.56 KB
/
DeleteData.php
File metadata and controls
58 lines (45 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?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();
}
}