<?php

namespace App\Models;

use App\Models\Scopes\BranchScope;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class CapitalInjection extends Model
{
    protected $fillable = ['capital_number','account_id','branch_id','amount','injection_date','reference','notes','created_by'];

    protected function casts(): array
    {
        return ['amount'=>'decimal:2','injection_date'=>'date'];
    }

    protected static function booted(): void
    {
        static::addGlobalScope(new BranchScope());
    }

    public function account(): BelongsTo { return $this->belongsTo(FinancialAccount::class, 'account_id'); }
    public function branch(): BelongsTo { return $this->belongsTo(Branch::class); }
    public function creator(): BelongsTo { return $this->belongsTo(User::class, 'created_by'); }
}
