From c741b2a819cf44f072e490897089d08a58c2c500 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 12 May 2024 06:25:13 +0200 Subject: [PATCH] Add related models. --- app/Models/Account.php | 5 +++++ app/Models/AccountBalance.php | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/app/Models/Account.php b/app/Models/Account.php index f6182fad25..df6f4ae9c4 100644 --- a/app/Models/Account.php +++ b/app/Models/Account.php @@ -193,6 +193,11 @@ class Account extends Model return $this->hasMany(AccountMeta::class); } + public function accountBalances(): HasMany + { + return $this->hasMany(AccountBalance::class); + } + public function getEditNameAttribute(): string { $name = $this->name; diff --git a/app/Models/AccountBalance.php b/app/Models/AccountBalance.php index d718af79d7..f3a180d728 100644 --- a/app/Models/AccountBalance.php +++ b/app/Models/AccountBalance.php @@ -4,9 +4,16 @@ namespace FireflyIII\Models; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; +use Illuminate\Database\Eloquent\Relations\BelongsTo; class AccountBalance extends Model { protected $fillable = ['account_id', 'transaction_currency_id', 'balance']; use HasFactory; + + + public function account(): BelongsTo + { + return $this->belongsTo(Account::class); + } }