DeleteExpiredAutoliftOptions.php 681 Bytes
<?php

namespace App\Console\Commands;

use App\Models\EmployerAutoliftOption;
use App\Models\WorkerAutoliftOption;
use Illuminate\Console\Command;

class DeleteExpiredAutoliftOptions extends Command
{
    protected $signature = 'vacancy:delete_expired';

    protected $description = 'Command description';

    public function handle()
    {
        EmployerAutoliftOption::query()
            ->whereRaw('`updated_at` < DATE_SUB(NOW(), INTERVAL `days_repeat` DAY)')
            ->delete();
        WorkerAutoliftOption::query()
            ->whereRaw('`updated_at` < DATE_SUB(NOW(), INTERVAL `days_repeat` DAY)')
            ->delete();
        return Command::SUCCESS;
    }
}