DeleteExpiredAutoliftOptions.php 787 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)')
            ->update([
                'is_enabled' => false
            ]);
        WorkerAutoliftOption::query()
            ->whereRaw('`updated_at` < DATE_SUB(NOW(), INTERVAL `days_repeat` DAY)')
            ->update([
                'is_enabled' => false
            ]);
        return Command::SUCCESS;
    }
}