belongsTo(AccountType::class); } public function client(): BelongsTo { return $this->belongsTo(Client::class); } public function getStartingBalanceAttribute() { if ($this->balances()->exists()) { return $this->balances() ->where('is_starting', true) ->orderBy('id', 'desc')->first()->balance; } return null; } public function balances(): HasMany { return $this->hasMany(Balance::class); } public function getCurrentBalanceAttribute() { if ($this->balances()->exists()) { return $this->balances() ->orderBy('id', 'desc')->first()->balance; } return null; } }