<?php
namespace App\Models;
use App\Enums\SettlementStatus; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\HasMany;
class SettlementBatch extends Model { protected $fillable=['batch_ref','merchant_id','currency','period_from','period_to','gross_collected_minor','gross_paid_minor','net_position_minor','status','reference','settled_on','settled_by','note']; protected function casts():array{return ['period_from'=>'datetime','period_to'=>'datetime','gross_collected_minor'=>'integer','gross_paid_minor'=>'integer','net_position_minor'=>'integer','status'=>SettlementStatus::class,'settled_on'=>'date'];} public function merchant():BelongsTo{return $this->belongsTo(Merchant::class);} public function legs():HasMany{return $this->hasMany(SettlementLeg::class);} public function transfers(){return $this->belongsToMany(Transfer::class,'settlement_legs')->withPivot(['merchant_id','leg','amount_minor','currency']);} }
