<?php

namespace App\Models;

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

class CreditHistory extends Model
{
    use HasFactory;

    protected $fillable = [
        'lender_id',
        'credit_id',
        'code',
        'type',
        'amount',
        'date',
        'due_date',
        'attachment',
        'is_valid',
        'validation_date',
        'total_repayments',
        'user_id',
        'transaction'
    ];

    // Relationship with Lender
    public function lender() {
        return $this->belongsTo(Lender::class);
    }

    // Relationship with Credit
    public function credit() {
        return $this->belongsTo(Credit::class);
    }

    // Relationship with User
    public function user() {
        return $this->belongsTo(User::class);
    }
}
