<?php

namespace App\Models;

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

class ContractorEquipment extends Model
{
    protected $table = 'contractor_equipments';

    protected $fillable = [
        'contractor_id',
        'name',
        'type',
        'brand',
        'model',
        'year',
        'quantity',
        'condition',
        'ownership_status',
        'certificate_url',
        'is_verified',
        'verified_at',
        'verified_by',
    ];

    protected $casts = [
        'year' => 'integer',
        'quantity' => 'integer',
        'is_verified' => 'boolean',
        'verified_at' => 'datetime',
    ];

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

    public function verifier(): BelongsTo
    {
        return $this->belongsTo(User::class, 'verified_by');
    }
}