<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class JobSubmission extends Model
{
    use HasFactory;

    protected $fillable = [
        'user_id',
        'job_id',
        'proof_link',
        'status',
    ];

    public function user()
    {
        return $this->belongsTo(User::class);
    }

    public function job()
    {
        return $this->belongsTo(Job::class);
    }
    
    public function scopePendingOlderThan($query, $hours = 24)
{
    return $query->where('status', 'pending')
                 ->where('created_at', '<=', now()->subHours($hours));
}
}
