Skip to content

Firefly III: a personal finances manager

Various strict code things.

James Coledbe827e3c565
diff --git a/app/Generator/Webhook/StandardMessageGenerator.php b/app/Generator/Webhook/StandardMessageGenerator.php
index aeb6ee9660..f48404cfde 100644
--- a/app/Generator/Webhook/StandardMessageGenerator.php
+++ b/app/Generator/Webhook/StandardMessageGenerator.php
@@ -101,7 +101,7 @@ class StandardMessageGenerator implements MessageGeneratorInterface
*/
private function getWebhooks(): Collection
{
- return $this->user->webhooks()->where('active', 1)->where('trigger', $this->trigger)->get(['webhooks.*']);
+ return $this->user->webhooks()->where('active', true)->where('trigger', $this->trigger)->get(['webhooks.*']);
}
/**
diff --git a/app/Helpers/Collector/GroupCollector.php b/app/Helpers/Collector/GroupCollector.php
index 961781e091..2d04f8f34e 100644
--- a/app/Helpers/Collector/GroupCollector.php
+++ b/app/Helpers/Collector/GroupCollector.php
@@ -497,7 +497,7 @@ class GroupCollector implements GroupCollectorInterface
->where(
static function (EloquentBuilder $q1) {
$q1->where('attachments.attachable_type', TransactionJournal::class);
- $q1->where('attachments.uploaded', 1);
+ $q1->where('attachments.uploaded', true);
$q1->orWhereNull('attachments.attachable_type');
}
);
diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php
index 6177f200e8..03089c709a 100644
--- a/app/Repositories/Account/AccountRepository.php
+++ b/app/Repositories/Account/AccountRepository.php
@@ -259,7 +259,7 @@ class AccountRepository implements AccountRepositoryInterface
if (0 !== count($types)) {
$query->accountTypeIn($types);
}
- $query->where('active', 1);
+ $query->where('active', true);
$query->orderBy('accounts.account_type_id', 'ASC');
$query->orderBy('accounts.order', 'ASC');
$query->orderBy('accounts.name', 'ASC');
@@ -640,7 +640,7 @@ class AccountRepository implements AccountRepositoryInterface
public function searchAccount(string $query, array $types, int $limit): Collection
{
$dbQuery = $this->user->accounts()
- ->where('active', 1)
+ ->where('active', true)
->orderBy('accounts.order', 'ASC')
->orderBy('accounts.account_type_id', 'ASC')
->orderBy('accounts.name', 'ASC')
@@ -669,7 +669,7 @@ class AccountRepository implements AccountRepositoryInterface
{
$dbQuery = $this->user->accounts()->distinct()
->leftJoin('account_meta', 'accounts.id', '=', 'account_meta.account_id')
- ->where('accounts.active', 1)
+ ->where('accounts.active', true)
->orderBy('accounts.order', 'ASC')
->orderBy('accounts.account_type_id', 'ASC')
->orderBy('accounts.name', 'ASC')
diff --git a/app/Repositories/Bill/BillRepository.php b/app/Repositories/Bill/BillRepository.php
index 1a9897d53a..bae560b7c9 100644
--- a/app/Repositories/Bill/BillRepository.php
+++ b/app/Repositories/Bill/BillRepository.php
@@ -166,7 +166,7 @@ class BillRepository implements BillRepositoryInterface
public function getActiveBills(): Collection
{
return $this->user->bills()
- ->where('active', 1)
+ ->where('active', true)
->orderBy('bills.name', 'ASC')
->get(['bills.*', DB::raw('((bills.amount_min + bills.amount_max) / 2) AS expectedAmount'),]);
}
diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.php
index b296995edd..416e59dff9 100644
--- a/app/Repositories/Budget/BudgetRepository.php
+++ b/app/Repositories/Budget/BudgetRepository.php
@@ -197,7 +197,7 @@ class BudgetRepository implements BudgetRepositoryInterface
*/
public function getActiveBudgets(): Collection
{
- return $this->user->budgets()->where('active', 1)
+ return $this->user->budgets()->where('active', true)
->orderBy('order', 'ASC')
->orderBy('name', 'ASC')
->get();
@@ -282,7 +282,7 @@ class BudgetRepository implements BudgetRepositoryInterface
$search->where('name', 'LIKE', sprintf('%%%s%%', $query));
}
$search->orderBy('order', 'ASC')
- ->orderBy('name', 'ASC')->where('active', 1);
+ ->orderBy('name', 'ASC')->where('active', true);
return $search->take($limit)->get();
}
diff --git a/app/Repositories/Currency/CurrencyRepository.php b/app/Repositories/Currency/CurrencyRepository.php
index d96e2aad6c..c2249e6bbe 100644
--- a/app/Repositories/Currency/CurrencyRepository.php
+++ b/app/Repositories/Currency/CurrencyRepository.php
@@ -448,7 +448,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
*/
public function searchCurrency(string $search, int $limit): Collection
{
- $query = TransactionCurrency::where('enabled', 1);
+ $query = TransactionCurrency::where('enabled', true);
if ('' !== $search) {
$query->where('name', 'LIKE', sprintf('%%%s%%', $search));
}
diff --git a/app/Repositories/Rule/RuleRepository.php b/app/Repositories/Rule/RuleRepository.php
index 68130393cd..dd75f8d930 100644
--- a/app/Repositories/Rule/RuleRepository.php
+++ b/app/Repositories/Rule/RuleRepository.php
@@ -211,8 +211,8 @@ class RuleRepository implements RuleRepositoryInterface
{
$collection = $this->user->rules()
->leftJoin('rule_groups', 'rule_groups.id', '=', 'rules.rule_group_id')
- ->where('rules.active', 1)
- ->where('rule_groups.active', 1)
+ ->where('rules.active', true)
+ ->where('rule_groups.active', true)
->orderBy('rule_groups.order', 'ASC')
->orderBy('rules.order', 'ASC')
->orderBy('rules.id', 'ASC')
@@ -238,8 +238,8 @@ class RuleRepository implements RuleRepositoryInterface
{
$collection = $this->user->rules()
->leftJoin('rule_groups', 'rule_groups.id', '=', 'rules.rule_group_id')
- ->where('rules.active', 1)
- ->where('rule_groups.active', 1)
+ ->where('rules.active', true)
+ ->where('rule_groups.active', true)
->orderBy('rule_groups.order', 'ASC')
->orderBy('rules.order', 'ASC')
->orderBy('rules.id', 'ASC')
diff --git a/app/Repositories/RuleGroup/RuleGroupRepository.php b/app/Repositories/RuleGroup/RuleGroupRepository.php
index f1fad15cef..bdc2c5bb74 100644
--- a/app/Repositories/RuleGroup/RuleGroupRepository.php
+++ b/app/Repositories/RuleGroup/RuleGroupRepository.php
@@ -150,7 +150,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
*/
public function getActiveGroups(): Collection
{
- return $this->user->ruleGroups()->with(['rules'])->where('rule_groups.active', 1)->orderBy('order', 'ASC')->get(['rule_groups.*']);
+ return $this->user->ruleGroups()->with(['rules'])->where('rule_groups.active', true)->orderBy('order', 'ASC')->get(['rule_groups.*']);
}
/**
@@ -161,7 +161,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
public function getActiveRules(RuleGroup $group): Collection
{
return $group->rules()
- ->where('rules.active', 1)
+ ->where('rules.active', true)
->get(['rules.*']);
}
@@ -176,7 +176,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
->leftJoin('rule_triggers', 'rules.id', '=', 'rule_triggers.rule_id')
->where('rule_triggers.trigger_type', 'user_action')
->where('rule_triggers.trigger_value', 'store-journal')
- ->where('rules.active', 1)
+ ->where('rules.active', true)
->get(['rules.*']);
}
@@ -191,7 +191,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
->leftJoin('rule_triggers', 'rules.id', '=', 'rule_triggers.rule_id')
->where('rule_triggers.trigger_type', 'user_action')
->where('rule_triggers.trigger_value', 'update-journal')
- ->where('rules.active', 1)
+ ->where('rules.active', true)
->get(['rules.*']);
}
@@ -326,7 +326,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
*/
public function maxOrder(): int
{
- return (int)$this->user->ruleGroups()->where('active', 1)->max('order');
+ return (int)$this->user->ruleGroups()->where('active', true)->max('order');
}
/**
@@ -337,7 +337,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
$this->user->ruleGroups()->where('active', false)->update(['order' => 0]);
$set = $this->user
->ruleGroups()
- ->where('active', 1)
+ ->where('active', true)
->whereNull('deleted_at')
->orderBy('order', 'ASC')
->orderBy('title', 'DESC')
diff --git a/app/Repositories/TransactionGroup/TransactionGroupRepository.php b/app/Repositories/TransactionGroup/TransactionGroupRepository.php
index a0581d398e..71d568e00f 100644
--- a/app/Repositories/TransactionGroup/TransactionGroupRepository.php
+++ b/app/Repositories/TransactionGroup/TransactionGroupRepository.php
@@ -102,7 +102,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
$journals = $group->transactionJournals->pluck('id')->toArray();
$set = Attachment::whereIn('attachable_id', $journals)
->where('attachable_type', TransactionJournal::class)
- ->where('uploaded', 1)
+ ->where('uploaded', true)
->whereNull('deleted_at')->get();
$result = [];
diff --git a/app/Support/Binder/BudgetList.php b/app/Support/Binder/BudgetList.php
index ba4daf89f2..134f17233d 100644
--- a/app/Support/Binder/BudgetList.php
+++ b/app/Support/Binder/BudgetList.php
@@ -46,7 +46,7 @@ class BudgetList implements BinderInterface
if (auth()->check()) {
if ('allBudgets' === $value) {
- return auth()->user()->budgets()->where('active', 1)
+ return auth()->user()->budgets()->where('active', true)
->orderBy('order', 'ASC')
->orderBy('name', 'ASC')
->get();
@@ -63,7 +63,7 @@ class BudgetList implements BinderInterface
/** @var Collection $collection */
$collection = auth()->user()->budgets()
- ->where('active', 1)
+ ->where('active', true)
->whereIn('id', $list)
->get();
diff --git a/app/TransactionRules/Engine/SearchRuleEngine.php b/app/TransactionRules/Engine/SearchRuleEngine.php
index 273a3ce393..71327d2b6b 100644
--- a/app/TransactionRules/Engine/SearchRuleEngine.php
+++ b/app/TransactionRules/Engine/SearchRuleEngine.php
@@ -383,7 +383,7 @@ class SearchRuleEngine implements RuleEngineInterface
{
Log::debug(sprintf('SearchRuleEngine:: Will now execute actions on transaction journal #%d', $transaction['transaction_journal_id']));
/** @var RuleAction $ruleAction */
- foreach ($rule->ruleActions()->where('active', 1)->get() as $ruleAction) {
+ foreach ($rule->ruleActions()->where('active', true)->get() as $ruleAction) {
$break = $this->processRuleAction($ruleAction, $transaction);
if (true === $break) {
break;
@@ -458,8 +458,15 @@ class SearchRuleEngine implements RuleEngineInterface
// start a search query for individual each trigger:
$total = new Collection;
$count = 0;
+
+ /** @var Collection $triggers */
+ $triggers = $rule->ruleTriggers;
+
/** @var RuleTrigger $ruleTrigger */
- foreach ($rule->ruleTriggers()->where('active', 1)->get() as $ruleTrigger) {
+ foreach ($triggers as $ruleTrigger) {
+ if (false === $ruleTrigger->active) {
+ continue;
+ }
if ('user_action' === $ruleTrigger->trigger_type) {
Log::debug('Skip trigger type.');
continue;