2024-09-17 10:57:06 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Jobs;
|
|
|
|
|
|
|
|
|
|
use App\Models\PrivateKey;
|
|
|
|
|
use Illuminate\Bus\Queueable;
|
|
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
|
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
|
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
|
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
|
use Carbon\Carbon;
|
|
|
|
|
|
|
|
|
|
class CleanupSshKeysJob implements ShouldQueue
|
|
|
|
|
{
|
|
|
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
|
|
|
|
|
|
public function handle()
|
|
|
|
|
{
|
|
|
|
|
$oneWeekAgo = Carbon::now()->subWeek();
|
|
|
|
|
|
|
|
|
|
PrivateKey::where('created_at', '<', $oneWeekAgo)
|
2024-09-17 12:43:02 +00:00
|
|
|
->get()
|
|
|
|
|
->each(function ($privateKey) {
|
|
|
|
|
$privateKey->safeDelete();
|
|
|
|
|
});
|
2024-09-17 10:57:06 +00:00
|
|
|
}
|
2024-09-17 12:43:02 +00:00
|
|
|
}
|