<?php

namespace App\Models;

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

class CustomerStatementEntry extends Model
{
    protected $fillable = ['customer_id','loan_id','branch_id','entry_date','reference','type','description','debit','credit','running_balance','related_type','related_id'];

    protected function casts(): array
    {
        return ['entry_date'=>'datetime','debit'=>'decimal:2','credit'=>'decimal:2','running_balance'=>'decimal:2'];
    }

    public function customer(): BelongsTo { return $this->belongsTo(Customer::class); }
    public function loan(): BelongsTo { return $this->belongsTo(Loan::class); }
    public function branch(): BelongsTo { return $this->belongsTo(Branch::class); }
    public function related(): MorphTo { return $this->morphTo(); }
}
