<?php

namespace App\Models;

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

class InterestIncome extends Model
{
    use HasFactory;

    protected $table = 'interestincome';
    protected $primaryKey = 'id';

    protected $fillable = [
        'iloanid', 'customerid', 'ipid', 'charge', 'chargeddate'
    ];

    protected $casts = [
        'chargeddate' => 'datetime',
        'charge' => 'decimal:2',
    ];

    /**
     * Relationship with Loan
     */
    public function loan()
    {
        return $this->belongsTo(Loan::class, 'iloanid', 'loanid');
    }

    /**
     * Relationship with Customer
     */
    public function customer()
    {
        return $this->belongsTo(Customer::class, 'customerid', 'id');
    }
}