<?php

namespace App\Models;

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

class ContractorRating extends Model
{
    protected $table = 'contractor_ratings';

    protected $fillable = [
        'contractor_id',
        'rated_by',
        'contract_id',
        'score',
        'comment',
        'category',
    ];

    protected $casts = [
        'score' => 'decimal:2',
    ];

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

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

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