mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-20 00:20:03 +00:00
Update find methods to return null
This commit is contained in:
@@ -44,12 +44,13 @@ use Validator;
|
||||
*/
|
||||
class AccountRepository implements AccountRepositoryInterface
|
||||
{
|
||||
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
use FindAccountsTrait;
|
||||
/** @var array */
|
||||
private $validAssetFields = ['accountRole', 'accountNumber', 'currency_id', 'BIC'];
|
||||
|
||||
use FindAccountsTrait;
|
||||
/** @var array */
|
||||
private $validCCFields = ['accountRole', 'ccMonthlyPaymentDate', 'ccType', 'accountNumber', 'currency_id', 'BIC'];
|
||||
/** @var array */
|
||||
@@ -91,6 +92,16 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $accountId
|
||||
*
|
||||
* @return Account|null
|
||||
*/
|
||||
public function findNull(int $accountId): ?Account
|
||||
{
|
||||
return $this->user->accounts()->find($accountId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return account type by string.
|
||||
*
|
||||
@@ -336,7 +347,7 @@ class AccountRepository implements AccountRepositoryInterface
|
||||
|
||||
// account may exist already:
|
||||
$existingAccount = $this->findByName($data['name'], [$type]);
|
||||
if (null !== $existingAccount->id) {
|
||||
if (null !== $existingAccount) {
|
||||
Log::warning(sprintf('There already is an account named "%s" of type "%s".', $data['name'], $type));
|
||||
|
||||
return $existingAccount;
|
||||
|
||||
Reference in New Issue
Block a user