23 lines
494 B
PHP
23 lines
494 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Jobs\DeleteOlds;
|
|
|
|
use App\Models\Customer;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
/**
|
|
* Delete customers that are older than 36 months
|
|
*/
|
|
class DeleteOldCustomers
|
|
{
|
|
/**
|
|
* Called when the job will be executed.
|
|
*/
|
|
public function handle(): void
|
|
{
|
|
Log::debug(self::class . ' Removing old customers');
|
|
Customer::query()->withTrashed()->where('last_connection', '<=', now()->subMonths(36))->forceDelete();
|
|
}
|
|
}
|