<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class WithdrawalApproval extends Model
{
    use HasFactory;

    protected $fillable = [
        'credit_id',
        'shareholder_id',
        'branch_id',
        'status',
        'notes',
    ];

    protected $casts = [
        'credit_id' => 'integer',
        'shareholder_id' => 'integer',
        'branch_id' => 'integer',
    ];

    /**
     * Get the credit record associated with this approval
     */
    public function credit()
    {
        return $this->belongsTo(Credit::class);
    }

    /**
     * Get the shareholder user associated with this approval
     */
    public function shareholder()
    {
        return $this->belongsTo(User::class, 'shareholder_id');
    }

    /**
     * Get the branch associated with this approval
     */
    public function branch()
    {
        return $this->belongsTo(Branch::class);
    }
}
