<?php

namespace App\Models;

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

class LoanInstallmentExcuse extends Model
{
    protected $fillable = [
        'loan_id','loan_installment_id','branch_id','reason','excused_by','excused_at',
    ];

    protected function casts(): array
    {
        return ['excused_at'=>'datetime'];
    }

    public function loan(): BelongsTo { return $this->belongsTo(Loan::class); }
    public function installment(): BelongsTo { return $this->belongsTo(LoanInstallment::class, 'loan_installment_id'); }
    public function user(): BelongsTo { return $this->belongsTo(User::class, 'excused_by'); }
}
