mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Firefly is now capable of adding a transaction. Untested [skip-ci]
This commit is contained in:
@@ -16,7 +16,8 @@ class EloquentAccountRepository implements AccountRepositoryInterface
|
||||
return \Auth::user()->accounts()->with('accounttype')->get();
|
||||
}
|
||||
|
||||
public function getBeneficiaries() {
|
||||
public function getBeneficiaries()
|
||||
{
|
||||
$list = \Auth::user()->accounts()->leftJoin(
|
||||
'account_types', 'account_types.id', '=', 'accounts.account_type_id'
|
||||
)
|
||||
@@ -126,4 +127,28 @@ class EloquentAccountRepository implements AccountRepositoryInterface
|
||||
return $account;
|
||||
}
|
||||
|
||||
public function createOrFindBeneficiary($name)
|
||||
{
|
||||
$type = \AccountType::where('description', 'Beneficiary account')->first();
|
||||
return $this->createOrFind($name, $type);
|
||||
}
|
||||
|
||||
public function createOrFind($name, \AccountType $type)
|
||||
{
|
||||
$beneficiary = $this->findByName($name);
|
||||
if (!$beneficiary) {
|
||||
$data = [
|
||||
'name' => $name,
|
||||
'account_type' => $type
|
||||
];
|
||||
return $this->store($data);
|
||||
}
|
||||
return $beneficiary;
|
||||
}
|
||||
|
||||
public function findByName($name)
|
||||
{
|
||||
return \Auth::user()->accounts()->where('name', 'like', '%' . $name . '%')->first();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user