32 lines
714 B
PHP
32 lines
714 B
PHP
<?php
|
|
|
|
namespace App\Jobs;
|
|
|
|
use App\Models\OperationRun;
|
|
use Illuminate\Bus\Queueable;
|
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
|
use Illuminate\Foundation\Bus\Dispatchable;
|
|
use Illuminate\Queue\InteractsWithQueue;
|
|
use Illuminate\Queue\SerializesModels;
|
|
|
|
class PruneOldOperationRunsJob implements ShouldQueue
|
|
{
|
|
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
|
|
|
/**
|
|
* Create a new job instance.
|
|
*/
|
|
public function __construct(
|
|
public int $retentionDays = 90
|
|
) {}
|
|
|
|
/**
|
|
* Execute the job.
|
|
*/
|
|
public function handle(): void
|
|
{
|
|
OperationRun::where('created_at', '<', now()->subDays($this->retentionDays))
|
|
->delete();
|
|
}
|
|
}
|