Add all files
This commit is contained in:
40
app/Jobs/Server/SuspendJob.php
Normal file
40
app/Jobs/Server/SuspendJob.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Jobs\Server;
|
||||
|
||||
use App\Helpers\ExtensionHelper;
|
||||
use App\Helpers\NotificationHelper;
|
||||
use App\Models\Service;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class SuspendJob implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/**
|
||||
* Create a new job instance.
|
||||
*/
|
||||
public function __construct(public Service $service, public $sendNotification = true) {}
|
||||
|
||||
/**
|
||||
* Execute the job.
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
try {
|
||||
$data = ExtensionHelper::suspendServer($this->service);
|
||||
} catch (\Exception $e) {
|
||||
if ($e->getMessage() == 'No server assigned to this product') {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->sendNotification && isset($data)) {
|
||||
NotificationHelper::serverSuspendedNotification($this->service->user, $this->service, is_array($data) ? $data : []);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user