mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-27 17:31:09 -06:00
Sneaky bug. [skip ci]
This commit is contained in:
parent
52663de13d
commit
2d0820873a
@ -34,10 +34,11 @@ class EloquentAccountRepository implements AccountRepositoryInterface
|
|||||||
*
|
*
|
||||||
* @return \Account|mixed
|
* @return \Account|mixed
|
||||||
*/
|
*/
|
||||||
public function createOrFind($name, \AccountType $type)
|
public function createOrFind($name, \AccountType $type = null)
|
||||||
{
|
{
|
||||||
$beneficiary = $this->findByName($name);
|
|
||||||
if (!$beneficiary) {
|
$account = $this->findByName($name, $type);
|
||||||
|
if (!$account) {
|
||||||
$data = [
|
$data = [
|
||||||
'name' => $name,
|
'name' => $name,
|
||||||
'account_type' => $type
|
'account_type' => $type
|
||||||
@ -46,7 +47,7 @@ class EloquentAccountRepository implements AccountRepositoryInterface
|
|||||||
return $this->store($data);
|
return $this->store($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $beneficiary;
|
return $account;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -92,9 +93,10 @@ class EloquentAccountRepository implements AccountRepositoryInterface
|
|||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function findByName($name)
|
public function findByName($name, \AccountType $type = null)
|
||||||
{
|
{
|
||||||
return \Auth::user()->accounts()->where('name', 'like', '%' . $name . '%')->first();
|
$type = is_null($type) ? \AccountType::where('description', 'Default account')->first() : $type;
|
||||||
|
return \Auth::user()->accounts()->where('account_type_id',$type->id)->where('name', 'like', '%' . $name . '%')->first();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user