Feat: SSH Key cleanup job

This commit is contained in:
peaklabs-dev
2024-09-17 12:57:06 +02:00
parent 52c4994d44
commit 95070ab48d
2 changed files with 31 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
<?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)
->whereDoesntHave('gitSources')
->whereDoesntHave('servers')
->delete();
}
}