mirror of
https://github.com/alexjustesen/speedtest-tracker.git
synced 2026-08-07 11:44:56 +00:00
2c618e2d4e
* added public dashboard middleware * fixed lint issues
48 lines
1019 B
PHP
48 lines
1019 B
PHP
<?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);
|
|
}
|
|
}
|