Better ability to store piggy banks.

This commit is contained in:
James Cole
2024-12-01 18:16:48 +01:00
parent f2fab5d4ee
commit cdf1ebf3f7
17 changed files with 297 additions and 135 deletions

View File

@@ -55,7 +55,7 @@ class PiggyBank extends Model
'target_amount' => 'string',
];
protected $fillable = ['name', 'account_id', 'order', 'target_amount', 'start_date', 'start_date_tz', 'target_date', 'target_date_tz', 'active'];
protected $fillable = ['name', 'account_id', 'order', 'target_amount', 'start_date', 'start_date_tz', 'target_date', 'target_date_tz', 'active','transaction_currency_id'];
/**
* Route binder. Converts the key in the URL to the specified object (or throw 404).
@@ -67,9 +67,9 @@ class PiggyBank extends Model
if (auth()->check()) {
$piggyBankId = (int)$value;
$piggyBank = self::where('piggy_banks.id', $piggyBankId)
->leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')
->where('accounts.user_id', auth()->user()->id)->first(['piggy_banks.*'])
;
->leftJoin('account_piggy_bank','account_piggy_bank.piggy_bank_id', '=', 'piggy_banks.id')
->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')
->where('accounts.user_id', auth()->user()->id)->first(['piggy_banks.*']);
if (null !== $piggyBank) {
return $piggyBank;
}