mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-28 09:51:21 -06:00
Fixed the bug that would unintentionally not let you edit accounts without changing their name. Closed #83
This commit is contained in:
parent
0258982e60
commit
e70444f19a
@ -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
|
||||
|
@ -23,6 +23,7 @@ return [
|
||||
"unique_for_user" => "There already is an entry with this :attribute.",
|
||||
"before" => "The :attribute must be a date before :date.",
|
||||
'unique_object_for_user' => 'This name is already in use',
|
||||
'unique_account_for_user' => 'This account name is already in use',
|
||||
"between" => [
|
||||
"numeric" => "The :attribute must be between :min and :max.",
|
||||
"file" => "The :attribute must be between :min and :max kilobytes.",
|
||||
|
@ -23,6 +23,7 @@ return [
|
||||
"unique_for_user" => "There already is an entry with this :attribute.",
|
||||
"before" => "The :attribute must be a date before :date.",
|
||||
'unique_object_for_user' => 'Deze naam is al in gebruik',
|
||||
'unique_account_for_user' => 'This rekeningnaam is already in use',
|
||||
"between" => [
|
||||
"numeric" => "The :attribute must be between :min and :max.",
|
||||
"file" => "The :attribute must be between :min and :max kilobytes.",
|
||||
|
Loading…
Reference in New Issue
Block a user