diff --git a/app/Api/V1/Controllers/Data/Bulk/AccountController.php b/app/Api/V1/Controllers/Data/Bulk/AccountController.php index c38b8ddf7e..704a6b62aa 100644 --- a/app/Api/V1/Controllers/Data/Bulk/AccountController.php +++ b/app/Api/V1/Controllers/Data/Bulk/AccountController.php @@ -38,8 +38,8 @@ class AccountController extends Controller public function moveTransactions(MoveTransactionsRequest $request): JsonResponse { $accountIds = $request->getAll(); - $original = $this->repository->findNull($accountIds['original_account']); - $destination = $this->repository->findNull($accountIds['destination_account']); + $original = $this->repository->find($accountIds['original_account']); + $destination = $this->repository->find($accountIds['destination_account']); /** @var AccountDestroyService $service */ $service = app(AccountDestroyService::class); diff --git a/app/Api/V1/Controllers/Insight/Income/AccountController.php b/app/Api/V1/Controllers/Insight/Income/AccountController.php index bd195662e2..3a3a72ee87 100644 --- a/app/Api/V1/Controllers/Insight/Income/AccountController.php +++ b/app/Api/V1/Controllers/Insight/Income/AccountController.php @@ -38,7 +38,7 @@ use Illuminate\Http\JsonResponse; * * Shows income information grouped or limited by date. * Ie. all income grouped by account + currency. -* See reference nr. 75 + * See reference nr. 75 */ class AccountController extends Controller { @@ -74,8 +74,9 @@ class AccountController extends Controller } /** -* See reference nr. 76 -* See reference nr. 77 + * See reference nr. 76 + * See reference nr. 77 + * * @param GenericRequest $request * * @return JsonResponse @@ -103,7 +104,7 @@ class AccountController extends Controller } /** -* See reference nr. 78 + * See reference nr. 78 * * @param GenericRequest $request * diff --git a/app/Api/V1/Controllers/Models/TransactionLink/StoreController.php b/app/Api/V1/Controllers/Models/TransactionLink/StoreController.php index 79c23e9868..83305edd53 100644 --- a/app/Api/V1/Controllers/Models/TransactionLink/StoreController.php +++ b/app/Api/V1/Controllers/Models/TransactionLink/StoreController.php @@ -78,8 +78,8 @@ class StoreController extends Controller { $manager = $this->getManager(); $data = $request->getAll(); - $inward = $this->journalRepository->findNull($data['inward_id'] ?? 0); - $outward = $this->journalRepository->findNull($data['outward_id'] ?? 0); + $inward = $this->journalRepository->find($data['inward_id'] ?? 0); + $outward = $this->journalRepository->find($data['outward_id'] ?? 0); if (null === $inward || null === $outward) { throw new FireflyException('200024: Source or destination does not exist.'); } diff --git a/app/Api/V1/Controllers/Summary/BasicController.php b/app/Api/V1/Controllers/Summary/BasicController.php index ab75914003..86d72982e1 100644 --- a/app/Api/V1/Controllers/Summary/BasicController.php +++ b/app/Api/V1/Controllers/Summary/BasicController.php @@ -175,7 +175,7 @@ class BasicController extends Controller // format amounts: $keys = array_keys($sums); foreach ($keys as $currencyId) { - $currency = $this->currencyRepos->findNull($currencyId); + $currency = $this->currencyRepos->find($currencyId); if (null === $currency) { continue; } @@ -239,7 +239,7 @@ class BasicController extends Controller $return = []; foreach ($paidAmount as $currencyId => $amount) { $amount = bcmul($amount, '-1'); - $currency = $this->currencyRepos->findNull((int)$currencyId); + $currency = $this->currencyRepos->find((int)$currencyId); if (null === $currency) { continue; } @@ -259,7 +259,7 @@ class BasicController extends Controller foreach ($unpaidAmount as $currencyId => $amount) { $amount = bcmul($amount, '-1'); - $currency = $this->currencyRepos->findNull((int)$currencyId); + $currency = $this->currencyRepos->find((int)$currencyId); if (null === $currency) { continue; } diff --git a/app/Api/V1/Requests/Data/Bulk/MoveTransactionsRequest.php b/app/Api/V1/Requests/Data/Bulk/MoveTransactionsRequest.php index 37ae4d55b2..3e17e64644 100644 --- a/app/Api/V1/Requests/Data/Bulk/MoveTransactionsRequest.php +++ b/app/Api/V1/Requests/Data/Bulk/MoveTransactionsRequest.php @@ -55,8 +55,8 @@ class MoveTransactionsRequest extends FormRequest if (array_key_exists('original_account', $data) && array_key_exists('destination_account', $data)) { $repository = app(AccountRepositoryInterface::class); $repository->setUser(auth()->user()); - $original = $repository->findNull((int)$data['original_account']); - $destination = $repository->findNull((int)$data['destination_account']); + $original = $repository->find((int)$data['original_account']); + $destination = $repository->find((int)$data['destination_account']); if ($original->accountType->type !== $destination->accountType->type) { $validator->errors()->add('title', (string)trans('validation.same_account_type')); diff --git a/app/Api/V1/Requests/Data/Export/ExportRequest.php b/app/Api/V1/Requests/Data/Export/ExportRequest.php index a5c96c8f5d..c46f6fa60e 100644 --- a/app/Api/V1/Requests/Data/Export/ExportRequest.php +++ b/app/Api/V1/Requests/Data/Export/ExportRequest.php @@ -53,7 +53,7 @@ class ExportRequest extends FormRequest foreach ($parts as $part) { $accountId = (int)$part; if (0 !== $accountId) { - $account = $repository->findNull($accountId); + $account = $repository->find($accountId); if (null !== $account && AccountType::ASSET === $account->accountType->type) { $accounts->push($account); } diff --git a/app/Api/V1/Requests/Insight/GenericRequest.php b/app/Api/V1/Requests/Insight/GenericRequest.php index 54f71b05a4..26f8135e53 100644 --- a/app/Api/V1/Requests/Insight/GenericRequest.php +++ b/app/Api/V1/Requests/Insight/GenericRequest.php @@ -95,7 +95,7 @@ class GenericRequest extends FormRequest if (is_array($array)) { foreach ($array as $accountId) { $accountId = (int)$accountId; - $account = $repository->findNull($accountId); + $account = $repository->find($accountId); if (null !== $account) { $this->accounts->push($account); } @@ -159,7 +159,7 @@ class GenericRequest extends FormRequest if (is_array($array)) { foreach ($array as $budgetId) { $budgetId = (int)$budgetId; - $budget = $repository->findNull($budgetId); + $budget = $repository->find($budgetId); if (null !== $budgetId) { $this->budgets->push($budget); } @@ -191,7 +191,7 @@ class GenericRequest extends FormRequest if (is_array($array)) { foreach ($array as $categoryId) { $categoryId = (int)$categoryId; - $category = $repository->findNull($categoryId); + $category = $repository->find($categoryId); if (null !== $categoryId) { $this->categories->push($category); } @@ -281,7 +281,7 @@ class GenericRequest extends FormRequest if (is_array($array)) { foreach ($array as $tagId) { $tagId = (int)$tagId; - $tag = $repository->findNull($tagId); + $tag = $repository->find($tagId); if (null !== $tagId) { $this->tags->push($tag); } diff --git a/app/Api/V1/Requests/Models/TransactionLink/StoreRequest.php b/app/Api/V1/Requests/Models/TransactionLink/StoreRequest.php index eaf55ed30f..c22b71723b 100644 --- a/app/Api/V1/Requests/Models/TransactionLink/StoreRequest.php +++ b/app/Api/V1/Requests/Models/TransactionLink/StoreRequest.php @@ -104,8 +104,8 @@ class StoreRequest extends FormRequest $data = $validator->getData(); $inwardId = (int)($data['inward_id'] ?? 0); $outwardId = (int)($data['outward_id'] ?? 0); - $inward = $journalRepos->findNull($inwardId); - $outward = $journalRepos->findNull($outwardId); + $inward = $journalRepos->find($inwardId); + $outward = $journalRepos->find($outwardId); if (null === $inward) { $validator->errors()->add('inward_id', 'Invalid inward ID.'); diff --git a/app/Api/V1/Requests/Models/TransactionLink/UpdateRequest.php b/app/Api/V1/Requests/Models/TransactionLink/UpdateRequest.php index 51937db61a..a22c207bff 100644 --- a/app/Api/V1/Requests/Models/TransactionLink/UpdateRequest.php +++ b/app/Api/V1/Requests/Models/TransactionLink/UpdateRequest.php @@ -104,8 +104,8 @@ class UpdateRequest extends FormRequest $inwardId = $data['inward_id'] ?? $existing->source_id; $outwardId = $data['outward_id'] ?? $existing->destination_id; - $inward = $journalRepos->findNull((int)$inwardId); - $outward = $journalRepos->findNull((int)$outwardId); + $inward = $journalRepos->find((int)$inwardId); + $outward = $journalRepos->find((int)$outwardId); if (null === $inward) { $inward = $existing->source; } diff --git a/app/Console/Commands/Correction/FixFrontpageAccounts.php b/app/Console/Commands/Correction/FixFrontpageAccounts.php index 8c4c9a9bed..a1f5e7e2d2 100644 --- a/app/Console/Commands/Correction/FixFrontpageAccounts.php +++ b/app/Console/Commands/Correction/FixFrontpageAccounts.php @@ -89,7 +89,7 @@ class FixFrontpageAccounts extends Command /** @var string $accountId */ foreach ($data as $accountId) { $accountIdInt = (int)$accountId; - $account = $repository->findNull($accountIdInt); + $account = $repository->find($accountIdInt); if (null !== $account && in_array($account->accountType->type, [AccountType::ASSET, AccountType::DEBT, AccountType::LOAN, AccountType::MORTGAGE], true) && true === $account->active) { diff --git a/app/Console/Commands/Tools/ApplyRules.php b/app/Console/Commands/Tools/ApplyRules.php index 4a990ae8ee..fa46d79b46 100644 --- a/app/Console/Commands/Tools/ApplyRules.php +++ b/app/Console/Commands/Tools/ApplyRules.php @@ -213,7 +213,7 @@ class ApplyRules extends Command $accountRepository->setUser($this->getUser()); foreach ($accountList as $accountId) { $accountId = (int)$accountId; - $account = $accountRepository->findNull($accountId); + $account = $accountRepository->find($accountId); if (null !== $account && in_array($account->accountType->type, $this->acceptedAccounts, true)) { $finalList->push($account); } diff --git a/app/Console/Commands/VerifiesAccessToken.php b/app/Console/Commands/VerifiesAccessToken.php index 631ccd137e..ecca77971d 100644 --- a/app/Console/Commands/VerifiesAccessToken.php +++ b/app/Console/Commands/VerifiesAccessToken.php @@ -46,7 +46,7 @@ trait VerifiesAccessToken $userId = (int)$this->option('user'); /** @var UserRepositoryInterface $repository */ $repository = app(UserRepositoryInterface::class); - $user = $repository->findNull($userId); + $user = $repository->find($userId); if (null === $user) { throw new FireflyException('User is unexpectedly NULL'); } @@ -75,7 +75,7 @@ trait VerifiesAccessToken $token = (string)$this->option('token'); /** @var UserRepositoryInterface $repository */ $repository = app(UserRepositoryInterface::class); - $user = $repository->findNull($userId); + $user = $repository->find($userId); if (null === $user) { Log::error(sprintf('verifyAccessToken(): no such user for input "%d"', $userId)); diff --git a/app/Handlers/Events/APIEventHandler.php b/app/Handlers/Events/APIEventHandler.php index f797d5345f..50085a46ea 100644 --- a/app/Handlers/Events/APIEventHandler.php +++ b/app/Handlers/Events/APIEventHandler.php @@ -49,7 +49,7 @@ class APIEventHandler { /** @var UserRepositoryInterface $repository */ $repository = app(UserRepositoryInterface::class); - $user = $repository->findNull((int)$event->userId); + $user = $repository->find((int)$event->userId); if (null !== $user) { $email = $user->email; diff --git a/app/Handlers/Events/AutomationHandler.php b/app/Handlers/Events/AutomationHandler.php index 76619f55bf..5c6361c096 100644 --- a/app/Handlers/Events/AutomationHandler.php +++ b/app/Handlers/Events/AutomationHandler.php @@ -55,7 +55,7 @@ class AutomationHandler Log::debug('In reportJournals.'); /** @var UserRepositoryInterface $repository */ $repository = app(UserRepositoryInterface::class); - $user = $repository->findNull($event->userId); + $user = $repository->find($event->userId); if (null !== $user && 0 !== $event->groups->count()) { $email = $user->email; diff --git a/app/Helpers/Report/NetWorth.php b/app/Helpers/Report/NetWorth.php index 45986cf22b..10f62cfc15 100644 --- a/app/Helpers/Report/NetWorth.php +++ b/app/Helpers/Report/NetWorth.php @@ -119,7 +119,7 @@ class NetWorth implements NetWorthInterface // loop results and add currency information: foreach ($netWorth as $currencyId => $balance) { $result[] = [ - 'currency' => $this->currencyRepos->findNull($currencyId), + 'currency' => $this->currencyRepos->find($currencyId), 'balance' => $balance, ]; } diff --git a/app/Http/Controllers/Account/DeleteController.php b/app/Http/Controllers/Account/DeleteController.php index 7e49118d40..4c6a1102ae 100644 --- a/app/Http/Controllers/Account/DeleteController.php +++ b/app/Http/Controllers/Account/DeleteController.php @@ -104,7 +104,7 @@ class DeleteController extends Controller $type = $account->accountType->type; $typeName = config(sprintf('firefly.shortNamesByFullName.%s', $type)); $name = $account->name; - $moveTo = $this->repository->findNull((int)$request->get('move_account_before_delete')); + $moveTo = $this->repository->find((int)$request->get('move_account_before_delete')); $this->repository->destroy($account, $moveTo); diff --git a/app/Http/Controllers/Admin/LinkController.php b/app/Http/Controllers/Admin/LinkController.php index a1f65f8a10..fac92e9185 100644 --- a/app/Http/Controllers/Admin/LinkController.php +++ b/app/Http/Controllers/Admin/LinkController.php @@ -130,7 +130,7 @@ class LinkController extends Controller { Log::channel('audit')->info(sprintf('User destroyed link type #%d', $linkType->id)); $name = $linkType->name; - $moveTo = $this->repository->findNull((int)$request->get('move_link_type_before_delete')); + $moveTo = $this->repository->find((int)$request->get('move_link_type_before_delete')); $this->repository->destroy($linkType, $moveTo); $request->session()->flash('success', (string)trans('firefly.deleted_link_type', ['name' => $name])); diff --git a/app/Http/Controllers/Budget/BudgetLimitController.php b/app/Http/Controllers/Budget/BudgetLimitController.php index 99fb420ce9..11ead1a464 100644 --- a/app/Http/Controllers/Budget/BudgetLimitController.php +++ b/app/Http/Controllers/Budget/BudgetLimitController.php @@ -131,7 +131,7 @@ class BudgetLimitController extends Controller Log::debug('Going to store new budget-limit.', $request->all()); // first search for existing one and update it if necessary. $currency = $this->currencyRepos->find((int)$request->get('transaction_currency_id')); - $budget = $this->repository->findNull((int)$request->get('budget_id')); + $budget = $this->repository->find((int)$request->get('budget_id')); if (null === $currency || null === $budget) { throw new FireflyException('No valid currency or budget.'); } diff --git a/app/Http/Controllers/Budget/IndexController.php b/app/Http/Controllers/Budget/IndexController.php index 101994c3ab..f478cb9e3f 100644 --- a/app/Http/Controllers/Budget/IndexController.php +++ b/app/Http/Controllers/Budget/IndexController.php @@ -306,7 +306,7 @@ class IndexController extends Controller foreach ($budgetIds as $index => $budgetId) { $budgetId = (int)$budgetId; - $budget = $repository->findNull($budgetId); + $budget = $repository->find($budgetId); if (null !== $budget) { Log::debug(sprintf('Set budget #%d ("%s") to position %d', $budget->id, $budget->name, $index + 1)); $repository->setBudgetOrder($budget, $index + 1); diff --git a/app/Http/Controllers/Chart/AccountController.php b/app/Http/Controllers/Chart/AccountController.php index e09b67bb43..cc0b950288 100644 --- a/app/Http/Controllers/Chart/AccountController.php +++ b/app/Http/Controllers/Chart/AccountController.php @@ -123,7 +123,7 @@ class AccountController extends Controller // grab the difference and find the currency. $startAmount = $startBalances[$accountId][$currencyId] ?? '0'; $diff = bcsub($endAmount, $startAmount); - $currencies[$currencyId] = $currencies[$currencyId] ?? $this->currencyRepository->findNull($currencyId); + $currencies[$currencyId] = $currencies[$currencyId] ?? $this->currencyRepository->find($currencyId); if (0 !== bccomp($diff, '0')) { // store the values in a temporary array. $tempData[] = [ @@ -568,7 +568,7 @@ class AccountController extends Controller // grab the difference and find the currency. $startAmount = $startBalances[$accountId][$currencyId] ?? '0'; $diff = bcsub($endAmount, $startAmount); - $currencies[$currencyId] = $currencies[$currencyId] ?? $this->currencyRepository->findNull($currencyId); + $currencies[$currencyId] = $currencies[$currencyId] ?? $this->currencyRepository->find($currencyId); if (0 !== bccomp($diff, '0')) { // store the values in a temporary array. $tempData[] = [ diff --git a/app/Http/Controllers/Chart/BillController.php b/app/Http/Controllers/Chart/BillController.php index f92c40f28a..9b28269dc3 100644 --- a/app/Http/Controllers/Chart/BillController.php +++ b/app/Http/Controllers/Chart/BillController.php @@ -78,13 +78,13 @@ class BillController extends Controller $unpaid = $repository->getBillsUnpaidInRangePerCurrency($start, $end); // will be a positive amount. foreach ($paid as $currencyId => $amount) { - $currencies[$currencyId] = $currencies[$currencyId] ?? $currencyRepository->findNull($currencyId); + $currencies[$currencyId] = $currencies[$currencyId] ?? $currencyRepository->find($currencyId); $label = (string)trans('firefly.paid_in_currency', ['currency' => $currencies[$currencyId]->name]); $chartData[$label] = ['amount' => $amount, 'currency_symbol' => $currencies[$currencyId]->symbol, 'currency_code' => $currencies[$currencyId]->code]; } foreach ($unpaid as $currencyId => $amount) { - $currencies[$currencyId] = $currencies[$currencyId] ?? $currencyRepository->findNull($currencyId); + $currencies[$currencyId] = $currencies[$currencyId] ?? $currencyRepository->find($currencyId); $label = (string)trans('firefly.unpaid_in_currency', ['currency' => $currencies[$currencyId]->name]); $chartData[$label] = ['amount' => $amount, 'currency_symbol' => $currencies[$currencyId]->symbol, 'currency_code' => $currencies[$currencyId]->code]; diff --git a/app/Http/Controllers/JavascriptController.php b/app/Http/Controllers/JavascriptController.php index eaef5d9ea3..33b15b8fcf 100644 --- a/app/Http/Controllers/JavascriptController.php +++ b/app/Http/Controllers/JavascriptController.php @@ -131,7 +131,7 @@ class JavascriptController extends Controller */ public function variables(Request $request, AccountRepositoryInterface $repository, CurrencyRepositoryInterface $currencyRepository): Response { - $account = $repository->findNull((int) $request->get('account')); + $account = $repository->find((int) $request->get('account')); $currency = app('amount')->getDefaultCurrency(); if(null !== $account) { $currency = $repository->getAccountCurrency($account) ?? $currency; diff --git a/app/Http/Controllers/Json/BoxController.php b/app/Http/Controllers/Json/BoxController.php index 46d8ffc918..03c6c9b020 100644 --- a/app/Http/Controllers/Json/BoxController.php +++ b/app/Http/Controllers/Json/BoxController.php @@ -184,7 +184,7 @@ class BoxController extends Controller // format amounts: $keys = array_keys($sums); foreach ($keys as $currencyId) { - $currency = $repository->findNull($currencyId); + $currency = $repository->find($currencyId); $sums[$currencyId] = app('amount')->formatAnything($currency, $sums[$currencyId], false); $incomes[$currencyId] = app('amount')->formatAnything($currency, $incomes[$currencyId] ?? '0', false); $expenses[$currencyId] = app('amount')->formatAnything($currency, $expenses[$currencyId] ?? '0', false); diff --git a/app/Http/Controllers/NewUserController.php b/app/Http/Controllers/NewUserController.php index 9bda7c5d82..9b6d005cce 100644 --- a/app/Http/Controllers/NewUserController.php +++ b/app/Http/Controllers/NewUserController.php @@ -98,7 +98,7 @@ class NewUserController extends Controller // set language preference: app('preferences')->set('language', $language); // Store currency preference from input: - $currency = $currencyRepository->findNull((int) $request->input('amount_currency_id_bank_balance')); + $currency = $currencyRepository->find((int) $request->input('amount_currency_id_bank_balance')); // if is null, set to EUR: if (null === $currency) { diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.php index 04271ef4a4..61c21aba75 100644 --- a/app/Http/Controllers/TagController.php +++ b/app/Http/Controllers/TagController.php @@ -208,7 +208,7 @@ class TagController extends Controller $count = 0; foreach ($tags as $tagId) { $tagId = (int)$tagId; - $tag = $this->repository->findNull($tagId); + $tag = $this->repository->find($tagId); if (null !== $tag) { $this->repository->destroy($tag); $count++; diff --git a/app/Http/Controllers/Transaction/BulkController.php b/app/Http/Controllers/Transaction/BulkController.php index 91aea8def1..550f9f2d6d 100644 --- a/app/Http/Controllers/Transaction/BulkController.php +++ b/app/Http/Controllers/Transaction/BulkController.php @@ -104,7 +104,7 @@ class BulkController extends Controller foreach ($journalIds as $journalId) { $journalId = (int)$journalId; - $journal = $this->repository->findNull($journalId); + $journal = $this->repository->find($journalId); if (null !== $journal) { $resultA = $this->updateJournalBudget($journal, $ignoreBudget, $request->integer('budget_id')); $resultB = $this->updateJournalTags($journal, $tagsAction, explode(',', $request->string('tags'))); diff --git a/app/Http/Controllers/Transaction/LinkController.php b/app/Http/Controllers/Transaction/LinkController.php index b174811293..c2438fdd6b 100644 --- a/app/Http/Controllers/Transaction/LinkController.php +++ b/app/Http/Controllers/Transaction/LinkController.php @@ -123,7 +123,7 @@ class LinkController extends Controller $linkInfo = $request->getLinkInfo(); Log::debug('We are here (store)'); - $other = $this->journalRepository->findNull($linkInfo['transaction_journal_id']); + $other = $this->journalRepository->find($linkInfo['transaction_journal_id']); if (null === $other) { session()->flash('error', (string)trans('firefly.invalid_link_selection')); diff --git a/app/Http/Controllers/Transaction/MassController.php b/app/Http/Controllers/Transaction/MassController.php index 409dee94db..f17684bcd4 100644 --- a/app/Http/Controllers/Transaction/MassController.php +++ b/app/Http/Controllers/Transaction/MassController.php @@ -103,7 +103,7 @@ class MassController extends Controller foreach ($ids as $journalId) { /** @var TransactionJournal $journal */ - $journal = $this->repository->findNull((int)$journalId); + $journal = $this->repository->find((int)$journalId); if (null !== $journal && (int)$journalId === $journal->id) { $this->repository->destroyJournal($journal); ++$count; @@ -197,7 +197,7 @@ class MassController extends Controller */ private function updateJournal(int $journalId, MassEditJournalRequest $request): void { - $journal = $this->repository->findNull($journalId); + $journal = $this->repository->find($journalId); if (null === $journal) { throw new FireflyException(sprintf('Trying to edit non-existent or deleted journal #%d', $journalId)); } diff --git a/app/Http/Requests/ReportFormRequest.php b/app/Http/Requests/ReportFormRequest.php index 212fa59ad7..a9f908f5f6 100644 --- a/app/Http/Requests/ReportFormRequest.php +++ b/app/Http/Requests/ReportFormRequest.php @@ -55,7 +55,7 @@ class ReportFormRequest extends FormRequest $collection = new Collection; if (is_array($set)) { foreach ($set as $accountId) { - $account = $repository->findNull((int)$accountId); + $account = $repository->find((int)$accountId); if (null !== $account) { $collection->push($account); } @@ -78,7 +78,7 @@ class ReportFormRequest extends FormRequest $collection = new Collection; if (is_array($set)) { foreach ($set as $budgetId) { - $budget = $repository->findNull((int)$budgetId); + $budget = $repository->find((int)$budgetId); if (null !== $budget) { $collection->push($budget); } @@ -101,7 +101,7 @@ class ReportFormRequest extends FormRequest $collection = new Collection; if (is_array($set)) { foreach ($set as $categoryId) { - $category = $repository->findNull((int)$categoryId); + $category = $repository->find((int)$categoryId); if (null !== $category) { $collection->push($category); } @@ -124,7 +124,7 @@ class ReportFormRequest extends FormRequest $collection = new Collection; if (is_array($set)) { foreach ($set as $accountId) { - $account = $repository->findNull((int)$accountId); + $account = $repository->find((int)$accountId); if (null !== $account) { $collection->push($account); } @@ -209,7 +209,7 @@ class ReportFormRequest extends FormRequest $collection->push($tag); continue; } - $tag = $repository->findNull((int)$tagTag); + $tag = $repository->find((int)$tagTag); if (null !== $tag) { $collection->push($tag); } diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index bfc4708fbc..9db77aeb27 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -161,7 +161,7 @@ class EventServiceProvider extends ServiceProvider static function (Client $oauthClient) { /** @var UserRepositoryInterface $repository */ $repository = app(UserRepositoryInterface::class); - $user = $repository->findNull((int)$oauthClient->user_id); + $user = $repository->find((int)$oauthClient->user_id); if (null === $user) { Log::info('OAuth client generated but no user associated.'); diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php index d1e7648663..ff753aeba2 100644 --- a/app/Repositories/Account/AccountRepository.php +++ b/app/Repositories/Account/AccountRepository.php @@ -130,17 +130,7 @@ class AccountRepository implements AccountRepositoryInterface $query->whereIn('account_types.type', $types); } -// See reference nr. 9 - - $accounts = $query->get(['accounts.*']); - /** @var Account $account */ - foreach ($accounts as $account) { - if ($account->iban === $iban) { - return $account; - } - } - - return null; + return $query->where('iban', $iban)->first(['accounts.*']); } /** @@ -161,7 +151,7 @@ class AccountRepository implements AccountRepositoryInterface $accounts = $query->get(['accounts.*']); -// See reference nr. 10 + // See reference nr. 10 /** @var Account $account */ foreach ($accounts as $account) { @@ -181,7 +171,7 @@ class AccountRepository implements AccountRepositoryInterface * * @return Account|null */ - public function findNull(int $accountId): ?Account + public function find(int $accountId): ?Account { return $this->user->accounts()->find($accountId); } diff --git a/app/Repositories/Account/AccountRepositoryInterface.php b/app/Repositories/Account/AccountRepositoryInterface.php index 5e1ba522ab..2985643d99 100644 --- a/app/Repositories/Account/AccountRepositoryInterface.php +++ b/app/Repositories/Account/AccountRepositoryInterface.php @@ -95,7 +95,7 @@ interface AccountRepositoryInterface * * @return Account|null */ - public function findNull(int $accountId): ?Account; + public function find(int $accountId): ?Account; /** * @param Account $account diff --git a/app/Repositories/Account/AccountTasker.php b/app/Repositories/Account/AccountTasker.php index 18f45aa92f..c0702b41f1 100644 --- a/app/Repositories/Account/AccountTasker.php +++ b/app/Repositories/Account/AccountTasker.php @@ -207,7 +207,7 @@ class AccountTasker implements AccountTaskerInterface $sourceId = (int)$journal['destination_account_id']; $currencyId = (int)$journal['currency_id']; $key = sprintf('%s-%s', $sourceId, $currencyId); - $currencies[$currencyId] = $currencies[$currencyId] ?? $currencyRepos->findNull($currencyId); + $currencies[$currencyId] = $currencies[$currencyId] ?? $currencyRepos->find($currencyId); $report['accounts'][$key] = $report['accounts'][$key] ?? [ 'id' => $sourceId, 'name' => $journal['destination_account_name'], @@ -269,7 +269,7 @@ class AccountTasker implements AccountTaskerInterface $currencyId = (int)$journal['currency_id']; $key = sprintf('%s-%s', $sourceId, $currencyId); if (!array_key_exists($key, $report['accounts'])) { - $currencies[$currencyId] = $currencies[$currencyId] ?? $currencyRepos->findNull($currencyId); + $currencies[$currencyId] = $currencies[$currencyId] ?? $currencyRepos->find($currencyId); $report['accounts'][$key] = [ 'id' => $sourceId, 'name' => $journal['source_account_name'], diff --git a/app/Repositories/Bill/BillRepository.php b/app/Repositories/Bill/BillRepository.php index e6a03855c5..725a241203 100644 --- a/app/Repositories/Bill/BillRepository.php +++ b/app/Repositories/Bill/BillRepository.php @@ -146,18 +146,7 @@ class BillRepository implements BillRepositoryInterface */ public function findByName(string $name): ?Bill { - $bills = $this->user->bills()->get(['bills.*']); - -// See reference nr. 6 - - /** @var Bill $bill */ - foreach ($bills as $bill) { - if ($bill->name === $name) { - return $bill; - } - } - - return null; + return $this->user->bills()->where('name', $name)->first(['bills.*']); } /** @@ -505,6 +494,7 @@ class BillRepository implements BillRepositoryInterface $currentStart = clone $nextExpectedMatch; } + return $set; } @@ -641,7 +631,7 @@ class BillRepository implements BillRepositoryInterface $cache->addProperty('nextDateMatch'); $cache->addProperty($date); if ($cache->has()) { - return $cache->get(); + return $cache->get(); } // find the most recent date for this bill NOT in the future. Cache this date: $start = clone $bill->date; @@ -669,7 +659,7 @@ class BillRepository implements BillRepositoryInterface $cache->addProperty('nextExpectedMatch'); $cache->addProperty($date); if ($cache->has()) { - return $cache->get(); + return $cache->get(); } // find the most recent date for this bill NOT in the future. Cache this date: $start = clone $bill->date; diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.php index 3bb179cef0..5354c9ab41 100644 --- a/app/Repositories/Budget/BudgetRepository.php +++ b/app/Repositories/Budget/BudgetRepository.php @@ -127,7 +127,7 @@ class BudgetRepository implements BudgetRepositoryInterface { Log::debug('Now in findBudget()'); Log::debug(sprintf('Searching for budget with ID #%d...', $budgetId)); - $result = $this->findNull((int)$budgetId); + $result = $this->find((int)$budgetId); if (null === $result && null !== $budgetName && '' !== $budgetName) { Log::debug(sprintf('Searching for budget with name %s...', $budgetName)); $result = $this->findByName((string)$budgetName); @@ -164,12 +164,8 @@ class BudgetRepository implements BudgetRepositoryInterface * * @return Budget|null */ - public function findNull(int $budgetId = null): ?Budget + public function find(int $budgetId = null): ?Budget { - if (null === $budgetId) { - return null; - } - return $this->user->budgets()->find($budgetId); } @@ -348,7 +344,7 @@ class BudgetRepository implements BudgetRepositoryInterface $repos = app(CurrencyRepositoryInterface::class); $currency = null; if (array_key_exists('currency_id', $data)) { - $currency = $repos->findNull((int)$data['currency_id']); + $currency = $repos->find((int)$data['currency_id']); } if (array_key_exists('currency_code', $data)) { $currency = $repos->findByCode((string)$data['currency_code']); @@ -454,7 +450,7 @@ class BudgetRepository implements BudgetRepositoryInterface $repos = app(CurrencyRepositoryInterface::class); $currencyId = (int)($data['currency_id'] ?? 0); $currencyCode = (string)($data['currency_code'] ?? ''); - $currency = $repos->findNull($currencyId); + $currency = $repos->find($currencyId); if (null === $currency) { $currency = $repos->findByCodeNull($currencyCode); } diff --git a/app/Repositories/Budget/BudgetRepositoryInterface.php b/app/Repositories/Budget/BudgetRepositoryInterface.php index f5eadde2eb..576cac2c7d 100644 --- a/app/Repositories/Budget/BudgetRepositoryInterface.php +++ b/app/Repositories/Budget/BudgetRepositoryInterface.php @@ -74,13 +74,12 @@ interface BudgetRepositoryInterface public function findByName(?string $name): ?Budget; /** -* See reference nr. 12 * * @param int|null $budgetId * * @return Budget|null */ - public function findNull(int $budgetId = null): ?Budget; + public function find(int $budgetId = null): ?Budget; /** * This method returns the oldest journal or transaction date known to this budget. diff --git a/app/Repositories/Category/CategoryRepository.php b/app/Repositories/Category/CategoryRepository.php index 115624078e..e90246c5c6 100644 --- a/app/Repositories/Category/CategoryRepository.php +++ b/app/Repositories/Category/CategoryRepository.php @@ -87,17 +87,7 @@ class CategoryRepository implements CategoryRepositoryInterface */ public function findByName(string $name): ?Category { - $categories = $this->user->categories()->get(['categories.*']); - -// See reference nr. 7 - - foreach ($categories as $category) { - if ($category->name === $name) { - return $category; - } - } - - return null; + return $this->user->categories()->where('name', $name)->first(['categories.*']); } /** @@ -111,7 +101,7 @@ class CategoryRepository implements CategoryRepositoryInterface { Log::debug('Now in findCategory()'); Log::debug(sprintf('Searching for category with ID #%d...', $categoryId)); - $result = $this->findNull((int)$categoryId); + $result = $this->find((int)$categoryId); if (null === $result) { Log::debug(sprintf('Searching for category with name %s...', $categoryName)); $result = $this->findByName((string)$categoryName); @@ -135,7 +125,7 @@ class CategoryRepository implements CategoryRepositoryInterface * * @return Category|null */ - public function findNull(int $categoryId): ?Category + public function find(int $categoryId): ?Category { return $this->user->categories()->find($categoryId); } diff --git a/app/Repositories/Category/CategoryRepositoryInterface.php b/app/Repositories/Category/CategoryRepositoryInterface.php index 74e401bbc6..52966d31fd 100644 --- a/app/Repositories/Category/CategoryRepositoryInterface.php +++ b/app/Repositories/Category/CategoryRepositoryInterface.php @@ -70,7 +70,7 @@ interface CategoryRepositoryInterface * * @return Category|null */ - public function findNull(int $categoryId): ?Category; + public function find(int $categoryId): ?Category; /** * @param Category $category diff --git a/app/Repositories/Currency/CurrencyRepository.php b/app/Repositories/Currency/CurrencyRepository.php index 65292a9c65..ea30208170 100644 --- a/app/Repositories/Currency/CurrencyRepository.php +++ b/app/Repositories/Currency/CurrencyRepository.php @@ -38,7 +38,6 @@ use FireflyIII\Repositories\User\UserRepositoryInterface; use FireflyIII\Services\Internal\Destroy\CurrencyDestroyService; use FireflyIII\Services\Internal\Update\CurrencyUpdateService; use FireflyIII\User; -use Illuminate\Database\Eloquent\Builder; use Illuminate\Support\Collection; use Log; @@ -346,20 +345,6 @@ class CurrencyRepository implements CurrencyRepositoryInterface return $result; } - /** - * Find by ID, return NULL if not found. - * Used in Import Currency! - * - * @param int $currencyId - * - * @return TransactionCurrency|null - * @deprecated - */ - public function findNull(int $currencyId): ?TransactionCurrency - { - return TransactionCurrency::find($currencyId); - } - /** * @return Collection */ diff --git a/app/Repositories/Currency/CurrencyRepositoryInterface.php b/app/Repositories/Currency/CurrencyRepositoryInterface.php index edf4c3a207..7c50d812de 100644 --- a/app/Repositories/Currency/CurrencyRepositoryInterface.php +++ b/app/Repositories/Currency/CurrencyRepositoryInterface.php @@ -163,15 +163,6 @@ interface CurrencyRepositoryInterface */ public function findCurrencyNull(?int $currencyId, ?string $currencyCode): ?TransactionCurrency; - /** - * Find by ID, return NULL if not found. - * - * @param int $currencyId - * - * @return TransactionCurrency|null - */ - public function findNull(int $currencyId): ?TransactionCurrency; - /** * @return Collection */ diff --git a/app/Repositories/Journal/JournalRepository.php b/app/Repositories/Journal/JournalRepository.php index bdde8e2583..db2586aba2 100644 --- a/app/Repositories/Journal/JournalRepository.php +++ b/app/Repositories/Journal/JournalRepository.php @@ -87,9 +87,9 @@ class JournalRepository implements JournalRepositoryInterface * * @return TransactionJournal|null */ - public function findNull(int $journalId): ?TransactionJournal + public function find(int $journalId): ?TransactionJournal { - return $this->user->transactionJournals()->where('id', $journalId)->first(); + return $this->user->transactionJournals()->find($journalId); } /** @@ -123,62 +123,6 @@ class JournalRepository implements JournalRepositoryInterface return $transaction->account; } - /** - * Return a list of all destination accounts related to journal. - * - * @param TransactionJournal $journal - * @param bool $useCache - * - * @return Collection - */ - public function getJournalDestinationAccounts(TransactionJournal $journal, bool $useCache = true): Collection - { - $cache = new CacheProperties; - $cache->addProperty($journal->id); - $cache->addProperty('destination-account-list'); - if ($useCache && $cache->has()) { - return $cache->get(); - } - $transactions = $journal->transactions()->where('amount', '>', 0)->orderBy('transactions.account_id')->with('account')->get(); - $list = new Collection; - /** @var Transaction $t */ - foreach ($transactions as $t) { - $list->push($t->account); - } - $list = $list->unique('id'); - $cache->store($list); - - return $list; - } - - /** - * Return a list of all source accounts related to journal. - * - * @param TransactionJournal $journal - * @param bool $useCache - * - * @return Collection - */ - public function getJournalSourceAccounts(TransactionJournal $journal, bool $useCache = true): Collection - { - $cache = new CacheProperties; - $cache->addProperty($journal->id); - $cache->addProperty('source-account-list'); - if ($useCache && $cache->has()) { - return $cache->get(); - } - $transactions = $journal->transactions()->where('amount', '<', 0)->orderBy('transactions.account_id')->with('account')->get(); - $list = new Collection; - /** @var Transaction $t */ - foreach ($transactions as $t) { - $list->push($t->account); - } - $list = $list->unique('id'); - $cache->store($list); - - return $list; - } - /** * Return total amount of journal. Is always positive. * diff --git a/app/Repositories/Journal/JournalRepositoryInterface.php b/app/Repositories/Journal/JournalRepositoryInterface.php index f6a29ef255..ea595eeff0 100644 --- a/app/Repositories/Journal/JournalRepositoryInterface.php +++ b/app/Repositories/Journal/JournalRepositoryInterface.php @@ -58,14 +58,14 @@ interface JournalRepositoryInterface public function findByType(array $types): Collection; /** -* See reference nr. 1 + * See reference nr. 1 * Find a specific journal. * * @param int $journalId * * @return TransactionJournal|null */ - public function findNull(int $journalId): ?TransactionJournal; + public function find(int $journalId): ?TransactionJournal; /** * Get users very first transaction journal. @@ -84,28 +84,6 @@ interface JournalRepositoryInterface */ public function getDestinationAccount(TransactionJournal $journal): Account; - /** -* See reference nr. 2 - * Return a list of all destination accounts related to journal. - * - * @param TransactionJournal $journal - * - * @return Collection - * @deprecated - */ - public function getJournalDestinationAccounts(TransactionJournal $journal): Collection; - - /** -* See reference nr. 3 - * Return a list of all source accounts related to journal. - * - * @param TransactionJournal $journal - * - * @return Collection - * @deprecated - */ - public function getJournalSourceAccounts(TransactionJournal $journal): Collection; - /** * Return total amount of journal. Is always positive. * @@ -121,7 +99,7 @@ interface JournalRepositoryInterface public function getLast(): ?TransactionJournal; /** -* See reference nr. 4 + * See reference nr. 4 * * @param TransactionJournalLink $link * @@ -150,7 +128,7 @@ interface JournalRepositoryInterface public function getSourceAccount(TransactionJournal $journal): Account; /** -* See reference nr. 5 + * See reference nr. 5 * * @param int $journalId */ diff --git a/app/Repositories/LinkType/LinkTypeRepository.php b/app/Repositories/LinkType/LinkTypeRepository.php index da448f6749..f7e260e4be 100644 --- a/app/Repositories/LinkType/LinkTypeRepository.php +++ b/app/Repositories/LinkType/LinkTypeRepository.php @@ -118,7 +118,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface * * @return LinkType|null */ - public function findNull(int $linkTypeId): ?LinkType + public function find(int $linkTypeId): ?LinkType { return LinkType::find($linkTypeId); } @@ -247,7 +247,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface */ public function storeLink(array $information, TransactionJournal $inward, TransactionJournal $outward): ?TransactionJournalLink { - $linkType = $this->findNull((int)($information['link_type_id'] ?? 0)); + $linkType = $this->find((int)($information['link_type_id'] ?? 0)); if (null === $linkType) { $linkType = $this->findByName($information['link_type_name']); diff --git a/app/Repositories/LinkType/LinkTypeRepositoryInterface.php b/app/Repositories/LinkType/LinkTypeRepositoryInterface.php index 1a798b0ac1..f805dcb036 100644 --- a/app/Repositories/LinkType/LinkTypeRepositoryInterface.php +++ b/app/Repositories/LinkType/LinkTypeRepositoryInterface.php @@ -79,7 +79,7 @@ interface LinkTypeRepositoryInterface * * @return LinkType|null */ - public function findNull(int $linkTypeId): ?LinkType; + public function find(int $linkTypeId): ?LinkType; /** * See if such a link already exists (and get it). diff --git a/app/Repositories/PiggyBank/PiggyBankRepository.php b/app/Repositories/PiggyBank/PiggyBankRepository.php index e2bc94f19d..e0100ee705 100644 --- a/app/Repositories/PiggyBank/PiggyBankRepository.php +++ b/app/Repositories/PiggyBank/PiggyBankRepository.php @@ -71,14 +71,9 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface * * @return PiggyBank|null */ - public function findNull(int $piggyBankId): ?PiggyBank + public function find(int $piggyBankId): ?PiggyBank { - $piggyBank = $this->user->piggyBanks()->where('piggy_banks.id', $piggyBankId)->first(['piggy_banks.*']); - if (null !== $piggyBank) { - return $piggyBank; - } - - return null; + $piggyBank = $this->user->piggyBanks()->find($piggyBankId); } /** @@ -92,7 +87,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface Log::debug('Searching for piggy information.'); if (null !== $piggyBankId) { - $searchResult = $this->findNull((int)$piggyBankId); + $searchResult = $this->find((int)$piggyBankId); if (null !== $searchResult) { Log::debug(sprintf('Found piggy based on #%d, will return it.', $piggyBankId)); diff --git a/app/Repositories/PiggyBank/PiggyBankRepositoryInterface.php b/app/Repositories/PiggyBank/PiggyBankRepositoryInterface.php index 9e16a57b6f..423c1cea8e 100644 --- a/app/Repositories/PiggyBank/PiggyBankRepositoryInterface.php +++ b/app/Repositories/PiggyBank/PiggyBankRepositoryInterface.php @@ -115,7 +115,7 @@ interface PiggyBankRepositoryInterface * * @return PiggyBank|null */ - public function findNull(int $piggyBankId): ?PiggyBank; + public function find(int $piggyBankId): ?PiggyBank; /** * @param int|null $piggyBankId diff --git a/app/Repositories/Rule/RuleRepository.php b/app/Repositories/Rule/RuleRepository.php index abc71b4cfe..1990aa9af0 100644 --- a/app/Repositories/Rule/RuleRepository.php +++ b/app/Repositories/Rule/RuleRepository.php @@ -105,12 +105,7 @@ class RuleRepository implements RuleRepositoryInterface */ public function find(int $ruleId): ?Rule { - $rule = $this->user->rules()->find($ruleId); - if (null === $rule) { - return null; - } - - return $rule; + return $this->user->rules()->find($ruleId); } /** diff --git a/app/Repositories/RuleGroup/RuleGroupRepository.php b/app/Repositories/RuleGroup/RuleGroupRepository.php index e0e705f3aa..253f93b685 100644 --- a/app/Repositories/RuleGroup/RuleGroupRepository.php +++ b/app/Repositories/RuleGroup/RuleGroupRepository.php @@ -119,12 +119,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface */ public function find(int $ruleGroupId): ?RuleGroup { - $group = $this->user->ruleGroups()->find($ruleGroupId); - if (null === $group) { - return null; - } - - return $group; + return $this->user->ruleGroups()->find($ruleGroupId); } /** diff --git a/app/Repositories/Tag/TagRepository.php b/app/Repositories/Tag/TagRepository.php index a678fc526f..be1ae9e6fc 100644 --- a/app/Repositories/Tag/TagRepository.php +++ b/app/Repositories/Tag/TagRepository.php @@ -113,7 +113,7 @@ class TagRepository implements TagRepositoryInterface * * @return Tag|null */ - public function findNull(int $tagId): ?Tag + public function find(int $tagId): ?Tag { return $this->user->tags()->find($tagId); } diff --git a/app/Repositories/Tag/TagRepositoryInterface.php b/app/Repositories/Tag/TagRepositoryInterface.php index 888992444a..d4e550623f 100644 --- a/app/Repositories/Tag/TagRepositoryInterface.php +++ b/app/Repositories/Tag/TagRepositoryInterface.php @@ -74,7 +74,7 @@ interface TagRepositoryInterface * * @return Tag|null */ - public function findNull(int $tagId): ?Tag; + public function find(int $tagId): ?Tag; /** * @param Tag $tag diff --git a/app/Repositories/TransactionGroup/TransactionGroupRepository.php b/app/Repositories/TransactionGroup/TransactionGroupRepository.php index 4ea0bf4f30..04b76655ec 100644 --- a/app/Repositories/TransactionGroup/TransactionGroupRepository.php +++ b/app/Repositories/TransactionGroup/TransactionGroupRepository.php @@ -87,7 +87,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface */ public function find(int $groupId): ?TransactionGroup { - return $this->user->transactionGroups()->where('id', $groupId)->first(); + return $this->user->transactionGroups()->find($groupId); } /** diff --git a/app/Repositories/User/UserRepository.php b/app/Repositories/User/UserRepository.php index f488448854..1e22c24e06 100644 --- a/app/Repositories/User/UserRepository.php +++ b/app/Repositories/User/UserRepository.php @@ -183,7 +183,7 @@ class UserRepository implements UserRepositoryInterface * * @return User|null */ - public function findNull(int $userId): ?User + public function find(int $userId): ?User { return User::find($userId); } @@ -269,8 +269,6 @@ class UserRepository implements UserRepositoryInterface */ public function hasRole(User $user, string $role): bool { -// See reference nr. 8 - /** @var Role $userRole */ foreach ($user->roles as $userRole) { if ($userRole->name === $role) { diff --git a/app/Repositories/User/UserRepositoryInterface.php b/app/Repositories/User/UserRepositoryInterface.php index 767afcd24a..5eafdbab9f 100644 --- a/app/Repositories/User/UserRepositoryInterface.php +++ b/app/Repositories/User/UserRepositoryInterface.php @@ -114,7 +114,7 @@ interface UserRepositoryInterface * * @return User|null */ - public function findNull(int $userId): ?User; + public function find(int $userId): ?User; /** * Returns the first user in the DB. Generally only works when there is just one. diff --git a/app/Rules/IsValidAttachmentModel.php b/app/Rules/IsValidAttachmentModel.php index df6174a3a5..cdaaab047c 100644 --- a/app/Rules/IsValidAttachmentModel.php +++ b/app/Rules/IsValidAttachmentModel.php @@ -131,7 +131,7 @@ class IsValidAttachmentModel implements Rule $repository = app(AccountRepositoryInterface::class); $repository->setUser(auth()->user()); - return null !== $repository->findNull($value); + return null !== $repository->find($value); } /** @@ -159,7 +159,7 @@ class IsValidAttachmentModel implements Rule $repository = app(BudgetRepositoryInterface::class); $repository->setUser(auth()->user()); - return null !== $repository->findNull($value); + return null !== $repository->find($value); } /** @@ -173,7 +173,7 @@ class IsValidAttachmentModel implements Rule $repository = app(CategoryRepositoryInterface::class); $repository->setUser(auth()->user()); - return null !== $repository->findNull($value); + return null !== $repository->find($value); } /** @@ -186,7 +186,7 @@ class IsValidAttachmentModel implements Rule $repository = app(JournalRepositoryInterface::class); $repository->setUser(auth()->user()); - return null !== $repository->findNull($value); + return null !== $repository->find($value); } /** @@ -200,7 +200,7 @@ class IsValidAttachmentModel implements Rule $repository = app(PiggyBankRepositoryInterface::class); $repository->setUser(auth()->user()); - return null !== $repository->findNull($value); + return null !== $repository->find($value); } /** @@ -214,7 +214,7 @@ class IsValidAttachmentModel implements Rule $repository = app(TagRepositoryInterface::class); $repository->setUser(auth()->user()); - return null !== $repository->findNull($value); + return null !== $repository->find($value); } /** diff --git a/app/Services/Internal/Support/JournalServiceTrait.php b/app/Services/Internal/Support/JournalServiceTrait.php index 4186cb3028..9af842ec1c 100644 --- a/app/Services/Internal/Support/JournalServiceTrait.php +++ b/app/Services/Internal/Support/JournalServiceTrait.php @@ -96,7 +96,7 @@ trait JournalServiceTrait $search = null; // first attempt, find by ID. if (null !== $data['id']) { - $search = $this->accountRepository->findNull((int) $data['id']); + $search = $this->accountRepository->find((int) $data['id']); if (null !== $search && in_array($search->accountType->type, $types, true)) { Log::debug( sprintf('Found "account_id" object: #%d, "%s" of type %s', $search->id, $search->name, $search->accountType->type) diff --git a/app/Services/Internal/Support/RecurringTransactionTrait.php b/app/Services/Internal/Support/RecurringTransactionTrait.php index 46108986fd..57c4fa56ab 100644 --- a/app/Services/Internal/Support/RecurringTransactionTrait.php +++ b/app/Services/Internal/Support/RecurringTransactionTrait.php @@ -196,7 +196,7 @@ trait RecurringTransactionTrait $repository->setUser($this->user); // if user has submitted an account ID, search for it. - $result = $repository->findNull((int)$accountId); + $result = $repository->find((int)$accountId); if (null !== $result) { return $result; } diff --git a/app/Support/Binder/TagOrId.php b/app/Support/Binder/TagOrId.php index 99deb8aafd..cbf631ce26 100644 --- a/app/Support/Binder/TagOrId.php +++ b/app/Support/Binder/TagOrId.php @@ -48,7 +48,7 @@ class TagOrId implements BinderInterface $result = $repository->findByTag($value); if (null === $result) { - $result = $repository->findNull((int)$value); + $result = $repository->find((int)$value); } if (null !== $result) { return $result; diff --git a/app/Support/Http/Controllers/ChartGeneration.php b/app/Support/Http/Controllers/ChartGeneration.php index fda7339759..d217867765 100644 --- a/app/Support/Http/Controllers/ChartGeneration.php +++ b/app/Support/Http/Controllers/ChartGeneration.php @@ -74,7 +74,7 @@ trait ChartGeneration /** @var Account $account */ foreach ($accounts as $account) { // See reference nr. 33 - $currency = $repository->findNull((int)$accountRepos->getMetaValue($account, 'currency_id')); + $currency = $repository->find((int)$accountRepos->getMetaValue($account, 'currency_id')); if (null === $currency) { $currency = $default; } diff --git a/app/Support/Http/Controllers/RenderPartialViews.php b/app/Support/Http/Controllers/RenderPartialViews.php index 8aa97bdb95..d0829339d9 100644 --- a/app/Support/Http/Controllers/RenderPartialViews.php +++ b/app/Support/Http/Controllers/RenderPartialViews.php @@ -59,10 +59,10 @@ trait RenderPartialViews /** @var BudgetRepositoryInterface $budgetRepository */ $budgetRepository = app(BudgetRepositoryInterface::class); - $budget = $budgetRepository->findNull((int)$attributes['budgetId']); + $budget = $budgetRepository->find((int)$attributes['budgetId']); $accountRepos = app(AccountRepositoryInterface::class); - $account = $accountRepos->findNull((int)$attributes['accountId']); + $account = $accountRepos->find((int)$attributes['accountId']); $journals = $popupHelper->balanceForBudget($budget, $account, $attributes); @@ -110,7 +110,7 @@ trait RenderPartialViews /** @var PopupReportInterface $popupHelper */ $popupHelper = app(PopupReportInterface::class); - $budget = $budgetRepository->findNull((int)$attributes['budgetId']); + $budget = $budgetRepository->find((int)$attributes['budgetId']); if (null === $budget) { $budget = new Budget; } @@ -139,7 +139,7 @@ trait RenderPartialViews /** @var CategoryRepositoryInterface $categoryRepository */ $categoryRepository = app(CategoryRepositoryInterface::class); - $category = $categoryRepository->findNull((int)$attributes['categoryId']); + $category = $categoryRepository->find((int)$attributes['categoryId']); $journals = $popupHelper->byCategory($category, $attributes); try { @@ -227,7 +227,7 @@ trait RenderPartialViews /** @var PopupReportInterface $popupHelper */ $popupHelper = app(PopupReportInterface::class); - $account = $accountRepository->findNull((int)$attributes['accountId']); + $account = $accountRepository->find((int)$attributes['accountId']); if (null === $account) { return 'This is an unknown account. Apologies.'; @@ -348,7 +348,7 @@ trait RenderPartialViews /** @var PopupReportInterface $popupHelper */ $popupHelper = app(PopupReportInterface::class); - $account = $accountRepository->findNull((int)$attributes['accountId']); + $account = $accountRepository->find((int)$attributes['accountId']); if (null === $account) { return 'This is an unknown category. Apologies.'; diff --git a/app/Support/Search/OperatorQuerySearch.php b/app/Support/Search/OperatorQuerySearch.php index dc81594895..15562732be 100644 --- a/app/Support/Search/OperatorQuerySearch.php +++ b/app/Support/Search/OperatorQuerySearch.php @@ -334,7 +334,7 @@ class OperatorQuerySearch implements SearchInterface $this->searchAccount($value, 1, 3); break; case 'source_account_id': - $account = $this->accountRepository->findNull((int)$value); + $account = $this->accountRepository->find((int)$value); if (null !== $account) { $this->collector->setSourceAccounts(new Collection([$account])); } @@ -372,7 +372,7 @@ class OperatorQuerySearch implements SearchInterface $this->searchAccount($value, 2, 3); break; case 'destination_account_id': - $account = $this->accountRepository->findNull((int)$value); + $account = $this->accountRepository->find((int)$value); if (null !== $account) { $this->collector->setDestinationAccounts(new Collection([$account])); } @@ -381,7 +381,7 @@ class OperatorQuerySearch implements SearchInterface $parts = explode(',', $value); $collection = new Collection; foreach ($parts as $accountId) { - $account = $this->accountRepository->findNull((int)$accountId); + $account = $this->accountRepository->find((int)$accountId); if (null !== $account) { $collection->push($account); } diff --git a/app/TransactionRules/Engine/SearchRuleEngine.php b/app/TransactionRules/Engine/SearchRuleEngine.php index 9c1e061f1f..45febf39a1 100644 --- a/app/TransactionRules/Engine/SearchRuleEngine.php +++ b/app/TransactionRules/Engine/SearchRuleEngine.php @@ -326,7 +326,7 @@ class SearchRuleEngine implements RuleEngineInterface if (0 !== $journalId) { $repository = app(JournalRepositoryInterface::class); $repository->setUser($this->user); - $journal = $repository->findNull($journalId); + $journal = $repository->find($journalId); if (null !== $journal) { $date = $journal->date; Log::debug(sprintf('Found journal #%d with date %s.', $journal->id, $journal->date->format('Y-m-d'))); diff --git a/app/Transformers/RecurrenceTransformer.php b/app/Transformers/RecurrenceTransformer.php index 945d97c011..949d39fa67 100644 --- a/app/Transformers/RecurrenceTransformer.php +++ b/app/Transformers/RecurrenceTransformer.php @@ -263,7 +263,7 @@ class RecurrenceTransformer extends AbstractTransformer $array['tags'] = json_decode($transactionMeta->value); break; case 'piggy_bank_id': - $piggy = $this->piggyRepos->findNull((int)$transactionMeta->value); + $piggy = $this->piggyRepos->find((int)$transactionMeta->value); if (null !== $piggy) { $array['piggy_bank_id'] = (string)$piggy->id; $array['piggy_bank_name'] = $piggy->name; @@ -284,7 +284,7 @@ class RecurrenceTransformer extends AbstractTransformer } break; case 'budget_id': - $budget = $this->budgetRepos->findNull((int)$transactionMeta->value); + $budget = $this->budgetRepos->find((int)$transactionMeta->value); if (null !== $budget) { $array['budget_id'] = (string)$budget->id; $array['budget_name'] = $budget->name; diff --git a/app/Validation/Account/DepositValidation.php b/app/Validation/Account/DepositValidation.php index 9f3c57e3aa..ecc3d6156e 100644 --- a/app/Validation/Account/DepositValidation.php +++ b/app/Validation/Account/DepositValidation.php @@ -117,7 +117,7 @@ trait DepositValidation // if the user submits an ID only but that ID is not of the correct type, // return false. if (null !== $accountId && null === $accountName) { - $search = $this->accountRepository->findNull($accountId); + $search = $this->accountRepository->find($accountId); if (null !== $search && !in_array($search->accountType->type, $validTypes, true)) { Log::debug(sprintf('User submitted only an ID (#%d), which is a "%s", so this is not a valid source.', $accountId, $search->accountType->type)); $result = false; diff --git a/app/Validation/Account/LiabilityValidation.php b/app/Validation/Account/LiabilityValidation.php index a3ced5c197..0a7df89e64 100644 --- a/app/Validation/Account/LiabilityValidation.php +++ b/app/Validation/Account/LiabilityValidation.php @@ -75,7 +75,7 @@ trait LiabilityValidation } Log::debug('Destination ID is not null.'); - $search = $this->accountRepository->findNull($accountId); + $search = $this->accountRepository->find($accountId); // the source resulted in an account, but it's not of a valid type. if (null !== $search && !in_array($search->accountType->type, $validTypes, true)) { diff --git a/app/Validation/Account/OBValidation.php b/app/Validation/Account/OBValidation.php index c2bcf617da..3f61b4d5a4 100644 --- a/app/Validation/Account/OBValidation.php +++ b/app/Validation/Account/OBValidation.php @@ -115,7 +115,7 @@ trait OBValidation // return false. if (null !== $accountId && null === $accountName) { Log::debug('Source ID is not null, but name is null.'); - $search = $this->accountRepository->findNull($accountId); + $search = $this->accountRepository->find($accountId); // the source resulted in an account, but it's not of a valid type. if (null !== $search && !in_array($search->accountType->type, $validTypes, true)) { diff --git a/app/Validation/Account/ReconciliationValidation.php b/app/Validation/Account/ReconciliationValidation.php index 450c9977ed..d8e97de566 100644 --- a/app/Validation/Account/ReconciliationValidation.php +++ b/app/Validation/Account/ReconciliationValidation.php @@ -46,7 +46,7 @@ trait ReconciliationValidation return false; } - $result = $this->accountRepository->findNull($accountId); + $result = $this->accountRepository->find($accountId); if (null === $result) { $this->destError = (string)trans('validation.deposit_dest_bad_data', ['id' => $accountId, 'name' => '']); Log::debug('Return FALSE'); @@ -92,7 +92,7 @@ trait ReconciliationValidation return false; } - $result = $this->accountRepository->findNull($accountId); + $result = $this->accountRepository->find($accountId); $types = [AccountType::ASSET, AccountType::LOAN, AccountType::DEBT, AccountType::MORTGAGE, AccountType::RECONCILIATION]; if (null === $result) { Log::debug('Return FALSE'); diff --git a/app/Validation/Account/WithdrawalValidation.php b/app/Validation/Account/WithdrawalValidation.php index 1dc5d4293b..f3b5efa66f 100644 --- a/app/Validation/Account/WithdrawalValidation.php +++ b/app/Validation/Account/WithdrawalValidation.php @@ -87,7 +87,7 @@ trait WithdrawalValidation // if there's an ID it must be of the "validTypes". if (null !== $accountId && 0 !== $accountId) { - $found = $this->accountRepository->findNull($accountId); + $found = $this->accountRepository->find($accountId); if (null !== $found) { $type = $found->accountType->type; if (in_array($type, $validTypes, true)) { diff --git a/app/Validation/AccountValidator.php b/app/Validation/AccountValidator.php index cf3ffe03de..7856a3e512 100644 --- a/app/Validation/AccountValidator.php +++ b/app/Validation/AccountValidator.php @@ -228,7 +228,7 @@ class AccountValidator { // find by ID if ($accountId > 0) { - $first = $this->accountRepository->findNull($accountId); + $first = $this->accountRepository->find($accountId); if ((null !== $first) && in_array($first->accountType->type, $validTypes, true)) { return $first; }