<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use App\Models\JobSubmission;

class AutoApproveSubmissions extends Command
{
    protected $signature = 'submissions:auto-approve';
    protected $description = 'Automatically approve pending submissions after 24 hours';

    public function handle()
    {
        $submissions = JobSubmission::where('status', 'pending')
            ->where('created_at', '<=', now()->subHours(24))
            ->get();

        foreach ($submissions as $submission) {
            $submission->status = 'approved';
            $submission->save();
        }

        $this->info("✅ Auto-approved {$submissions->count()} submissions.");
    }
}