<?php

namespace App\Models;

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

class ChangeOrder extends Model
{
    protected $fillable = [
        'project_id',
        'title',
        'description',
        'amount',
        'status',
        'requested_at',
        'responded_at',
        'responded_by',
    ];

    protected $casts = [
        'requested_at' => 'date',
        'responded_at' => 'date',
        'amount' => 'decimal:2',
    ];

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

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