<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class ContractorSBU extends Model
{
    protected $table = 'contractor_sbu';

    protected $fillable = [
        'contractor_id',
        'sbu_number',
        'classification',
        'sub_classification',
        'issue_date',
        'expiry_date',
        'file_url',
    ];

    protected $casts = [
        'issue_date' => 'date',
        'expiry_date' => 'date',
    ];

    public function contractor(): BelongsTo
    {
        return $this->belongsTo(Contractor::class);
    }

    public function isValid(): bool
    {
        return $this->expiry_date->isFuture();
    }
}