mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-15 16:57:09 +00:00
Fix linking piggy banks to transactions.
This commit is contained in:
@@ -80,19 +80,30 @@ class BelongsUser implements ValidationRule
|
||||
|
||||
private function validatePiggyBankId(int $value): bool
|
||||
{
|
||||
$count = PiggyBank::leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')
|
||||
|
||||
|
||||
|
||||
|
||||
$count = PiggyBank
|
||||
::leftJoin('account_piggy_bank','account_piggy_bank.piggy_bank_id','=','piggy_banks.id')
|
||||
->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')
|
||||
->where('piggy_banks.id', '=', $value)
|
||||
->where('accounts.user_id', '=', auth()->user()->id)->count()
|
||||
;
|
||||
|
||||
return 1 === $count;
|
||||
return $count > 0;
|
||||
}
|
||||
|
||||
private function validatePiggyBankName(string $value): bool
|
||||
{
|
||||
$count = $this->countField(PiggyBank::class, 'name', $value);
|
||||
$count = PiggyBank
|
||||
::leftJoin('account_piggy_bank','account_piggy_bank.piggy_bank_id','=','piggy_banks.id')
|
||||
->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id')
|
||||
->where('piggy_banks.name', '=', $value)
|
||||
->where('accounts.user_id', '=', auth()->user()->id)->count()
|
||||
;
|
||||
|
||||
return 1 === $count;
|
||||
return $count>0;
|
||||
}
|
||||
|
||||
protected function countField(string $class, string $field, string $value): int
|
||||
|
Reference in New Issue
Block a user