mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Fixed the bug that would unintentionally not let you edit accounts without changing their name. Closed #83
This commit is contained in:
@@ -75,6 +75,10 @@ class FireflyValidator extends Validator
|
||||
if (isset($this->data['account_type_id'])) {
|
||||
return $this->validateByAccountTypeId($value, $parameters);
|
||||
}
|
||||
if(isset($this->data['id'])) {
|
||||
return $this->validateByAccountId($value, $parameters);
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -167,6 +171,33 @@ class FireflyValidator extends Validator
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $value
|
||||
* @param $parameters
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateByAccountId($value, $parameters)
|
||||
{
|
||||
/** @var Account $existingAccount */
|
||||
$existingAccount = Account::find($this->data['id']);
|
||||
|
||||
$type = $existingAccount->accountType;
|
||||
$ignore = $existingAccount->id;
|
||||
$value = $this->tryDecrypt($value);
|
||||
|
||||
$set = Auth::user()->accounts()->where('account_type_id', $type->id)->where('id', '!=', $ignore)->get();
|
||||
/** @var Account $entry */
|
||||
foreach ($set as $entry) {
|
||||
if ($entry->name == $value) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $attribute
|
||||
* @param $value
|
||||
|
Reference in New Issue
Block a user