lasthourcloud/app/Jobs/CleanupInstanceStuffsJob.php

46 lines
1.2 KiB
PHP
Raw Normal View History

2023-08-15 12:11:38 +00:00
<?php
namespace App\Jobs;
use App\Models\Waitlist;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldBeUnique;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class CleanupInstanceStuffsJob implements ShouldQueue, ShouldBeUnique
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public function __construct()
{
}
// public function uniqueId(): string
// {
// return $this->container_name;
// }
public function handle(): void
{
try {
// $this->cleanup_waitlist();
2023-09-11 15:36:30 +00:00
} catch (\Throwable $e) {
send_internal_notification('CleanupInstanceStuffsJob failed with error: ' . $e->getMessage());
2023-08-15 12:11:38 +00:00
ray($e->getMessage());
2023-08-24 19:09:58 +00:00
throw $e;
2023-08-15 12:11:38 +00:00
}
}
private function cleanup_waitlist()
{
2023-08-30 16:23:55 +00:00
$waitlist = Waitlist::whereVerified(false)->where('created_at', '<', now()->subMinutes(config('constants.waitlist.expiration')))->get();
2023-08-15 12:11:38 +00:00
foreach ($waitlist as $item) {
$item->delete();
}
}
}