<?php
namespace App\Models;
use App\Enums\LedgerDirection; use App\Enums\LedgerType;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo;
class LedgerEntry extends Model { public $timestamps=false; protected $fillable=['merchant_id','transfer_id','settlement_batch_id','direction','amount_minor','currency','type','balance_after_minor','note','created_by','created_at']; protected function casts():array{return ['direction'=>LedgerDirection::class,'type'=>LedgerType::class,'amount_minor'=>'integer','balance_after_minor'=>'integer','created_at'=>'datetime'];} public function merchant():BelongsTo{return $this->belongsTo(Merchant::class);} public function transfer():BelongsTo{return $this->belongsTo(Transfer::class);} protected static function booted():void{static::updating(fn()=>throw new \LogicException('Ledger entries are immutable.')); static::deleting(fn()=>throw new \LogicException('Ledger entries are immutable.'));} }
