forked from alexjustesen/speedtest-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTruncateResults.php
More file actions
47 lines (39 loc) · 1019 Bytes
/
TruncateResults.php
File metadata and controls
47 lines (39 loc) · 1019 Bytes
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
<?php
namespace App\Jobs;
use App\Models\User;
use Filament\Notifications\Notification;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\DB;
class TruncateResults implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* The number of times the job may be attempted.
*
* @var int
*/
public $tries = 1;
public function __construct(
public User $user,
) {}
/**
* Execute the job.
*/
public function handle(): void
{
try {
DB::table('results')->truncate();
} catch (\Throwable $th) {
$this->fail($th);
return;
}
Notification::make()
->title('Results table truncated!')
->success()
->sendToDatabase($this->user);
}
}