<?php

namespace App\Models;

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

class AccountLedger extends Model
{
    use HasFactory;

    protected $fillable = [
        'user_id','user_account_id','type','trx_no',
        'reference_type','reference_id',
        'debit','credit','description','posted_at'
    ];

    protected $casts = [
        'posted_at' => 'datetime',
        'debit'     => 'decimal:2',
        'credit'    => 'decimal:2',
    ];

    public function account()
    {
        return $this->belongsTo(UserAccount::class, 'user_account_id');
    }
}