From cb0b42e44bdb8163996c1e44dcbf8235ceaeab52 Mon Sep 17 00:00:00 2001 From: James Cole Date: Wed, 10 Sep 2025 16:07:19 +0200 Subject: [PATCH] Replace method calls. --- .../Controllers/Chart/BalanceController.php | 2 -- .../V1/Controllers/Chart/BudgetController.php | 6 ++--- app/Api/V1/Controllers/Controller.php | 2 -- .../Insight/Expense/BudgetController.php | 2 +- .../Insight/Expense/CategoryController.php | 2 +- .../Insight/Income/CategoryController.php | 2 +- .../Insight/Transfer/CategoryController.php | 2 +- .../Models/Account/ListController.php | 2 +- .../Models/Rule/TriggerController.php | 4 ++-- .../System/ConfigurationController.php | 1 - .../V1/Controllers/Webhook/ShowController.php | 4 ++-- .../StoreByCurrenciesRequest.php | 4 ++-- .../StoreByDateRequest.php | 2 +- app/Factory/TransactionJournalFactory.php | 4 ++-- .../Report/Audit/MonthReportGenerator.php | 2 +- .../Events/DestroyedGroupEventHandler.php | 2 +- .../Events/StoredGroupEventHandler.php | 2 +- .../Events/UpdatedGroupEventHandler.php | 2 +- .../Collector/Extensions/MetaCollection.php | 2 +- app/Helpers/Report/PopupReport.php | 8 +++---- .../Controllers/Account/ShowController.php | 4 ++-- .../Budget/BudgetLimitController.php | 4 ++-- .../Controllers/Budget/IndexController.php | 2 +- .../Controllers/Chart/AccountController.php | 6 ++--- .../Controllers/Chart/BudgetController.php | 6 ++--- .../Chart/BudgetReportController.php | 2 +- .../Controllers/Chart/CategoryController.php | 2 +- .../Chart/CategoryReportController.php | 4 ++-- .../Chart/DoubleReportController.php | 2 +- .../Controllers/Chart/TagReportController.php | 4 ++-- app/Http/Controllers/HomeController.php | 2 +- .../Controllers/Json/ReconcileController.php | 2 +- .../Recurring/TriggerController.php | 2 +- .../Controllers/Rule/SelectController.php | 4 ++-- .../RuleGroup/ExecutionController.php | 2 +- app/Jobs/CreateAutoBudgetLimits.php | 4 ++-- .../Chart/Budget/FrontpageChartGenerator.php | 4 ++-- .../Category/WholePeriodChartGenerator.php | 2 +- app/Support/Http/Controllers/AugumentData.php | 2 +- .../JsonApi/Enrichments/AccountEnrichment.php | 2 +- .../JsonApi/Enrichments/BudgetEnrichment.php | 4 ++-- .../Enrichments/CategoryEnrichment.php | 2 +- .../Enrichments/PiggyBankEnrichment.php | 2 +- .../Enrichments/PiggyBankEventEnrichment.php | 2 +- .../Enrichments/RecurringEnrichment.php | 2 +- .../Enrichments/SubscriptionEnrichment.php | 2 +- .../TransactionGroupEnrichment.php | 2 +- .../JsonApi/Enrichments/WebhookEnrichment.php | 2 +- .../Report/Budget/BudgetReportGenerator.php | 2 +- .../Recurring/FiltersWeekends.php | 17 +++++++------- app/Support/Search/OperatorQuerySearch.php | 22 +++++++++---------- 51 files changed, 87 insertions(+), 91 deletions(-) diff --git a/app/Api/V1/Controllers/Chart/BalanceController.php b/app/Api/V1/Controllers/Chart/BalanceController.php index 1895a5e35b..cd3d967dc6 100644 --- a/app/Api/V1/Controllers/Chart/BalanceController.php +++ b/app/Api/V1/Controllers/Chart/BalanceController.php @@ -31,9 +31,7 @@ use FireflyIII\Enums\TransactionTypeEnum; use FireflyIII\Enums\UserRoleEnum; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Helpers\Collector\GroupCollectorInterface; -use FireflyIII\Models\TransactionCurrency; use FireflyIII\Repositories\Account\AccountRepositoryInterface; -use FireflyIII\Support\Facades\Amount; use FireflyIII\Support\Http\Api\AccountBalanceGrouped; use FireflyIII\Support\Http\Api\CleansChartData; use FireflyIII\Support\Http\Api\CollectsAccountsFromFilter; diff --git a/app/Api/V1/Controllers/Chart/BudgetController.php b/app/Api/V1/Controllers/Chart/BudgetController.php index dde99549dc..726f4c78bd 100644 --- a/app/Api/V1/Controllers/Chart/BudgetController.php +++ b/app/Api/V1/Controllers/Chart/BudgetController.php @@ -114,7 +114,7 @@ class BudgetController extends Controller // get all limits: $limits = $this->blRepository->getBudgetLimits($budget, $start, $end); $rows = []; - $spent = $this->opsRepository->listExpenses($start, $end, null, new Collection([$budget])); + $spent = $this->opsRepository->listExpenses($start, $end, null, new Collection()->push($budget)); $expenses = $this->processExpenses($budget->id, $spent, $start, $end); $converter = new ExchangeRateConverter(); $currencies = [$this->primaryCurrency->id => $this->primaryCurrency]; @@ -208,7 +208,7 @@ class BudgetController extends Controller // */ // private function noBudgetLimits(Budget $budget, Carbon $start, Carbon $end): array // { - // $spent = $this->opsRepository->listExpenses($start, $end, null, new Collection([$budget])); + // $spent = $this->opsRepository->listExpenses($start, $end, null, new Collection()->push($budget)); // // return $this->processExpenses($budget->id, $spent, $start, $end); // } @@ -290,7 +290,7 @@ class BudgetController extends Controller // Log::debug(sprintf('Created new ExchangeRateConverter in %s', __METHOD__)); // $end = clone $limit->end_date; // $end->endOfDay(); - // $spent = $this->opsRepository->listExpenses($limit->start_date, $end, null, new Collection([$budget])); + // $spent = $this->opsRepository->listExpenses($limit->start_date, $end, null, new Collection()->push($budget)); // $limitCurrencyId = $limit->transaction_currency_id; // // /** @var array $entry */ diff --git a/app/Api/V1/Controllers/Controller.php b/app/Api/V1/Controllers/Controller.php index 0b68debfcd..298bc20cc7 100644 --- a/app/Api/V1/Controllers/Controller.php +++ b/app/Api/V1/Controllers/Controller.php @@ -232,8 +232,6 @@ abstract class Controller extends BaseController $baseUrl = sprintf('%s/api/v1', request()->getSchemeAndHttpHost()); $manager->setSerializer(new JsonApiSerializer($baseUrl)); - // $transformer->collectMetaData(new Collection([$object])); - $resource = new Item($object, $transformer, $key); return $manager->createData($resource)->toArray(); diff --git a/app/Api/V1/Controllers/Insight/Expense/BudgetController.php b/app/Api/V1/Controllers/Insight/Expense/BudgetController.php index ed91b96a16..84686fb367 100644 --- a/app/Api/V1/Controllers/Insight/Expense/BudgetController.php +++ b/app/Api/V1/Controllers/Insight/Expense/BudgetController.php @@ -76,7 +76,7 @@ class BudgetController extends Controller /** @var Budget $budget */ foreach ($budgets as $budget) { - $expenses = $this->opsRepository->sumExpenses($start, $end, $assetAccounts, new Collection([$budget])); + $expenses = $this->opsRepository->sumExpenses($start, $end, $assetAccounts, new Collection()->push($budget)); /** @var array $expense */ foreach ($expenses as $expense) { diff --git a/app/Api/V1/Controllers/Insight/Expense/CategoryController.php b/app/Api/V1/Controllers/Insight/Expense/CategoryController.php index d5d092b461..c470cef7ae 100644 --- a/app/Api/V1/Controllers/Insight/Expense/CategoryController.php +++ b/app/Api/V1/Controllers/Insight/Expense/CategoryController.php @@ -76,7 +76,7 @@ class CategoryController extends Controller /** @var Category $category */ foreach ($categories as $category) { - $expenses = $this->opsRepository->sumExpenses($start, $end, $assetAccounts, new Collection([$category])); + $expenses = $this->opsRepository->sumExpenses($start, $end, $assetAccounts, new Collection()->push($category)); /** @var array $expense */ foreach ($expenses as $expense) { diff --git a/app/Api/V1/Controllers/Insight/Income/CategoryController.php b/app/Api/V1/Controllers/Insight/Income/CategoryController.php index 1547090337..e2fb1d527d 100644 --- a/app/Api/V1/Controllers/Insight/Income/CategoryController.php +++ b/app/Api/V1/Controllers/Insight/Income/CategoryController.php @@ -76,7 +76,7 @@ class CategoryController extends Controller /** @var Category $category */ foreach ($categories as $category) { - $expenses = $this->opsRepository->sumIncome($start, $end, $assetAccounts, new Collection([$category])); + $expenses = $this->opsRepository->sumIncome($start, $end, $assetAccounts, new Collection()->push($category)); /** @var array $expense */ foreach ($expenses as $expense) { diff --git a/app/Api/V1/Controllers/Insight/Transfer/CategoryController.php b/app/Api/V1/Controllers/Insight/Transfer/CategoryController.php index 63cabef200..4df25a96f8 100644 --- a/app/Api/V1/Controllers/Insight/Transfer/CategoryController.php +++ b/app/Api/V1/Controllers/Insight/Transfer/CategoryController.php @@ -76,7 +76,7 @@ class CategoryController extends Controller /** @var Category $category */ foreach ($categories as $category) { - $expenses = $this->opsRepository->sumTransfers($start, $end, $assetAccounts, new Collection([$category])); + $expenses = $this->opsRepository->sumTransfers($start, $end, $assetAccounts, new Collection()->push($category)); /** @var array $expense */ foreach ($expenses as $expense) { diff --git a/app/Api/V1/Controllers/Models/Account/ListController.php b/app/Api/V1/Controllers/Models/Account/ListController.php index 15f8ac7c04..eacc1824f1 100644 --- a/app/Api/V1/Controllers/Models/Account/ListController.php +++ b/app/Api/V1/Controllers/Models/Account/ListController.php @@ -152,7 +152,7 @@ class ListController extends Controller // use new group collector: /** @var GroupCollectorInterface $collector */ $collector = app(GroupCollectorInterface::class); - $collector->setUser($admin)->setAccounts(new Collection([$account])) + $collector->setUser($admin)->setAccounts(new Collection()->push($account)) ->withAPIInformation()->setLimit($pageSize)->setPage($this->parameters->get('page'))->setTypes($types) ; diff --git a/app/Api/V1/Controllers/Models/Rule/TriggerController.php b/app/Api/V1/Controllers/Models/Rule/TriggerController.php index 42465d3c85..2fab36ba92 100644 --- a/app/Api/V1/Controllers/Models/Rule/TriggerController.php +++ b/app/Api/V1/Controllers/Models/Rule/TriggerController.php @@ -75,7 +75,7 @@ class TriggerController extends Controller /** @var RuleEngineInterface $ruleEngine */ $ruleEngine = app(RuleEngineInterface::class); - $ruleEngine->setRules(new Collection([$rule])); + $ruleEngine->setRules(new Collection()->push($rule)); // overrule the rule(s) if necessary. if (array_key_exists('start', $parameters) && null !== $parameters['start']) { @@ -129,7 +129,7 @@ class TriggerController extends Controller /** @var RuleEngineInterface $ruleEngine */ $ruleEngine = app(RuleEngineInterface::class); - $ruleEngine->setRules(new Collection([$rule])); + $ruleEngine->setRules(new Collection()->push($rule)); // overrule the rule(s) if necessary. if (array_key_exists('start', $parameters) && null !== $parameters['start']) { diff --git a/app/Api/V1/Controllers/System/ConfigurationController.php b/app/Api/V1/Controllers/System/ConfigurationController.php index 80d4a063c5..5902b8a343 100644 --- a/app/Api/V1/Controllers/System/ConfigurationController.php +++ b/app/Api/V1/Controllers/System/ConfigurationController.php @@ -133,7 +133,6 @@ class ConfigurationController extends Controller */ public function show(string $configKey): JsonResponse { - $data = []; $dynamic = $this->getDynamicConfiguration(); $shortKey = str_replace('configuration.', '', $configKey); if (str_starts_with($configKey, 'configuration.')) { diff --git a/app/Api/V1/Controllers/Webhook/ShowController.php b/app/Api/V1/Controllers/Webhook/ShowController.php index 2d835dad82..c0a27d5fce 100644 --- a/app/Api/V1/Controllers/Webhook/ShowController.php +++ b/app/Api/V1/Controllers/Webhook/ShowController.php @@ -165,9 +165,9 @@ class ShowController extends Controller // tell the generator which trigger it should look for $engine->setTrigger(WebhookTrigger::tryFrom($webhook->trigger)); // tell the generator which objects to process - $engine->setObjects(new Collection([$group])); + $engine->setObjects(new Collection()->push($group)); // set the webhook to trigger - $engine->setWebhooks(new Collection([$webhook])); + $engine->setWebhooks(new Collection()->push($webhook)); // tell the generator to generate the messages $engine->generateMessages(); diff --git a/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreByCurrenciesRequest.php b/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreByCurrenciesRequest.php index 2d90d680f8..be2bfe8584 100644 --- a/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreByCurrenciesRequest.php +++ b/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreByCurrenciesRequest.php @@ -58,8 +58,8 @@ class StoreByCurrenciesRequest extends FormRequest $data = $validator->getData(); foreach ($data as $date => $rate) { try { - $date = Carbon::createFromFormat('Y-m-d', $date); - } catch (InvalidFormatException $e) { + Carbon::createFromFormat('Y-m-d', $date); + } catch (InvalidFormatException) { $validator->errors()->add('date', trans('validation.date', ['attribute' => 'date'])); return; diff --git a/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreByDateRequest.php b/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreByDateRequest.php index 971237b737..aa1eb2a5b7 100644 --- a/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreByDateRequest.php +++ b/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreByDateRequest.php @@ -88,7 +88,7 @@ class StoreByDateRequest extends FormRequest } try { - $to = Amount::getTransactionCurrencyByCode((string)$key); + Amount::getTransactionCurrencyByCode((string)$key); } catch (FireflyException) { $validator->errors()->add(sprintf('rates.%s', $key), trans('validation.invalid_currency_code', ['code' => $key])); } diff --git a/app/Factory/TransactionJournalFactory.php b/app/Factory/TransactionJournalFactory.php index 070f71fa26..7206947be2 100644 --- a/app/Factory/TransactionJournalFactory.php +++ b/app/Factory/TransactionJournalFactory.php @@ -270,7 +270,7 @@ class TransactionJournalFactory $negative = $transactionFactory->createNegative((string) $row['amount'], (string) $row['foreign_amount']); } catch (FireflyException $e) { Log::error(sprintf('Exception creating negative transaction: %s', $e->getMessage())); - $this->forceDeleteOnError(new Collection([$journal])); + $this->forceDeleteOnError(new Collection()->push($journal)); throw new FireflyException($e->getMessage(), 0, $e); } @@ -305,7 +305,7 @@ class TransactionJournalFactory } catch (FireflyException $e) { Log::error(sprintf('Exception creating positive transaction: %s', $e->getMessage())); $this->forceTrDelete($negative); - $this->forceDeleteOnError(new Collection([$journal])); + $this->forceDeleteOnError(new Collection()->push($journal)); throw new FireflyException($e->getMessage(), 0, $e); } diff --git a/app/Generator/Report/Audit/MonthReportGenerator.php b/app/Generator/Report/Audit/MonthReportGenerator.php index bc02d217a8..a0aea0c9df 100644 --- a/app/Generator/Report/Audit/MonthReportGenerator.php +++ b/app/Generator/Report/Audit/MonthReportGenerator.php @@ -132,7 +132,7 @@ class MonthReportGenerator implements ReportGeneratorInterface /** @var GroupCollectorInterface $collector */ $collector = app(GroupCollectorInterface::class); - $collector->setAccounts(new Collection([$account]))->setRange($this->start, $this->end)->withAccountInformation() + $collector->setAccounts(new Collection()->push($account))->setRange($this->start, $this->end)->withAccountInformation() ->withBudgetInformation()->withCategoryInformation()->withBillInformation()->withNotes() ; $journals = $collector->getExtractedJournals(); diff --git a/app/Handlers/Events/DestroyedGroupEventHandler.php b/app/Handlers/Events/DestroyedGroupEventHandler.php index 9f5926c96c..638cbc8e76 100644 --- a/app/Handlers/Events/DestroyedGroupEventHandler.php +++ b/app/Handlers/Events/DestroyedGroupEventHandler.php @@ -52,7 +52,7 @@ class DestroyedGroupEventHandler /** @var MessageGeneratorInterface $engine */ $engine = app(MessageGeneratorInterface::class); $engine->setUser($user); - $engine->setObjects(new Collection([$group])); + $engine->setObjects(new Collection()->push($group)); $engine->setTrigger(WebhookTrigger::DESTROY_TRANSACTION); $engine->generateMessages(); Log::debug(sprintf('send event RequestedSendWebhookMessages from %s', __METHOD__)); diff --git a/app/Handlers/Events/StoredGroupEventHandler.php b/app/Handlers/Events/StoredGroupEventHandler.php index 0b471c01ac..367c4b4d09 100644 --- a/app/Handlers/Events/StoredGroupEventHandler.php +++ b/app/Handlers/Events/StoredGroupEventHandler.php @@ -116,7 +116,7 @@ class StoredGroupEventHandler // tell the generator which trigger it should look for $engine->setTrigger(WebhookTrigger::STORE_TRANSACTION); // tell the generator which objects to process - $engine->setObjects(new Collection([$group])); + $engine->setObjects(new Collection()->push($group)); // tell the generator to generate the messages $engine->generateMessages(); diff --git a/app/Handlers/Events/UpdatedGroupEventHandler.php b/app/Handlers/Events/UpdatedGroupEventHandler.php index 71c04589db..973442abb3 100644 --- a/app/Handlers/Events/UpdatedGroupEventHandler.php +++ b/app/Handlers/Events/UpdatedGroupEventHandler.php @@ -163,7 +163,7 @@ class UpdatedGroupEventHandler /** @var MessageGeneratorInterface $engine */ $engine = app(MessageGeneratorInterface::class); $engine->setUser($user); - $engine->setObjects(new Collection([$group])); + $engine->setObjects(new Collection()->push($group)); $engine->setTrigger(WebhookTrigger::UPDATE_TRANSACTION); $engine->generateMessages(); diff --git a/app/Helpers/Collector/Extensions/MetaCollection.php b/app/Helpers/Collector/Extensions/MetaCollection.php index 7f97ab3afd..42a025e8b7 100644 --- a/app/Helpers/Collector/Extensions/MetaCollection.php +++ b/app/Helpers/Collector/Extensions/MetaCollection.php @@ -762,7 +762,7 @@ trait MetaCollection public function setTag(Tag $tag): GroupCollectorInterface { $this->withTagInformation(); - $this->setTags(new Collection([$tag])); + $this->setTags(new Collection()->push($tag)); return $this; } diff --git a/app/Helpers/Report/PopupReport.php b/app/Helpers/Report/PopupReport.php index aa21319780..414cd57d78 100644 --- a/app/Helpers/Report/PopupReport.php +++ b/app/Helpers/Report/PopupReport.php @@ -45,7 +45,7 @@ class PopupReport implements PopupReportInterface { /** @var GroupCollectorInterface $collector */ $collector = app(GroupCollectorInterface::class); - $collector->setAccounts(new Collection([$account])) + $collector->setAccounts(new Collection()->push($account)) ->withAccountInformation() ->withBudgetInformation() ->withCategoryInformation() @@ -72,7 +72,7 @@ class PopupReport implements PopupReportInterface /** @var GroupCollectorInterface $collector */ $collector = app(GroupCollectorInterface::class); $collector - ->setAccounts(new Collection([$account])) + ->setAccounts(new Collection()->push($account)) ->setTypes([TransactionTypeEnum::WITHDRAWAL->value]) ->withAccountInformation() ->withCategoryInformation() @@ -191,7 +191,7 @@ class PopupReport implements PopupReportInterface // $set = $attributes['accounts'] ?? new Collection; // $set->push($account); - $collector->setDestinationAccounts(new Collection([$account])) + $collector->setDestinationAccounts(new Collection()->push($account)) ->setRange($attributes['startDate'], $attributes['endDate']) ->withAccountInformation() ->withBudgetInformation() @@ -218,7 +218,7 @@ class PopupReport implements PopupReportInterface /** @var GroupCollectorInterface $collector */ $collector = app(GroupCollectorInterface::class); $collector - ->setSourceAccounts(new Collection([$account])) + ->setSourceAccounts(new Collection()->push($account)) ->setDestinationAccounts($attributes['accounts']) ->setRange($attributes['startDate'], $attributes['endDate']) ->setTypes([TransactionTypeEnum::DEPOSIT->value, TransactionTypeEnum::TRANSFER->value]) diff --git a/app/Http/Controllers/Account/ShowController.php b/app/Http/Controllers/Account/ShowController.php index a8b4ed4551..4b77635b4b 100644 --- a/app/Http/Controllers/Account/ShowController.php +++ b/app/Http/Controllers/Account/ShowController.php @@ -143,7 +143,7 @@ class ShowController extends Controller /** @var GroupCollectorInterface $collector */ $collector = app(GroupCollectorInterface::class); $collector - ->setAccounts(new Collection([$account])) + ->setAccounts(new Collection()->push($account)) ->setLimit($pageSize) ->setPage($page) ->withAttachmentInformation() @@ -221,7 +221,7 @@ class ShowController extends Controller /** @var GroupCollectorInterface $collector */ $collector = app(GroupCollectorInterface::class); - $collector->setAccounts(new Collection([$account]))->setLimit($pageSize)->setPage($page)->withAccountInformation()->withCategoryInformation(); + $collector->setAccounts(new Collection()->push($account))->setLimit($pageSize)->setPage($page)->withAccountInformation()->withCategoryInformation(); // this search will not include transaction groups where this asset account (or liability) // is just part of ONE of the journals. To force this: diff --git a/app/Http/Controllers/Budget/BudgetLimitController.php b/app/Http/Controllers/Budget/BudgetLimitController.php index 367bbba1ad..63e0c93e7e 100644 --- a/app/Http/Controllers/Budget/BudgetLimitController.php +++ b/app/Http/Controllers/Budget/BudgetLimitController.php @@ -203,7 +203,7 @@ class BudgetLimitController extends Controller if ($request->expectsJson()) { $array = $limit->toArray(); // add some extra metadata: - $spentArr = $this->opsRepository->sumExpenses($limit->start_date, $limit->end_date, null, new Collection([$budget]), $currency); + $spentArr = $this->opsRepository->sumExpenses($limit->start_date, $limit->end_date, null, new Collection()->push($budget), $currency); $array['spent'] = $spentArr[$currency->id]['sum'] ?? '0'; $array['left_formatted'] = app('amount')->formatAnything($limit->transactionCurrency, bcadd($array['spent'], (string) $array['amount'])); $array['amount_formatted'] = app('amount')->formatAnything($limit->transactionCurrency, $limit['amount']); @@ -264,7 +264,7 @@ class BudgetLimitController extends Controller $limit->start_date, $limit->end_date, null, - new Collection([$budgetLimit->budget]), + new Collection()->push($budgetLimit->budget), $budgetLimit->transactionCurrency ); $daysLeft = $this->activeDaysLeft($limit->start_date, $limit->end_date); diff --git a/app/Http/Controllers/Budget/IndexController.php b/app/Http/Controllers/Budget/IndexController.php index 8b11d50ed8..2ba33347a1 100644 --- a/app/Http/Controllers/Budget/IndexController.php +++ b/app/Http/Controllers/Budget/IndexController.php @@ -235,7 +235,7 @@ class IndexController extends Controller /** @var TransactionCurrency $currency */ foreach ($currencies as $currency) { - $spentArr = $this->opsRepository->sumExpenses($start, $end, null, new Collection([$current]), $currency, false); + $spentArr = $this->opsRepository->sumExpenses($start, $end, null, new Collection()->push($current), $currency, false); if (array_key_exists($currency->id, $spentArr) && array_key_exists('sum', $spentArr[$currency->id])) { $array['spent'][$currency->id]['spent'] = $spentArr[$currency->id]['sum']; $array['spent'][$currency->id]['currency_id'] = $currency->id; diff --git a/app/Http/Controllers/Chart/AccountController.php b/app/Http/Controllers/Chart/AccountController.php index 775aae212c..1e48b0d65f 100644 --- a/app/Http/Controllers/Chart/AccountController.php +++ b/app/Http/Controllers/Chart/AccountController.php @@ -235,7 +235,7 @@ class AccountController extends Controller /** @var GroupCollectorInterface $collector */ $collector = app(GroupCollectorInterface::class); - $collector->setAccounts(new Collection([$account])) + $collector->setAccounts(new Collection()->push($account)) ->setRange($start, $end) ->withBudgetInformation()->setTypes([TransactionTypeEnum::WITHDRAWAL->value]) ; @@ -322,7 +322,7 @@ class AccountController extends Controller /** @var GroupCollectorInterface $collector */ $collector = app(GroupCollectorInterface::class); - $collector->setAccounts(new Collection([$account]))->setRange($start, $end)->withCategoryInformation()->setTypes([TransactionTypeEnum::WITHDRAWAL->value]); + $collector->setAccounts(new Collection()->push($account))->setRange($start, $end)->withCategoryInformation()->setTypes([TransactionTypeEnum::WITHDRAWAL->value]); $journals = $collector->getExtractedJournals(); $result = []; $chartData = []; @@ -429,7 +429,7 @@ class AccountController extends Controller /** @var GroupCollectorInterface $collector */ $collector = app(GroupCollectorInterface::class); - $collector->setAccounts(new Collection([$account]))->setRange($start, $end)->withCategoryInformation()->setTypes([TransactionTypeEnum::DEPOSIT->value]); + $collector->setAccounts(new Collection()->push($account))->setRange($start, $end)->withCategoryInformation()->setTypes([TransactionTypeEnum::DEPOSIT->value]); $journals = $collector->getExtractedJournals(); $result = []; $chartData = []; diff --git a/app/Http/Controllers/Chart/BudgetController.php b/app/Http/Controllers/Chart/BudgetController.php index 4c47208824..a2d1ee0911 100644 --- a/app/Http/Controllers/Chart/BudgetController.php +++ b/app/Http/Controllers/Chart/BudgetController.php @@ -100,7 +100,7 @@ class BudgetController extends Controller return response()->json($cache->get()); } $step = $this->calculateStep($start, $end); // depending on diff, do something with range of chart. - $collection = new Collection([$budget]); + $collection = new Collection()->push($budget); $chartData = []; $loopStart = clone $start; $loopStart = Navigation::startOfPeriod($loopStart, $step); @@ -169,7 +169,7 @@ class BudgetController extends Controller $locale = app('steam')->getLocale(); $entries = []; $amount = $budgetLimit->amount ?? '0'; - $budgetCollection = new Collection([$budget]); + $budgetCollection = new Collection()->push($budget); $currency = $budgetLimit->transactionCurrency; if ($this->convertToPrimary) { $amount = $budgetLimit->native_amount ?? $amount; @@ -535,7 +535,7 @@ class BudgetController extends Controller } // get spent amount in this period for this currency. - $sum = $this->opsRepository->sumExpenses($currentStart, $currentEnd, $accounts, new Collection([$budget]), $currency); + $sum = $this->opsRepository->sumExpenses($currentStart, $currentEnd, $accounts, new Collection()->push($budget), $currency); $amount = app('steam')->positive($sum[$currency->id]['sum'] ?? '0'); $chartData[0]['entries'][$title] = app('steam')->bcround($amount, $currency->decimal_places); diff --git a/app/Http/Controllers/Chart/BudgetReportController.php b/app/Http/Controllers/Chart/BudgetReportController.php index 0b5daf13a9..9e66271b11 100644 --- a/app/Http/Controllers/Chart/BudgetReportController.php +++ b/app/Http/Controllers/Chart/BudgetReportController.php @@ -163,7 +163,7 @@ class BudgetReportController extends Controller public function mainChart(Collection $accounts, Budget $budget, Carbon $start, Carbon $end): JsonResponse { $chartData = []; - $spent = $this->opsRepository->listExpenses($start, $end, $accounts, new Collection([$budget])); + $spent = $this->opsRepository->listExpenses($start, $end, $accounts, new Collection()->push($budget)); $format = Navigation::preferredCarbonLocalizedFormat($start, $end); // loop expenses. diff --git a/app/Http/Controllers/Chart/CategoryController.php b/app/Http/Controllers/Chart/CategoryController.php index a4e9ba5624..e22a6bd4d5 100644 --- a/app/Http/Controllers/Chart/CategoryController.php +++ b/app/Http/Controllers/Chart/CategoryController.php @@ -174,7 +174,7 @@ class CategoryController extends Controller $opsRepository = app(OperationsRepositoryInterface::class); $categoryId = $category->id; // this gives us all currencies - $collection = new Collection([$category]); + $collection = new Collection()->push($category); $expenses = $opsRepository->listExpenses($start, $end, $accounts, $collection); $income = $opsRepository->listIncome($start, $end, $accounts, $collection); } diff --git a/app/Http/Controllers/Chart/CategoryReportController.php b/app/Http/Controllers/Chart/CategoryReportController.php index a45df44718..107509cece 100644 --- a/app/Http/Controllers/Chart/CategoryReportController.php +++ b/app/Http/Controllers/Chart/CategoryReportController.php @@ -208,8 +208,8 @@ class CategoryReportController extends Controller public function mainChart(Collection $accounts, Category $category, Carbon $start, Carbon $end): JsonResponse { $chartData = []; - $spent = $this->opsRepository->listExpenses($start, $end, $accounts, new Collection([$category])); - $earned = $this->opsRepository->listIncome($start, $end, $accounts, new Collection([$category])); + $spent = $this->opsRepository->listExpenses($start, $end, $accounts, new Collection()->push($category)); + $earned = $this->opsRepository->listIncome($start, $end, $accounts, new Collection()->push($category)); $format = app('navigation')->preferredCarbonLocalizedFormat($start, $end); // loop expenses. foreach ($spent as $currency) { diff --git a/app/Http/Controllers/Chart/DoubleReportController.php b/app/Http/Controllers/Chart/DoubleReportController.php index 4394ad1463..12b75f9e23 100644 --- a/app/Http/Controllers/Chart/DoubleReportController.php +++ b/app/Http/Controllers/Chart/DoubleReportController.php @@ -150,7 +150,7 @@ class DoubleReportController extends Controller { $chartData = []; - $opposing = $this->repository->expandWithDoubles(new Collection([$account])); + $opposing = $this->repository->expandWithDoubles(new Collection()->push($account)); $accounts = $accounts->merge($opposing); $spent = $this->opsRepository->listExpenses($start, $end, $accounts); $earned = $this->opsRepository->listIncome($start, $end, $accounts); diff --git a/app/Http/Controllers/Chart/TagReportController.php b/app/Http/Controllers/Chart/TagReportController.php index a81013785c..6705377806 100644 --- a/app/Http/Controllers/Chart/TagReportController.php +++ b/app/Http/Controllers/Chart/TagReportController.php @@ -212,8 +212,8 @@ class TagReportController extends Controller public function mainChart(Collection $accounts, Tag $tag, Carbon $start, Carbon $end): JsonResponse { $chartData = []; - $spent = $this->opsRepository->listExpenses($start, $end, $accounts, new Collection([$tag])); - $earned = $this->opsRepository->listIncome($start, $end, $accounts, new Collection([$tag])); + $spent = $this->opsRepository->listExpenses($start, $end, $accounts, new Collection()->push($tag)); + $earned = $this->opsRepository->listIncome($start, $end, $accounts, new Collection()->push($tag)); $format = app('navigation')->preferredCarbonLocalizedFormat($start, $end); // loop expenses. diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index b829724308..3ab394545e 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -170,7 +170,7 @@ class HomeController extends Controller foreach ($accounts as $account) { /** @var GroupCollectorInterface $collector */ $collector = app(GroupCollectorInterface::class); - $collector->setAccounts(new Collection([$account]))->withAccountInformation()->setRange($start, $end)->setLimit(10)->setPage(1); + $collector->setAccounts(new Collection()->push($account))->withAccountInformation()->setRange($start, $end)->setLimit(10)->setPage(1); $set = $collector->getExtractedJournals(); $transactions[] = ['transactions' => $set, 'account' => $account]; } diff --git a/app/Http/Controllers/Json/ReconcileController.php b/app/Http/Controllers/Json/ReconcileController.php index 44a4d0cdf9..a1208182e8 100644 --- a/app/Http/Controllers/Json/ReconcileController.php +++ b/app/Http/Controllers/Json/ReconcileController.php @@ -217,7 +217,7 @@ class ReconcileController extends Controller /** @var GroupCollectorInterface $collector */ $collector = app(GroupCollectorInterface::class); - $collector->setAccounts(new Collection([$account])) + $collector->setAccounts(new Collection()->push($account)) ->setRange($selectionStart, $selectionEnd) ->withBudgetInformation()->withCategoryInformation()->withAccountInformation() ; diff --git a/app/Http/Controllers/Recurring/TriggerController.php b/app/Http/Controllers/Recurring/TriggerController.php index 454b999593..7719be82a8 100644 --- a/app/Http/Controllers/Recurring/TriggerController.php +++ b/app/Http/Controllers/Recurring/TriggerController.php @@ -74,7 +74,7 @@ class TriggerController extends Controller /** @var CreateRecurringTransactions $job */ $job = app(CreateRecurringTransactions::class); - $job->setRecurrences(new Collection([$recurrence])); + $job->setRecurrences(new Collection()->push($recurrence)); $job->setDate($date); $job->setForce(false); $job->handle(); diff --git a/app/Http/Controllers/Rule/SelectController.php b/app/Http/Controllers/Rule/SelectController.php index c266d41b21..4d85f8ae3d 100644 --- a/app/Http/Controllers/Rule/SelectController.php +++ b/app/Http/Controllers/Rule/SelectController.php @@ -152,7 +152,7 @@ class SelectController extends Controller $newRuleEngine = app(RuleEngineInterface::class); // set rules: - $newRuleEngine->setRules(new Collection([$rule])); + $newRuleEngine->setRules(new Collection()->push($rule)); $newRuleEngine->setRefreshTriggers(false); $collection = $newRuleEngine->find(); $collection = $collection->slice(0, 20); @@ -196,7 +196,7 @@ class SelectController extends Controller $newRuleEngine = app(RuleEngineInterface::class); // set rules: - $newRuleEngine->setRules(new Collection([$rule])); + $newRuleEngine->setRules(new Collection()->push($rule)); $collection = $newRuleEngine->find(); $collection = $collection->slice(0, 20); diff --git a/app/Http/Controllers/RuleGroup/ExecutionController.php b/app/Http/Controllers/RuleGroup/ExecutionController.php index 9088b74442..a0191cba3f 100644 --- a/app/Http/Controllers/RuleGroup/ExecutionController.php +++ b/app/Http/Controllers/RuleGroup/ExecutionController.php @@ -78,7 +78,7 @@ class ExecutionController extends Controller // set rules: // #10427, file rule group and not the set of rules. - $collection = new Collection([$ruleGroup]); + $collection = new Collection()->push($ruleGroup); $newRuleEngine->setRuleGroups($collection); $newRuleEngine->fire(); diff --git a/app/Jobs/CreateAutoBudgetLimits.php b/app/Jobs/CreateAutoBudgetLimits.php index 0d74406fb7..e9779d0bc0 100644 --- a/app/Jobs/CreateAutoBudgetLimits.php +++ b/app/Jobs/CreateAutoBudgetLimits.php @@ -269,7 +269,7 @@ class CreateAutoBudgetLimits implements ShouldQueue // if has one, calculate expenses and use that as a base. $repository = app(OperationsRepositoryInterface::class); $repository->setUser($autoBudget->budget->user); - $spent = $repository->sumExpenses($previousStart, $previousEnd, null, new Collection([$autoBudget->budget]), $autoBudget->transactionCurrency); + $spent = $repository->sumExpenses($previousStart, $previousEnd, null, new Collection()->push($autoBudget->budget), $autoBudget->transactionCurrency); $currencyId = $autoBudget->transaction_currency_id; $spentAmount = $spent[$currencyId]['sum'] ?? '0'; Log::debug(sprintf('Spent in previous budget period (%s-%s) is %s', $previousStart->format('Y-m-d'), $previousEnd->format('Y-m-d'), $spentAmount)); @@ -329,7 +329,7 @@ class CreateAutoBudgetLimits implements ShouldQueue // if has one, calculate expenses and use that as a base. $repository = app(OperationsRepositoryInterface::class); $repository->setUser($autoBudget->budget->user); - $spent = $repository->sumExpenses($previousStart, $previousEnd, null, new Collection([$autoBudget->budget]), $autoBudget->transactionCurrency); + $spent = $repository->sumExpenses($previousStart, $previousEnd, null, new Collection()->push($autoBudget->budget), $autoBudget->transactionCurrency); $currencyId = $autoBudget->transaction_currency_id; $spentAmount = $spent[$currencyId]['sum'] ?? '0'; Log::debug(sprintf('Spent in previous budget period (%s-%s) is %s', $previousStart->format('Y-m-d'), $previousEnd->format('Y-m-d'), $spentAmount)); diff --git a/app/Support/Chart/Budget/FrontpageChartGenerator.php b/app/Support/Chart/Budget/FrontpageChartGenerator.php index f2728f89e5..9e351afc78 100644 --- a/app/Support/Chart/Budget/FrontpageChartGenerator.php +++ b/app/Support/Chart/Budget/FrontpageChartGenerator.php @@ -114,7 +114,7 @@ class FrontpageChartGenerator */ private function noBudgetLimits(array $data, Budget $budget): array { - $spent = $this->opsRepository->sumExpenses($this->start, $this->end, null, new Collection([$budget])); + $spent = $this->opsRepository->sumExpenses($this->start, $this->end, null, new Collection()->push($budget)); /** @var array $entry */ foreach ($spent as $entry) { @@ -158,7 +158,7 @@ class FrontpageChartGenerator Log::debug(sprintf('Processing limit #%d with %s %s', $limit->id, $limit->transactionCurrency->code, $limit->amount)); } - $spent = $this->opsRepository->sumExpenses($limit->start_date, $limit->end_date, null, new Collection([$budget]), $currency); + $spent = $this->opsRepository->sumExpenses($limit->start_date, $limit->end_date, null, new Collection()->push($budget), $currency); Log::debug(sprintf('Spent array has %d entries.', count($spent))); /** @var array $entry */ diff --git a/app/Support/Chart/Category/WholePeriodChartGenerator.php b/app/Support/Chart/Category/WholePeriodChartGenerator.php index 344b4b68b3..2a28cb4d62 100644 --- a/app/Support/Chart/Category/WholePeriodChartGenerator.php +++ b/app/Support/Chart/Category/WholePeriodChartGenerator.php @@ -40,7 +40,7 @@ class WholePeriodChartGenerator public function generate(Category $category, Carbon $start, Carbon $end): array { - $collection = new Collection([$category]); + $collection = new Collection()->push($category); /** @var OperationsRepositoryInterface $opsRepository */ $opsRepository = app(OperationsRepositoryInterface::class); diff --git a/app/Support/Http/Controllers/AugumentData.php b/app/Support/Http/Controllers/AugumentData.php index a95a1e6ff2..d882ce2b5b 100644 --- a/app/Support/Http/Controllers/AugumentData.php +++ b/app/Support/Http/Controllers/AugumentData.php @@ -191,7 +191,7 @@ trait AugumentData $set = $blRepository->getBudgetLimits($budget, $start, $end); - $budgetCollection = new Collection([$budget]); + $budgetCollection = new Collection()->push($budget); // merge sets based on a key, in case of convert to primary currency $limits = new Collection(); diff --git a/app/Support/JsonApi/Enrichments/AccountEnrichment.php b/app/Support/JsonApi/Enrichments/AccountEnrichment.php index 96c99cd41c..62dee47082 100644 --- a/app/Support/JsonApi/Enrichments/AccountEnrichment.php +++ b/app/Support/JsonApi/Enrichments/AccountEnrichment.php @@ -90,7 +90,7 @@ class AccountEnrichment implements EnrichmentInterface public function enrichSingle(array|Model $model): Account|array { Log::debug(__METHOD__); - $collection = new Collection([$model]); + $collection = new Collection()->push($model); $collection = $this->enrich($collection); return $collection->first(); diff --git a/app/Support/JsonApi/Enrichments/BudgetEnrichment.php b/app/Support/JsonApi/Enrichments/BudgetEnrichment.php index 821cd051c8..2aa21bc9cf 100644 --- a/app/Support/JsonApi/Enrichments/BudgetEnrichment.php +++ b/app/Support/JsonApi/Enrichments/BudgetEnrichment.php @@ -73,7 +73,7 @@ class BudgetEnrichment implements EnrichmentInterface public function enrichSingle(array|Model $model): array|Model { Log::debug(__METHOD__); - $collection = new Collection([$model]); + $collection = new Collection()->push($model); $collection = $this->enrich($collection); return $collection->first(); @@ -167,7 +167,7 @@ class BudgetEnrichment implements EnrichmentInterface $opsRepository->setUser($this->user); $opsRepository->setUserGroup($this->userGroup); // $spent = $this->beautify(); - // $set = $this->opsRepository->sumExpenses($start, $end, null, new Collection([$budget])) + // $set = $this->opsRepository->sumExpenses($start, $end, null, new Collection()->push($budget)) $expenses = $opsRepository->collectExpenses($this->start, $this->end, null, $this->collection, null); foreach ($this->collection as $item) { $id = (int)$item->id; diff --git a/app/Support/JsonApi/Enrichments/CategoryEnrichment.php b/app/Support/JsonApi/Enrichments/CategoryEnrichment.php index 7547b57f4b..bbe24f94c2 100644 --- a/app/Support/JsonApi/Enrichments/CategoryEnrichment.php +++ b/app/Support/JsonApi/Enrichments/CategoryEnrichment.php @@ -65,7 +65,7 @@ class CategoryEnrichment implements EnrichmentInterface public function enrichSingle(array|Model $model): array|Model { Log::debug(__METHOD__); - $collection = new Collection([$model]); + $collection = new Collection()->push($model); $collection = $this->enrich($collection); return $collection->first(); diff --git a/app/Support/JsonApi/Enrichments/PiggyBankEnrichment.php b/app/Support/JsonApi/Enrichments/PiggyBankEnrichment.php index 7266cec54d..9dd940801a 100644 --- a/app/Support/JsonApi/Enrichments/PiggyBankEnrichment.php +++ b/app/Support/JsonApi/Enrichments/PiggyBankEnrichment.php @@ -80,7 +80,7 @@ class PiggyBankEnrichment implements EnrichmentInterface public function enrichSingle(array|Model $model): array|Model { Log::debug(__METHOD__); - $collection = new Collection([$model]); + $collection = new Collection()->push($model); $collection = $this->enrich($collection); return $collection->first(); diff --git a/app/Support/JsonApi/Enrichments/PiggyBankEventEnrichment.php b/app/Support/JsonApi/Enrichments/PiggyBankEventEnrichment.php index 9247bbbf18..fad6293f90 100644 --- a/app/Support/JsonApi/Enrichments/PiggyBankEventEnrichment.php +++ b/app/Support/JsonApi/Enrichments/PiggyBankEventEnrichment.php @@ -69,7 +69,7 @@ class PiggyBankEventEnrichment implements EnrichmentInterface public function enrichSingle(array|Model $model): array|Model { Log::debug(__METHOD__); - $collection = new Collection([$model]); + $collection = new Collection()->push($model); $collection = $this->enrich($collection); return $collection->first(); diff --git a/app/Support/JsonApi/Enrichments/RecurringEnrichment.php b/app/Support/JsonApi/Enrichments/RecurringEnrichment.php index 6c3f049d49..4b2249dc49 100644 --- a/app/Support/JsonApi/Enrichments/RecurringEnrichment.php +++ b/app/Support/JsonApi/Enrichments/RecurringEnrichment.php @@ -101,7 +101,7 @@ class RecurringEnrichment implements EnrichmentInterface public function enrichSingle(array|Model $model): array|Model { Log::debug(__METHOD__); - $collection = new Collection([$model]); + $collection = new Collection()->push($model); $collection = $this->enrich($collection); return $collection->first(); diff --git a/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php b/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php index 01c7c8bd69..06388a80bc 100644 --- a/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php +++ b/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php @@ -145,7 +145,7 @@ class SubscriptionEnrichment implements EnrichmentInterface public function enrichSingle(array|Model $model): array|Model { Log::debug(__METHOD__); - $collection = new Collection([$model]); + $collection = new Collection()->push($model); $collection = $this->enrich($collection); return $collection->first(); diff --git a/app/Support/JsonApi/Enrichments/TransactionGroupEnrichment.php b/app/Support/JsonApi/Enrichments/TransactionGroupEnrichment.php index 7ff47ca207..d322331135 100644 --- a/app/Support/JsonApi/Enrichments/TransactionGroupEnrichment.php +++ b/app/Support/JsonApi/Enrichments/TransactionGroupEnrichment.php @@ -68,7 +68,7 @@ class TransactionGroupEnrichment implements EnrichmentInterface { Log::debug(__METHOD__); if (is_array($model)) { - $collection = new Collection([$model]); + $collection = new Collection()->push($model); $collection = $this->enrich($collection); return $collection->first(); diff --git a/app/Support/JsonApi/Enrichments/WebhookEnrichment.php b/app/Support/JsonApi/Enrichments/WebhookEnrichment.php index ed14659cfb..516705892a 100644 --- a/app/Support/JsonApi/Enrichments/WebhookEnrichment.php +++ b/app/Support/JsonApi/Enrichments/WebhookEnrichment.php @@ -70,7 +70,7 @@ class WebhookEnrichment implements EnrichmentInterface public function enrichSingle(array|Model $model): array|Model { Log::debug(__METHOD__); - $collection = new Collection([$model]); + $collection = new Collection()->push($model); $collection = $this->enrich($collection); return $collection->first(); diff --git a/app/Support/Report/Budget/BudgetReportGenerator.php b/app/Support/Report/Budget/BudgetReportGenerator.php index 3014e97dc4..c478e3cce4 100644 --- a/app/Support/Report/Budget/BudgetReportGenerator.php +++ b/app/Support/Report/Budget/BudgetReportGenerator.php @@ -188,7 +188,7 @@ class BudgetReportGenerator $limitId = $limit->id; $limitCurrency = $limit->transactionCurrency ?? $this->currency; $currencyId = $limitCurrency->id; - $expenses = $this->opsRepository->sumExpenses($limit->start_date, $limit->end_date, $this->accounts, new Collection([$budget])); + $expenses = $this->opsRepository->sumExpenses($limit->start_date, $limit->end_date, $this->accounts, new Collection()->push($budget)); $spent = $expenses[$currencyId]['sum'] ?? '0'; $left = -1 === bccomp(bcadd($limit->amount, $spent), '0') ? '0' : bcadd($limit->amount, $spent); $overspent = 1 === bccomp(bcmul($spent, '-1'), $limit->amount) ? bcadd($spent, $limit->amount) : '0'; diff --git a/app/Support/Repositories/Recurring/FiltersWeekends.php b/app/Support/Repositories/Recurring/FiltersWeekends.php index 222879cc29..e5befa669f 100644 --- a/app/Support/Repositories/Recurring/FiltersWeekends.php +++ b/app/Support/Repositories/Recurring/FiltersWeekends.php @@ -28,6 +28,7 @@ use Carbon\Carbon; use FireflyIII\Enums\RecurrenceRepetitionWeekend; use FireflyIII\Models\RecurrenceRepetition; use Illuminate\Support\Collection; +use Illuminate\Support\Facades\Log; /** * Trait FiltersWeekends @@ -39,9 +40,9 @@ trait FiltersWeekends */ protected function filterWeekends(RecurrenceRepetition $repetition, array $dates): array { - app('log')->debug(sprintf('Now in %s', __METHOD__)); + Log::debug(sprintf('Now in %s', __METHOD__)); if (RecurrenceRepetitionWeekend::WEEKEND_DO_NOTHING->value === $repetition->weekend) { - app('log')->debug('Repetition will not be filtered on weekend days.'); + Log::debug('Repetition will not be filtered on weekend days.'); return $dates; } @@ -53,7 +54,7 @@ trait FiltersWeekends if (!$isWeekend) { $return[] = clone $date; - // app('log')->debug(sprintf('Date is %s, not a weekend date.', $date->format('D d M Y'))); + // Log::debug(sprintf('Date is %s, not a weekend date.', $date->format('D d M Y'))); continue; } @@ -61,7 +62,7 @@ trait FiltersWeekends if (RecurrenceRepetitionWeekend::WEEKEND_TO_FRIDAY->value === $repetition->weekend) { $clone = clone $date; $clone->addDays(5 - $date->dayOfWeekIso); - app('log')->debug( + Log::debug( sprintf('Date is %s, and this is in the weekend, so corrected to %s (Friday).', $date->format('D d M Y'), $clone->format('D d M Y')) ); $return[] = clone $clone; @@ -73,23 +74,23 @@ trait FiltersWeekends if (RecurrenceRepetitionWeekend::WEEKEND_TO_MONDAY->value === $repetition->weekend) { $clone = clone $date; $clone->addDays(8 - $date->dayOfWeekIso); - app('log')->debug( + Log::debug( sprintf('Date is %s, and this is in the weekend, so corrected to %s (Monday).', $date->format('D d M Y'), $clone->format('D d M Y')) ); $return[] = $clone; continue; } - // app('log')->debug(sprintf('Date is %s, removed from final result', $date->format('D d M Y'))); + // Log::debug(sprintf('Date is %s, removed from final result', $date->format('D d M Y'))); } // filter unique dates - app('log')->debug(sprintf('Count before filtering: %d', count($dates))); + Log::debug(sprintf('Count before filtering: %d', count($dates))); $collection = new Collection($return); $filtered = $collection->unique(); $return = $filtered->toArray(); - app('log')->debug(sprintf('Count after filtering: %d', count($return))); + Log::debug(sprintf('Count after filtering: %d', count($return))); return $return; } diff --git a/app/Support/Search/OperatorQuerySearch.php b/app/Support/Search/OperatorQuerySearch.php index 69781b2157..dc975609f0 100644 --- a/app/Support/Search/OperatorQuerySearch.php +++ b/app/Support/Search/OperatorQuerySearch.php @@ -450,7 +450,7 @@ class OperatorQuerySearch implements SearchInterface case 'source_account_id': $account = $this->accountRepository->find((int) $value); if (null !== $account) { - $this->collector->setSourceAccounts(new Collection([$account])); + $this->collector->setSourceAccounts(new Collection()->push($account)); } if (null === $account) { // since the source does not exist, cannot return results: @@ -463,7 +463,7 @@ class OperatorQuerySearch implements SearchInterface case '-source_account_id': $account = $this->accountRepository->find((int) $value); if (null !== $account) { - $this->collector->excludeSourceAccounts(new Collection([$account])); + $this->collector->excludeSourceAccounts(new Collection()->push($account)); } if (null === $account) { // since the source does not exist, cannot return results: @@ -580,7 +580,7 @@ class OperatorQuerySearch implements SearchInterface case 'destination_account_id': $account = $this->accountRepository->find((int) $value); if (null !== $account) { - $this->collector->setDestinationAccounts(new Collection([$account])); + $this->collector->setDestinationAccounts(new Collection()->push($account)); } if (null === $account) { Log::warning('Call to findNothing() because dest account does not exist (destination_account_id).'); @@ -592,7 +592,7 @@ class OperatorQuerySearch implements SearchInterface case '-destination_account_id': $account = $this->accountRepository->find((int) $value); if (null !== $account) { - $this->collector->excludeDestinationAccounts(new Collection([$account])); + $this->collector->excludeDestinationAccounts(new Collection()->push($account)); } if (null === $account) { Log::warning('Call to findNothing() because dest account does not exist (-destination_account_id).'); @@ -652,37 +652,37 @@ class OperatorQuerySearch implements SearchInterface // case 'source_is_cash': $account = $this->getCashAccount(); - $this->collector->setSourceAccounts(new Collection([$account])); + $this->collector->setSourceAccounts(new Collection()->push($account)); break; case '-source_is_cash': $account = $this->getCashAccount(); - $this->collector->excludeSourceAccounts(new Collection([$account])); + $this->collector->excludeSourceAccounts(new Collection()->push($account)); break; case 'destination_is_cash': $account = $this->getCashAccount(); - $this->collector->setDestinationAccounts(new Collection([$account])); + $this->collector->setDestinationAccounts(new Collection()->push($account)); break; case '-destination_is_cash': $account = $this->getCashAccount(); - $this->collector->excludeDestinationAccounts(new Collection([$account])); + $this->collector->excludeDestinationAccounts(new Collection()->push($account)); break; case 'account_is_cash': $account = $this->getCashAccount(); - $this->collector->setAccounts(new Collection([$account])); + $this->collector->setAccounts(new Collection()->push($account)); break; case '-account_is_cash': $account = $this->getCashAccount(); - $this->collector->excludeAccounts(new Collection([$account])); + $this->collector->excludeAccounts(new Collection()->push($account)); break; @@ -1070,7 +1070,7 @@ class OperatorQuerySearch implements SearchInterface case '-bill_is': $bill = $this->billRepository->findByName($value); if (null !== $bill) { - $this->collector->excludeBills(new Collection([$bill])); + $this->collector->excludeBills(new Collection()->push($bill)); break; }