diff --git a/app/Api/V1/Controllers/Data/PurgeController.php b/app/Api/V1/Controllers/Data/PurgeController.php index 50fd4e2995..fc6e5365f6 100644 --- a/app/Api/V1/Controllers/Data/PurgeController.php +++ b/app/Api/V1/Controllers/Data/PurgeController.php @@ -87,7 +87,7 @@ final class PurgeController extends Controller Rule::whereUserId($user->id)->onlyTrashed()->forceDelete(); // notes (this will actually purge EVERYBODY's deleted notes) - Note::onlyTrashed()->forceDelete(); + Note::query()->onlyTrashed()->forceDelete(); // recurring transactions Recurrence::whereUserId($user->id)->onlyTrashed()->forceDelete(); diff --git a/app/Api/V1/Requests/Autocomplete/AutocompleteRequest.php b/app/Api/V1/Requests/Autocomplete/AutocompleteRequest.php index fdd82f2d50..4ab1ed1291 100644 --- a/app/Api/V1/Requests/Autocomplete/AutocompleteRequest.php +++ b/app/Api/V1/Requests/Autocomplete/AutocompleteRequest.php @@ -59,6 +59,6 @@ class AutocompleteRequest extends FormRequest public function rules(): array { - return ['date' => 'date|after:1970-01-02|before:2038-01-17']; + return ['date' => ['date', 'after:1970-01-02', 'before:2038-01-17']]; } } diff --git a/app/Api/V1/Requests/Chart/ChartRequest.php b/app/Api/V1/Requests/Chart/ChartRequest.php index a22d767ee8..9ec14fa924 100644 --- a/app/Api/V1/Requests/Chart/ChartRequest.php +++ b/app/Api/V1/Requests/Chart/ChartRequest.php @@ -60,11 +60,11 @@ class ChartRequest extends FormRequest public function rules(): array { return [ - 'start' => 'required|date|after:1970-01-02|before:2038-01-17|before_or_equal:end', - 'end' => 'required|date|after:1970-01-02|before:2038-01-17|after_or_equal:start', + 'start' => ['required', 'date', 'after:1970-01-02', 'before:2038-01-17', 'before_or_equal:end'], + 'end' => ['required', 'date', 'after:1970-01-02', 'before:2038-01-17', 'after_or_equal:start'], 'preselected' => sprintf('nullable|in:%s', implode(',', config('firefly.preselected_accounts'))), 'period' => sprintf('nullable|in:%s', implode(',', config('firefly.valid_view_ranges'))), - 'accounts' => 'nullable|array', + 'accounts' => ['nullable', 'array'], 'accounts.*' => 'exists:accounts,id', ]; } diff --git a/app/Api/V1/Requests/Data/Bulk/MoveTransactionsRequest.php b/app/Api/V1/Requests/Data/Bulk/MoveTransactionsRequest.php index 0b2b1164b2..4f57f9709b 100644 --- a/app/Api/V1/Requests/Data/Bulk/MoveTransactionsRequest.php +++ b/app/Api/V1/Requests/Data/Bulk/MoveTransactionsRequest.php @@ -52,8 +52,8 @@ class MoveTransactionsRequest extends FormRequest public function rules(): array { return [ - 'original_account' => 'required|different:destination_account|belongsToUser:accounts,id', - 'destination_account' => 'required|different:original_account|belongsToUser:accounts,id', + 'original_account' => ['required', 'different:destination_account', 'belongsToUser:accounts,id'], + 'destination_account' => ['required', 'different:original_account', 'belongsToUser:accounts,id'], ]; } diff --git a/app/Api/V1/Requests/Data/Export/ExportRequest.php b/app/Api/V1/Requests/Data/Export/ExportRequest.php index f28f59873c..aa3d8a0e8b 100644 --- a/app/Api/V1/Requests/Data/Export/ExportRequest.php +++ b/app/Api/V1/Requests/Data/Export/ExportRequest.php @@ -72,6 +72,6 @@ class ExportRequest extends FormRequest */ public function rules(): array { - return ['type' => 'in:csv', 'accounts' => 'min:1|max:32768', 'start' => 'date|before:end', 'end' => 'date|after:start']; + return ['type' => 'in:csv', 'accounts' => ['min:1', 'max:32768'], 'start' => ['date', 'before:end'], 'end' => ['date', 'after:start']]; } } diff --git a/app/Api/V1/Requests/Data/SameDateRequest.php b/app/Api/V1/Requests/Data/SameDateRequest.php index 16c4bab66a..dc534fdf85 100644 --- a/app/Api/V1/Requests/Data/SameDateRequest.php +++ b/app/Api/V1/Requests/Data/SameDateRequest.php @@ -55,6 +55,6 @@ class SameDateRequest extends FormRequest */ public function rules(): array { - return ['start' => 'required|date', 'end' => 'required|date|after_or_equal:start']; + return ['start' => ['required', 'date'], 'end' => ['required', 'date', 'after_or_equal:start']]; } } diff --git a/app/Api/V1/Requests/Generic/SingleDateRequest.php b/app/Api/V1/Requests/Generic/SingleDateRequest.php index da447c3db2..63ea94a35e 100644 --- a/app/Api/V1/Requests/Generic/SingleDateRequest.php +++ b/app/Api/V1/Requests/Generic/SingleDateRequest.php @@ -56,6 +56,6 @@ class SingleDateRequest extends FormRequest */ public function rules(): array { - return ['date' => 'required|date|after:1970-01-02|before:2038-01-17']; + return ['date' => ['required', 'date', 'after:1970-01-02', 'before:2038-01-17']]; } } diff --git a/app/Api/V1/Requests/Insight/GenericRequest.php b/app/Api/V1/Requests/Insight/GenericRequest.php index 50c1d51b8b..a44eb1cf40 100644 --- a/app/Api/V1/Requests/Insight/GenericRequest.php +++ b/app/Api/V1/Requests/Insight/GenericRequest.php @@ -169,7 +169,7 @@ class GenericRequest extends FormRequest $this->bills = new Collection(); $this->tags = new Collection(); - return ['start' => 'required|date', 'end' => 'required|date|after_or_equal:start']; + return ['start' => ['required', 'date'], 'end' => ['required', 'date', 'after_or_equal:start']]; } private function parseAccounts(): void diff --git a/app/Api/V1/Requests/Models/Account/StoreRequest.php b/app/Api/V1/Requests/Models/Account/StoreRequest.php index 383ded14e1..1db2bfb5aa 100644 --- a/app/Api/V1/Requests/Models/Account/StoreRequest.php +++ b/app/Api/V1/Requests/Models/Account/StoreRequest.php @@ -99,29 +99,29 @@ class StoreRequest extends FormRequest $ccPaymentTypes = implode(',', array_keys(config('firefly.ccTypes'))); $type = $this->convertString('type'); $rules = [ - 'name' => 'required|max:1024|min:1|uniqueAccountForUser', + 'name' => ['required', 'max:1024', 'min:1', 'uniqueAccountForUser'], 'type' => sprintf('required|max:1024|min:1|in:%s', $types), 'iban' => ['iban', 'nullable', new UniqueIban(null, $type)], - 'bic' => 'bic|nullable', + 'bic' => ['bic', 'nullable'], 'account_number' => ['min:1', 'max:255', 'nullable', new UniqueAccountNumber(null, $type)], - 'opening_balance' => 'numeric|required_with:opening_balance_date|nullable', - 'opening_balance_date' => 'date|required_with:opening_balance|nullable', - 'virtual_balance' => 'numeric|nullable', - 'order' => 'numeric|nullable', - 'currency_id' => 'numeric|exists:transaction_currencies,id', - 'currency_code' => 'min:3|max:3|exists:transaction_currencies,code', + 'opening_balance' => ['numeric', 'required_with:opening_balance_date', 'nullable'], + 'opening_balance_date' => ['date', 'required_with:opening_balance', 'nullable'], + 'virtual_balance' => ['numeric', 'nullable'], + 'order' => ['numeric', 'nullable'], + 'currency_id' => ['numeric', 'exists:transaction_currencies,id'], + 'currency_code' => ['min:3', 'max:3', 'exists:transaction_currencies,code'], 'active' => [new IsBoolean()], 'include_net_worth' => [new IsBoolean()], 'account_role' => sprintf('nullable|in:%s|required_if:type,asset', $accountRoles), 'credit_card_type' => sprintf('nullable|in:%s|required_if:account_role,ccAsset', $ccPaymentTypes), - 'monthly_payment_date' => 'nullable|date|required_if:account_role,ccAsset|required_if:credit_card_type,monthlyFull', - 'liability_type' => 'nullable|required_if:type,liability|required_if:type,liabilities|in:loan,debt,mortgage', + 'monthly_payment_date' => ['nullable', 'date', 'required_if:account_role,ccAsset', 'required_if:credit_card_type,monthlyFull'], + 'liability_type' => ['nullable', 'required_if:type,liability', 'required_if:type,liabilities', 'in:loan,debt,mortgage'], 'liability_amount' => ['required_with:liability_start_date', new IsValidPositiveAmount()], - 'liability_start_date' => 'required_with:liability_amount|date', - 'liability_direction' => 'nullable|required_if:type,liability|required_if:type,liabilities|in:credit,debit', - 'interest' => 'min:0|max:100|numeric', + 'liability_start_date' => ['required_with:liability_amount', 'date'], + 'liability_direction' => ['nullable', 'required_if:type,liability', 'required_if:type,liabilities', 'in:credit,debit'], + 'interest' => ['min:0', 'max:100', 'numeric'], 'interest_period' => sprintf('nullable|in:%s', implode(',', config('firefly.interest_periods'))), - 'notes' => 'min:0|max:32768', + 'notes' => ['min:0', 'max:32768'], ]; return Location::requestRules($rules); diff --git a/app/Api/V1/Requests/Models/Account/UpdateRequest.php b/app/Api/V1/Requests/Models/Account/UpdateRequest.php index d8069ce82d..5d184f2969 100644 --- a/app/Api/V1/Requests/Models/Account/UpdateRequest.php +++ b/app/Api/V1/Requests/Models/Account/UpdateRequest.php @@ -95,24 +95,24 @@ class UpdateRequest extends FormRequest 'name' => sprintf('min:1|max:1024|uniqueAccountForUser:%d', $account->id), 'type' => sprintf('in:%s', $types), 'iban' => ['iban', 'nullable', new UniqueIban($account, $this->convertString('type'))], - 'bic' => 'bic|nullable', + 'bic' => ['bic', 'nullable'], 'account_number' => ['min:1', 'max:255', 'nullable', new UniqueAccountNumber($account, $this->convertString('type'))], - 'opening_balance' => 'numeric|required_with:opening_balance_date|nullable', - 'opening_balance_date' => 'date|required_with:opening_balance|nullable', - 'virtual_balance' => 'numeric|nullable', - 'order' => 'numeric|nullable', - 'currency_id' => 'numeric|exists:transaction_currencies,id', - 'currency_code' => 'min:3|max:51|exists:transaction_currencies,code', + 'opening_balance' => ['numeric', 'required_with:opening_balance_date', 'nullable'], + 'opening_balance_date' => ['date', 'required_with:opening_balance', 'nullable'], + 'virtual_balance' => ['numeric', 'nullable'], + 'order' => ['numeric', 'nullable'], + 'currency_id' => ['numeric', 'exists:transaction_currencies,id'], + 'currency_code' => ['min:3', 'max:51', 'exists:transaction_currencies,code'], 'active' => [new IsBoolean()], 'include_net_worth' => [new IsBoolean()], 'account_role' => sprintf('in:%s|nullable|required_if:type,asset', $accountRoles), 'credit_card_type' => sprintf('in:%s|nullable|required_if:account_role,ccAsset', $ccPaymentTypes), - 'monthly_payment_date' => 'date|nullable|required_if:account_role,ccAsset|required_if:credit_card_type,monthlyFull', - 'liability_type' => 'required_if:type,liability|in:loan,debt,mortgage', - 'liability_direction' => 'required_if:type,liability|in:credit,debit', - 'interest' => 'required_if:type,liability|min:0|max:100|numeric', - 'interest_period' => 'required_if:type,liability|in:daily,monthly,yearly', - 'notes' => 'min:0|max:32768', + 'monthly_payment_date' => ['date', 'nullable', 'required_if:account_role,ccAsset', 'required_if:credit_card_type,monthlyFull'], + 'liability_type' => ['required_if:type,liability', 'in:loan,debt,mortgage'], + 'liability_direction' => ['required_if:type,liability', 'in:credit,debit'], + 'interest' => ['required_if:type,liability', 'min:0', 'max:100', 'numeric'], + 'interest_period' => ['required_if:type,liability', 'in:daily,monthly,yearly'], + 'notes' => ['min:0', 'max:32768'], ]; return Location::requestRules($rules); diff --git a/app/Api/V1/Requests/Models/Attachment/StoreRequest.php b/app/Api/V1/Requests/Models/Attachment/StoreRequest.php index 1a8d617733..63fe2a69c6 100644 --- a/app/Api/V1/Requests/Models/Attachment/StoreRequest.php +++ b/app/Api/V1/Requests/Models/Attachment/StoreRequest.php @@ -64,9 +64,9 @@ class StoreRequest extends FormRequest $model = $this->convertString('attachable_type'); return [ - 'filename' => 'required|min:1|max:255', + 'filename' => ['required', 'min:1', 'max:255'], 'title' => ['min:1', 'max:255'], - 'notes' => 'min:1|max:32768', + 'notes' => ['min:1', 'max:32768'], 'attachable_type' => sprintf('required|in:%s', $models), 'attachable_id' => ['required', 'numeric', new IsValidAttachmentModel($model)], ]; diff --git a/app/Api/V1/Requests/Models/Attachment/UpdateRequest.php b/app/Api/V1/Requests/Models/Attachment/UpdateRequest.php index 9e302939e5..b230c226dc 100644 --- a/app/Api/V1/Requests/Models/Attachment/UpdateRequest.php +++ b/app/Api/V1/Requests/Models/Attachment/UpdateRequest.php @@ -68,7 +68,7 @@ class UpdateRequest extends FormRequest return [ 'filename' => ['min:1', 'max:255'], 'title' => ['min:1', 'max:255'], - 'notes' => 'min:1|max:32768', + 'notes' => ['min:1', 'max:32768'], 'attachable_type' => sprintf('in:%s', $models), 'attachable_id' => ['numeric', new IsValidAttachmentModel($model)], ]; diff --git a/app/Api/V1/Requests/Models/AvailableBudget/Request.php b/app/Api/V1/Requests/Models/AvailableBudget/Request.php index cfa1111115..14541253a8 100644 --- a/app/Api/V1/Requests/Models/AvailableBudget/Request.php +++ b/app/Api/V1/Requests/Models/AvailableBudget/Request.php @@ -65,11 +65,11 @@ class Request extends FormRequest public function rules(): array { return [ - 'currency_id' => 'numeric|exists:transaction_currencies,id', - 'currency_code' => 'min:3|max:51|exists:transaction_currencies,code', + 'currency_id' => ['numeric', 'exists:transaction_currencies,id'], + 'currency_code' => ['min:3', 'max:51', 'exists:transaction_currencies,code'], 'amount' => ['nullable', new IsValidPositiveAmount()], - 'start' => 'date|after:1970-01-02|before:2038-01-17', - 'end' => 'date|after:1970-01-02|before:2038-01-17', + 'start' => ['date', 'after:1970-01-02', 'before:2038-01-17'], + 'end' => ['date', 'after:1970-01-02', 'before:2038-01-17'], ]; } diff --git a/app/Api/V1/Requests/Models/Bill/StoreRequest.php b/app/Api/V1/Requests/Models/Bill/StoreRequest.php index 9adcdcac44..38e042d4e7 100644 --- a/app/Api/V1/Requests/Models/Bill/StoreRequest.php +++ b/app/Api/V1/Requests/Models/Bill/StoreRequest.php @@ -77,18 +77,18 @@ class StoreRequest extends FormRequest public function rules(): array { return [ - 'name' => 'min:1|max:255|uniqueObjectForUser:bills,name', + 'name' => ['min:1', 'max:255', 'uniqueObjectForUser:bills,name'], 'amount_min' => ['required', new IsValidPositiveAmount()], 'amount_max' => ['required', new IsValidPositiveAmount()], - 'currency_id' => 'numeric|exists:transaction_currencies,id', - 'currency_code' => 'min:3|max:51|exists:transaction_currencies,code', - 'date' => 'date|required|after:1970-01-02|before:2038-01-17', - 'end_date' => 'nullable|date|after:date|after:1970-01-02|before:2038-01-17', - 'extension_date' => 'nullable|date|after:date|after:1970-01-02|before:2038-01-17', - 'repeat_freq' => 'in:weekly,monthly,quarterly,half-year,yearly|required', - 'skip' => 'min:0|max:31|numeric', + 'currency_id' => ['numeric', 'exists:transaction_currencies,id'], + 'currency_code' => ['min:3', 'max:51', 'exists:transaction_currencies,code'], + 'date' => ['date', 'required', 'after:1970-01-02', 'before:2038-01-17'], + 'end_date' => ['nullable', 'date', 'after:date', 'after:1970-01-02', 'before:2038-01-17'], + 'extension_date' => ['nullable', 'date', 'after:date', 'after:1970-01-02', 'before:2038-01-17'], + 'repeat_freq' => ['in:weekly,monthly,quarterly,half-year,yearly', 'required'], + 'skip' => ['min:0', 'max:31', 'numeric'], 'active' => [new IsBoolean()], - 'notes' => 'nullable|min:1|max:32768', + 'notes' => ['nullable', 'min:1', 'max:32768'], ]; } diff --git a/app/Api/V1/Requests/Models/Bill/UpdateRequest.php b/app/Api/V1/Requests/Models/Bill/UpdateRequest.php index fd439d7439..6f2faab885 100644 --- a/app/Api/V1/Requests/Models/Bill/UpdateRequest.php +++ b/app/Api/V1/Requests/Models/Bill/UpdateRequest.php @@ -81,15 +81,15 @@ class UpdateRequest extends FormRequest 'name' => sprintf('min:1|max:255|uniqueObjectForUser:bills,name,%d', $bill->id), 'amount_min' => ['nullable', new IsValidPositiveAmount()], 'amount_max' => ['nullable', new IsValidPositiveAmount()], - 'currency_id' => 'numeric|exists:transaction_currencies,id', - 'currency_code' => 'min:3|max:51|exists:transaction_currencies,code', - 'date' => 'date|after:1970-01-02|before:2038-01-17', - 'end_date' => 'date|after:date|after:1970-01-02|before:2038-01-17', - 'extension_date' => 'date|after:date|after:1970-01-02|before:2038-01-17', + 'currency_id' => ['numeric', 'exists:transaction_currencies,id'], + 'currency_code' => ['min:3', 'max:51', 'exists:transaction_currencies,code'], + 'date' => ['date', 'after:1970-01-02', 'before:2038-01-17'], + 'end_date' => ['date', 'after:date', 'after:1970-01-02', 'before:2038-01-17'], + 'extension_date' => ['date', 'after:date', 'after:1970-01-02', 'before:2038-01-17'], 'repeat_freq' => 'in:weekly,monthly,quarterly,half-year,yearly', - 'skip' => 'min:0|max:31|numeric', + 'skip' => ['min:0', 'max:31', 'numeric'], 'active' => [new IsBoolean()], - 'notes' => 'min:1|max:32768', + 'notes' => ['min:1', 'max:32768'], ]; } diff --git a/app/Api/V1/Requests/Models/Budget/StoreRequest.php b/app/Api/V1/Requests/Models/Budget/StoreRequest.php index af5fd53580..dbae7bbf02 100644 --- a/app/Api/V1/Requests/Models/Budget/StoreRequest.php +++ b/app/Api/V1/Requests/Models/Budget/StoreRequest.php @@ -75,11 +75,11 @@ class StoreRequest extends FormRequest public function rules(): array { return [ - 'name' => 'required|min:1|max:255|uniqueObjectForUser:budgets,name', + 'name' => ['required', 'min:1', 'max:255', 'uniqueObjectForUser:budgets,name'], 'active' => [new IsBoolean()], 'currency_id' => 'exists:transaction_currencies,id', 'currency_code' => 'exists:transaction_currencies,code', - 'notes' => 'nullable|min:1|max:32768', + 'notes' => ['nullable', 'min:1', 'max:32768'], // auto budget info 'auto_budget_type' => 'in:reset,rollover,adjusted,none', 'auto_budget_amount' => [ @@ -88,7 +88,7 @@ class StoreRequest extends FormRequest 'required_if:auto_budget_type,adjusted', new IsValidPositiveAmount(), ], - 'auto_budget_period' => 'in:daily,weekly,monthly,quarterly,half_year,yearly|required_if:auto_budget_type,reset|required_if:auto_budget_type,rollover|required_if:auto_budget_type,adjusted', + 'auto_budget_period' => ['in:daily,weekly,monthly,quarterly,half_year,yearly', 'required_if:auto_budget_type,reset', 'required_if:auto_budget_type,rollover', 'required_if:auto_budget_type,adjusted'], // webhooks 'fire_webhooks' => [new IsBoolean()], diff --git a/app/Api/V1/Requests/Models/Budget/UpdateRequest.php b/app/Api/V1/Requests/Models/Budget/UpdateRequest.php index 6334bf8961..9f4d1be43a 100644 --- a/app/Api/V1/Requests/Models/Budget/UpdateRequest.php +++ b/app/Api/V1/Requests/Models/Budget/UpdateRequest.php @@ -85,7 +85,7 @@ class UpdateRequest extends FormRequest return [ 'name' => sprintf('min:1|max:100|uniqueObjectForUser:budgets,name,%d', $budget->id), 'active' => [new IsBoolean()], - 'notes' => 'nullable|min:1|max:32768', + 'notes' => ['nullable', 'min:1', 'max:32768'], 'auto_budget_type' => 'in:reset,rollover,adjusted,none', 'auto_budget_currency_id' => 'exists:transaction_currencies,id', 'auto_budget_currency_code' => 'exists:transaction_currencies,code', diff --git a/app/Api/V1/Requests/Models/BudgetLimit/StoreRequest.php b/app/Api/V1/Requests/Models/BudgetLimit/StoreRequest.php index 102e449fec..6703df8783 100644 --- a/app/Api/V1/Requests/Models/BudgetLimit/StoreRequest.php +++ b/app/Api/V1/Requests/Models/BudgetLimit/StoreRequest.php @@ -71,12 +71,12 @@ class StoreRequest extends FormRequest public function rules(): array { return [ - 'start' => 'required|before:end|date', - 'end' => 'required|after:start|date', + 'start' => ['required', 'before:end', 'date'], + 'end' => ['required', 'after:start', 'date'], 'amount' => ['required', new IsValidPositiveAmount()], - 'currency_id' => 'numeric|exists:transaction_currencies,id', - 'currency_code' => 'min:3|max:51|exists:transaction_currencies,code', - 'notes' => 'nullable|min:0|max:32768', + 'currency_id' => ['numeric', 'exists:transaction_currencies,id'], + 'currency_code' => ['min:3', 'max:51', 'exists:transaction_currencies,code'], + 'notes' => ['nullable', 'min:0', 'max:32768'], // webhooks 'fire_webhooks' => [new IsBoolean()], diff --git a/app/Api/V1/Requests/Models/BudgetLimit/UpdateRequest.php b/app/Api/V1/Requests/Models/BudgetLimit/UpdateRequest.php index 4d9cbb38be..3ed1e838c2 100644 --- a/app/Api/V1/Requests/Models/BudgetLimit/UpdateRequest.php +++ b/app/Api/V1/Requests/Models/BudgetLimit/UpdateRequest.php @@ -73,12 +73,12 @@ class UpdateRequest extends FormRequest public function rules(): array { return [ - 'start' => 'date|after:1970-01-02|before:2038-01-17', - 'end' => 'date|after:1970-01-02|before:2038-01-17', + 'start' => ['date', 'after:1970-01-02', 'before:2038-01-17'], + 'end' => ['date', 'after:1970-01-02', 'before:2038-01-17'], 'amount' => ['nullable', new IsValidPositiveAmount()], - 'currency_id' => 'numeric|exists:transaction_currencies,id', - 'currency_code' => 'min:3|max:51|exists:transaction_currencies,code', - 'notes' => 'nullable|min:0|max:32768', + 'currency_id' => ['numeric', 'exists:transaction_currencies,id'], + 'currency_code' => ['min:3', 'max:51', 'exists:transaction_currencies,code'], + 'notes' => ['nullable', 'min:0', 'max:32768'], // webhooks 'fire_webhooks' => [new IsBoolean()], diff --git a/app/Api/V1/Requests/Models/Category/StoreRequest.php b/app/Api/V1/Requests/Models/Category/StoreRequest.php index 72cf478cff..47d1991540 100644 --- a/app/Api/V1/Requests/Models/Category/StoreRequest.php +++ b/app/Api/V1/Requests/Models/Category/StoreRequest.php @@ -51,6 +51,6 @@ class StoreRequest extends FormRequest */ public function rules(): array { - return ['name' => 'required|min:1|max:100|uniqueObjectForUser:categories,name']; + return ['name' => ['required', 'min:1', 'max:100', 'uniqueObjectForUser:categories,name']]; } } diff --git a/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreByCurrenciesRequest.php b/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreByCurrenciesRequest.php index 62a8b6c350..ceb5730612 100644 --- a/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreByCurrenciesRequest.php +++ b/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreByCurrenciesRequest.php @@ -48,7 +48,7 @@ class StoreByCurrenciesRequest extends FormRequest */ public function rules(): array { - return ['*' => 'required|numeric|min:0.0000000001']; + return ['*' => ['required', 'numeric', 'min:0.0000000001']]; } public function withValidator(Validator $validator): void diff --git a/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreByDateRequest.php b/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreByDateRequest.php index a88987b120..2dbf6b0cbc 100644 --- a/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreByDateRequest.php +++ b/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreByDateRequest.php @@ -59,7 +59,7 @@ class StoreByDateRequest extends FormRequest */ public function rules(): array { - return ['from' => 'required|exists:transaction_currencies,code', 'rates' => 'required|array', 'rates.*' => 'required|numeric|min:0.0000000001']; + return ['from' => ['required', 'exists:transaction_currencies,code'], 'rates' => ['required', 'array'], 'rates.*' => ['required', 'numeric', 'min:0.0000000001']]; } public function withValidator(Validator $validator): void diff --git a/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreRequest.php b/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreRequest.php index 2bf14daa26..bad8b8b7e6 100644 --- a/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreRequest.php +++ b/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreRequest.php @@ -64,10 +64,10 @@ class StoreRequest extends FormRequest public function rules(): array { return [ - 'date' => 'required|date|after:1970-01-02|before:2038-01-17', - 'rate' => 'required|numeric|gt:0', - 'from' => 'required|exists:transaction_currencies,code', - 'to' => 'required|exists:transaction_currencies,code', + 'date' => ['required', 'date', 'after:1970-01-02', 'before:2038-01-17'], + 'rate' => ['required', 'numeric', 'gt:0'], + 'from' => ['required', 'exists:transaction_currencies,code'], + 'to' => ['required', 'exists:transaction_currencies,code'], ]; } } diff --git a/app/Api/V1/Requests/Models/CurrencyExchangeRate/UpdateRequest.php b/app/Api/V1/Requests/Models/CurrencyExchangeRate/UpdateRequest.php index 22426cec8b..2a92c35513 100644 --- a/app/Api/V1/Requests/Models/CurrencyExchangeRate/UpdateRequest.php +++ b/app/Api/V1/Requests/Models/CurrencyExchangeRate/UpdateRequest.php @@ -52,10 +52,10 @@ class UpdateRequest extends FormRequest public function rules(): array { return [ - 'date' => 'date|after:1970-01-02|before:2038-01-17', - 'rate' => 'required|numeric|gt:0', - 'from' => 'nullable|exists:transaction_currencies,code', - 'to' => 'nullable|exists:transaction_currencies,code', + 'date' => ['date', 'after:1970-01-02', 'before:2038-01-17'], + 'rate' => ['required', 'numeric', 'gt:0'], + 'from' => ['nullable', 'exists:transaction_currencies,code'], + 'to' => ['nullable', 'exists:transaction_currencies,code'], ]; } } diff --git a/app/Api/V1/Requests/Models/PiggyBank/StoreRequest.php b/app/Api/V1/Requests/Models/PiggyBank/StoreRequest.php index b16c4fa09a..e93e708401 100644 --- a/app/Api/V1/Requests/Models/PiggyBank/StoreRequest.php +++ b/app/Api/V1/Requests/Models/PiggyBank/StoreRequest.php @@ -71,18 +71,18 @@ class StoreRequest extends FormRequest public function rules(): array { return [ - 'name' => 'required|min:1|max:255|uniquePiggyBankForUser', + 'name' => ['required', 'min:1', 'max:255', 'uniquePiggyBankForUser'], 'accounts' => 'required', - 'accounts.*' => 'array|required', - 'accounts.*.account_id' => 'required|numeric|belongsToUser:accounts,id', + 'accounts.*' => ['array', 'required'], + 'accounts.*.account_id' => ['required', 'numeric', 'belongsToUser:accounts,id'], 'accounts.*.current_amount' => ['numeric', new IsValidZeroOrMoreAmount()], - 'object_group_id' => 'numeric|belongsToUser:object_groups,id', + 'object_group_id' => ['numeric', 'belongsToUser:object_groups,id'], 'object_group_title' => ['min:1', 'max:255'], 'target_amount' => ['required', new IsValidZeroOrMoreAmount()], - 'start_date' => 'required|date|after:1970-01-01|before:2038-01-17', - 'transaction_currency_id' => 'exists:transaction_currencies,id|required_without:transaction_currency_code', - 'transaction_currency_code' => 'exists:transaction_currencies,code|required_without:transaction_currency_id', - 'target_date' => 'date|nullable|after:start_date', + 'start_date' => ['required', 'date', 'after:1970-01-01', 'before:2038-01-17'], + 'transaction_currency_id' => ['exists:transaction_currencies,id', 'required_without:transaction_currency_code'], + 'transaction_currency_code' => ['exists:transaction_currencies,code', 'required_without:transaction_currency_id'], + 'target_date' => ['date', 'nullable', 'after:start_date'], 'notes' => 'max:65000', ]; } diff --git a/app/Api/V1/Requests/Models/PiggyBank/UpdateRequest.php b/app/Api/V1/Requests/Models/PiggyBank/UpdateRequest.php index 7f46f1ee18..f7fe234148 100644 --- a/app/Api/V1/Requests/Models/PiggyBank/UpdateRequest.php +++ b/app/Api/V1/Requests/Models/PiggyBank/UpdateRequest.php @@ -79,17 +79,17 @@ class UpdateRequest extends FormRequest 'name' => 'min:1|max:255|uniquePiggyBankForUser:'.$piggyBank->id, 'current_amount' => ['nullable', new LessThanPiggyTarget(), new IsValidPositiveAmount()], 'target_amount' => ['nullable', new IsValidZeroOrMoreAmount()], - 'start_date' => 'date|nullable', - 'target_date' => 'date|nullable|after:start_date', + 'start_date' => ['date', 'nullable'], + 'target_date' => ['date', 'nullable', 'after:start_date'], 'notes' => 'max:65000', 'accounts' => 'array', 'accounts.*' => 'array', 'accounts.*.account_id' => ['required', 'numeric', 'belongsToUser:accounts,id'], 'accounts.*.current_amount' => ['numeric', 'nullable', new IsValidZeroOrMoreAmount(true), new IsEnoughInAccounts($piggyBank, $this->getAll())], - 'object_group_id' => 'numeric|belongsToUser:object_groups,id', + 'object_group_id' => ['numeric', 'belongsToUser:object_groups,id'], 'object_group_title' => ['min:1', 'max:255'], - 'transaction_currency_id' => 'exists:transaction_currencies,id|nullable', - 'transaction_currency_code' => 'exists:transaction_currencies,code|nullable', + 'transaction_currency_id' => ['exists:transaction_currencies,id', 'nullable'], + 'transaction_currency_code' => ['exists:transaction_currencies,code', 'nullable'], ]; } } diff --git a/app/Api/V1/Requests/Models/Recurrence/StoreRequest.php b/app/Api/V1/Requests/Models/Recurrence/StoreRequest.php index 82877be8ef..ac4999f843 100644 --- a/app/Api/V1/Requests/Models/Recurrence/StoreRequest.php +++ b/app/Api/V1/Requests/Models/Recurrence/StoreRequest.php @@ -78,40 +78,40 @@ class StoreRequest extends FormRequest public function rules(): array { return [ - 'type' => 'required|in:withdrawal,transfer,deposit', - 'title' => 'required|min:1|max:255|uniqueObjectForUser:recurrences,title', - 'description' => 'min:1|max:32768', - 'first_date' => 'required|date', + 'type' => ['required', 'in:withdrawal,transfer,deposit'], + 'title' => ['required', 'min:1', 'max:255', 'uniqueObjectForUser:recurrences,title'], + 'description' => ['min:1', 'max:32768'], + 'first_date' => ['required', 'date'], 'apply_rules' => [new IsBoolean()], 'active' => [new IsBoolean()], - 'repeat_until' => 'nullable|date', - 'nr_of_repetitions' => 'nullable|numeric|min:1|max:31', + 'repeat_until' => ['nullable', 'date'], + 'nr_of_repetitions' => ['nullable', 'numeric', 'min:1', 'max:31'], - 'repetitions.*.type' => 'required|in:daily,weekly,ndom,monthly,yearly', - 'repetitions.*.moment' => 'min:0|max:10', - 'repetitions.*.skip' => 'nullable|numeric|min:0|max:31', - 'repetitions.*.weekend' => 'numeric|min:1|max:4', + 'repetitions.*.type' => ['required', 'in:daily,weekly,ndom,monthly,yearly'], + 'repetitions.*.moment' => ['min:0', 'max:10'], + 'repetitions.*.skip' => ['nullable', 'numeric', 'min:0', 'max:31'], + 'repetitions.*.weekend' => ['numeric', 'min:1', 'max:4'], - 'transactions.*.description' => 'required|min:1|max:255', + 'transactions.*.description' => ['required', 'min:1', 'max:255'], 'transactions.*.amount' => ['required', new IsValidPositiveAmount()], 'transactions.*.foreign_amount' => ['nullable', new IsValidPositiveAmount()], - 'transactions.*.currency_id' => 'nullable|numeric|exists:transaction_currencies,id', - 'transactions.*.currency_code' => 'nullable|min:3|max:51|exists:transaction_currencies,code', - 'transactions.*.foreign_currency_id' => 'nullable|numeric|exists:transaction_currencies,id', - 'transactions.*.foreign_currency_code' => 'nullable|min:3|max:51|exists:transaction_currencies,code', + 'transactions.*.currency_id' => ['nullable', 'numeric', 'exists:transaction_currencies,id'], + 'transactions.*.currency_code' => ['nullable', 'min:3', 'max:51', 'exists:transaction_currencies,code'], + 'transactions.*.foreign_currency_id' => ['nullable', 'numeric', 'exists:transaction_currencies,id'], + 'transactions.*.foreign_currency_code' => ['nullable', 'min:3', 'max:51', 'exists:transaction_currencies,code'], 'transactions.*.source_id' => ['numeric', 'nullable', new BelongsUser()], - 'transactions.*.source_name' => 'min:1|max:255|nullable', + 'transactions.*.source_name' => ['min:1', 'max:255', 'nullable'], 'transactions.*.destination_id' => ['numeric', 'nullable', new BelongsUser()], - 'transactions.*.destination_name' => 'min:1|max:255|nullable', + 'transactions.*.destination_name' => ['min:1', 'max:255', 'nullable'], // new and updated fields: 'transactions.*.budget_id' => ['nullable', 'mustExist:budgets,id', new BelongsUser()], 'transactions.*.budget_name' => ['min:1', 'max:255', 'nullable', new BelongsUser()], 'transactions.*.category_id' => ['nullable', 'mustExist:categories,id', new BelongsUser()], - 'transactions.*.category_name' => 'min:1|max:255|nullable', + 'transactions.*.category_name' => ['min:1', 'max:255', 'nullable'], 'transactions.*.piggy_bank_id' => ['nullable', 'numeric', 'mustExist:piggy_banks,id', new BelongsUser()], 'transactions.*.piggy_bank_name' => ['min:1', 'max:255', 'nullable', new BelongsUser()], - 'transactions.*.tags' => 'nullable|min:1|max:255', + 'transactions.*.tags' => ['nullable', 'min:1', 'max:255'], ]; } diff --git a/app/Api/V1/Requests/Models/Recurrence/UpdateRequest.php b/app/Api/V1/Requests/Models/Recurrence/UpdateRequest.php index 27c6a50f44..7004db0a4d 100644 --- a/app/Api/V1/Requests/Models/Recurrence/UpdateRequest.php +++ b/app/Api/V1/Requests/Models/Recurrence/UpdateRequest.php @@ -89,38 +89,38 @@ class UpdateRequest extends FormRequest return [ 'title' => sprintf('min:1|max:255|uniqueObjectForUser:recurrences,title,%d', $recurrence->id), - 'description' => 'min:1|max:32768', - 'first_date' => 'date|after:1970-01-02|before:2038-01-17', + 'description' => ['min:1', 'max:32768'], + 'first_date' => ['date', 'after:1970-01-02', 'before:2038-01-17'], 'apply_rules' => [new IsBoolean()], 'active' => [new IsBoolean()], - 'repeat_until' => 'nullable|date', - 'nr_of_repetitions' => 'nullable|numeric|min:1|max:31', + 'repeat_until' => ['nullable', 'date'], + 'nr_of_repetitions' => ['nullable', 'numeric', 'min:1', 'max:31'], 'repetitions.*.type' => 'in:daily,weekly,ndom,monthly,yearly', - 'repetitions.*.moment' => 'min:0|max:10|numeric', - 'repetitions.*.skip' => 'nullable|numeric|min:0|max:31', - 'repetitions.*.weekend' => 'nullable|numeric|min:1|max:4', + 'repetitions.*.moment' => ['min:0', 'max:10', 'numeric'], + 'repetitions.*.skip' => ['nullable', 'numeric', 'min:0', 'max:31'], + 'repetitions.*.weekend' => ['nullable', 'numeric', 'min:1', 'max:4'], 'transactions.*.description' => ['min:1', 'max:255'], 'transactions.*.amount' => [new IsValidPositiveAmount()], 'transactions.*.foreign_amount' => ['nullable', new IsValidPositiveAmount()], - 'transactions.*.currency_id' => 'nullable|numeric|exists:transaction_currencies,id', - 'transactions.*.currency_code' => 'nullable|min:3|max:51|exists:transaction_currencies,code', - 'transactions.*.foreign_currency_id' => 'nullable|numeric|exists:transaction_currencies,id', - 'transactions.*.foreign_currency_code' => 'nullable|min:3|max:51|exists:transaction_currencies,code', + 'transactions.*.currency_id' => ['nullable', 'numeric', 'exists:transaction_currencies,id'], + 'transactions.*.currency_code' => ['nullable', 'min:3', 'max:51', 'exists:transaction_currencies,code'], + 'transactions.*.foreign_currency_id' => ['nullable', 'numeric', 'exists:transaction_currencies,id'], + 'transactions.*.foreign_currency_code' => ['nullable', 'min:3', 'max:51', 'exists:transaction_currencies,code'], 'transactions.*.source_id' => ['numeric', 'nullable', new BelongsUser()], - 'transactions.*.source_name' => 'min:1|max:255|nullable', + 'transactions.*.source_name' => ['min:1', 'max:255', 'nullable'], 'transactions.*.destination_id' => ['numeric', 'nullable', new BelongsUser()], - 'transactions.*.destination_name' => 'min:1|max:255|nullable', + 'transactions.*.destination_name' => ['min:1', 'max:255', 'nullable'], // new and updated fields: 'transactions.*.budget_id' => ['nullable', 'mustExist:budgets,id', new BelongsUser()], 'transactions.*.budget_name' => ['min:1', 'max:255', 'nullable', new BelongsUser()], 'transactions.*.category_id' => ['nullable', 'mustExist:categories,id', new BelongsUser()], - 'transactions.*.category_name' => 'min:1|max:255|nullable', + 'transactions.*.category_name' => ['min:1', 'max:255', 'nullable'], 'transactions.*.piggy_bank_id' => ['nullable', 'numeric', 'mustExist:piggy_banks,id', new BelongsUser()], 'transactions.*.piggy_bank_name' => ['min:1', 'max:255', 'nullable', new BelongsUser()], - 'transactions.*.tags' => 'nullable|min:1|max:255', + 'transactions.*.tags' => ['nullable', 'min:1', 'max:255'], ]; } diff --git a/app/Api/V1/Requests/Models/Rule/StoreRequest.php b/app/Api/V1/Requests/Models/Rule/StoreRequest.php index 02a1167d04..d26ef8b8a5 100644 --- a/app/Api/V1/Requests/Models/Rule/StoreRequest.php +++ b/app/Api/V1/Requests/Models/Rule/StoreRequest.php @@ -80,11 +80,11 @@ class StoreRequest extends FormRequest $contextActions = implode(',', config('firefly.context-rule-actions')); return [ - 'title' => 'required|min:1|max:100|uniqueObjectForUser:rules,title', - 'description' => 'min:1|max:32768|nullable', - 'rule_group_id' => 'belongsToUser:rule_groups|required_without:rule_group_title', - 'rule_group_title' => 'nullable|min:1|max:255|required_without:rule_group_id|belongsToUser:rule_groups,title', - 'trigger' => 'required|in:store-journal,update-journal,manual-activation', + 'title' => ['required', 'min:1', 'max:100', 'uniqueObjectForUser:rules,title'], + 'description' => ['min:1', 'max:32768', 'nullable'], + 'rule_group_id' => ['belongsToUser:rule_groups', 'required_without:rule_group_title'], + 'rule_group_title' => ['nullable', 'min:1', 'max:255', 'required_without:rule_group_id', 'belongsToUser:rule_groups,title'], + 'trigger' => ['required', 'in:store-journal,update-journal,manual-activation'], 'triggers.*.type' => 'required|in:'.implode(',', $validTriggers), 'triggers.*.value' => 'required_if:actions.*.type,'.$contextTriggers.'|min:1|ruleTriggerValue|max:1024', 'triggers.*.stop_processing' => [new IsBoolean()], diff --git a/app/Api/V1/Requests/Models/Rule/TestRequest.php b/app/Api/V1/Requests/Models/Rule/TestRequest.php index 91c2d62e08..5565946dc6 100644 --- a/app/Api/V1/Requests/Models/Rule/TestRequest.php +++ b/app/Api/V1/Requests/Models/Rule/TestRequest.php @@ -47,10 +47,10 @@ class TestRequest extends FormRequest public function rules(): array { return [ - 'start' => 'date|after:1970-01-02|before:2038-01-17', - 'end' => 'date|after_or_equal:start|after:1970-01-02|before:2038-01-17', + 'start' => ['date', 'after:1970-01-02', 'before:2038-01-17'], + 'end' => ['date', 'after_or_equal:start', 'after:1970-01-02', 'before:2038-01-17'], 'accounts' => '', - 'accounts.*' => 'required|exists:accounts,id|belongsToUser:accounts', + 'accounts.*' => ['required', 'exists:accounts,id', 'belongsToUser:accounts'], ]; } diff --git a/app/Api/V1/Requests/Models/Rule/TriggerRequest.php b/app/Api/V1/Requests/Models/Rule/TriggerRequest.php index 2b57bd910c..13f623fdc4 100644 --- a/app/Api/V1/Requests/Models/Rule/TriggerRequest.php +++ b/app/Api/V1/Requests/Models/Rule/TriggerRequest.php @@ -47,10 +47,10 @@ class TriggerRequest extends FormRequest public function rules(): array { return [ - 'start' => 'date|after:1970-01-02|before:2038-01-17', - 'end' => 'date|after_or_equal:start|after:1970-01-02|before:2038-01-17', + 'start' => ['date', 'after:1970-01-02', 'before:2038-01-17'], + 'end' => ['date', 'after_or_equal:start', 'after:1970-01-02', 'before:2038-01-17'], 'accounts' => '', - 'accounts.*' => 'exists:accounts,id|belongsToUser:accounts', + 'accounts.*' => ['exists:accounts,id', 'belongsToUser:accounts'], ]; } diff --git a/app/Api/V1/Requests/Models/Rule/UpdateRequest.php b/app/Api/V1/Requests/Models/Rule/UpdateRequest.php index eedf72d327..f835e87098 100644 --- a/app/Api/V1/Requests/Models/Rule/UpdateRequest.php +++ b/app/Api/V1/Requests/Models/Rule/UpdateRequest.php @@ -91,9 +91,9 @@ class UpdateRequest extends FormRequest return [ 'title' => sprintf('min:1|max:100|uniqueObjectForUser:rules,title,%d', $rule->id), - 'description' => 'min:1|max:32768|nullable', + 'description' => ['min:1', 'max:32768', 'nullable'], 'rule_group_id' => 'belongsToUser:rule_groups', - 'rule_group_title' => 'nullable|min:1|max:255|belongsToUser:rule_groups,title', + 'rule_group_title' => ['nullable', 'min:1', 'max:255', 'belongsToUser:rule_groups,title'], 'trigger' => 'in:store-journal,update-journal,manual-activation', 'triggers.*.type' => 'required|in:'.implode(',', $validTriggers), 'triggers.*.value' => 'required_if:actions.*.type,'.$contextTriggers.'|min:1|ruleTriggerValue|max:1024', @@ -106,7 +106,7 @@ class UpdateRequest extends FormRequest 'strict' => [new IsBoolean()], 'stop_processing' => [new IsBoolean()], 'active' => [new IsBoolean()], - 'order' => 'numeric|min:1|max:2048', + 'order' => ['numeric', 'min:1', 'max:2048'], ]; } diff --git a/app/Api/V1/Requests/Models/RuleGroup/StoreRequest.php b/app/Api/V1/Requests/Models/RuleGroup/StoreRequest.php index f3a6ac210b..9fad816d27 100644 --- a/app/Api/V1/Requests/Models/RuleGroup/StoreRequest.php +++ b/app/Api/V1/Requests/Models/RuleGroup/StoreRequest.php @@ -67,8 +67,8 @@ class StoreRequest extends FormRequest public function rules(): array { return [ - 'title' => 'required|min:1|max:100|uniqueObjectForUser:rule_groups,title', - 'description' => 'min:1|max:32768|nullable', + 'title' => ['required', 'min:1', 'max:100', 'uniqueObjectForUser:rule_groups,title'], + 'description' => ['min:1', 'max:32768', 'nullable'], 'active' => [new IsBoolean()], ]; } diff --git a/app/Api/V1/Requests/Models/RuleGroup/TestRequest.php b/app/Api/V1/Requests/Models/RuleGroup/TestRequest.php index 780d858926..466b6a6f3b 100644 --- a/app/Api/V1/Requests/Models/RuleGroup/TestRequest.php +++ b/app/Api/V1/Requests/Models/RuleGroup/TestRequest.php @@ -47,10 +47,10 @@ class TestRequest extends FormRequest public function rules(): array { return [ - 'start' => 'date|after:1970-01-02|before:2038-01-17', - 'end' => 'date|after_or_equal:start|after:1970-01-02|before:2038-01-17', + 'start' => ['date', 'after:1970-01-02', 'before:2038-01-17'], + 'end' => ['date', 'after_or_equal:start', 'after:1970-01-02', 'before:2038-01-17'], 'accounts' => '', - 'accounts.*' => 'exists:accounts,id|belongsToUser:accounts', + 'accounts.*' => ['exists:accounts,id', 'belongsToUser:accounts'], ]; } diff --git a/app/Api/V1/Requests/Models/RuleGroup/TriggerRequest.php b/app/Api/V1/Requests/Models/RuleGroup/TriggerRequest.php index 776c704eaa..8bbe4f8383 100644 --- a/app/Api/V1/Requests/Models/RuleGroup/TriggerRequest.php +++ b/app/Api/V1/Requests/Models/RuleGroup/TriggerRequest.php @@ -46,7 +46,7 @@ class TriggerRequest extends FormRequest public function rules(): array { - return ['start' => 'date|after:1970-01-02|before:2038-01-17', 'end' => 'date|after_or_equal:start|after:1970-01-02|before:2038-01-17']; + return ['start' => ['date', 'after:1970-01-02', 'before:2038-01-17'], 'end' => ['date', 'after_or_equal:start', 'after:1970-01-02', 'before:2038-01-17']]; } private function getAccounts(): array diff --git a/app/Api/V1/Requests/Models/RuleGroup/UpdateRequest.php b/app/Api/V1/Requests/Models/RuleGroup/UpdateRequest.php index e660feef20..33c737f1b6 100644 --- a/app/Api/V1/Requests/Models/RuleGroup/UpdateRequest.php +++ b/app/Api/V1/Requests/Models/RuleGroup/UpdateRequest.php @@ -66,7 +66,7 @@ class UpdateRequest extends FormRequest return [ 'title' => 'min:1|max:100|uniqueObjectForUser:rule_groups,title,'.$ruleGroup->id, - 'description' => 'min:1|max:32768|nullable', + 'description' => ['min:1', 'max:32768', 'nullable'], 'active' => [new IsBoolean()], ]; } diff --git a/app/Api/V1/Requests/Models/Tag/StoreRequest.php b/app/Api/V1/Requests/Models/Tag/StoreRequest.php index 1e46339206..70d773e106 100644 --- a/app/Api/V1/Requests/Models/Tag/StoreRequest.php +++ b/app/Api/V1/Requests/Models/Tag/StoreRequest.php @@ -62,9 +62,9 @@ class StoreRequest extends FormRequest public function rules(): array { $rules = [ - 'tag' => 'required|min:1|uniqueObjectForUser:tags,tag|max:1024', - 'description' => 'min:1|nullable|max:32768', - 'date' => 'date|nullable|after:1970-01-02|before:2038-01-17', + 'tag' => ['required', 'min:1', 'uniqueObjectForUser:tags,tag', 'max:1024'], + 'description' => ['min:1', 'nullable', 'max:32768'], + 'date' => ['date', 'nullable', 'after:1970-01-02', 'before:2038-01-17'], ]; return Location::requestRules($rules); diff --git a/app/Api/V1/Requests/Models/Tag/UpdateRequest.php b/app/Api/V1/Requests/Models/Tag/UpdateRequest.php index 84974c3ca3..c5deb1b95f 100644 --- a/app/Api/V1/Requests/Models/Tag/UpdateRequest.php +++ b/app/Api/V1/Requests/Models/Tag/UpdateRequest.php @@ -63,8 +63,8 @@ class UpdateRequest extends FormRequest $tag = $this->route()->parameter('tagOrId'); $rules = [ 'tag' => 'min:1|max:1024|uniqueObjectForUser:tags,tag,'.$tag->id, - 'description' => 'min:1|nullable|max:32768', - 'date' => 'date|nullable|after:1970-01-02|before:2038-01-17', + 'description' => ['min:1', 'nullable', 'max:32768'], + 'date' => ['date', 'nullable', 'after:1970-01-02', 'before:2038-01-17'], ]; return Location::requestRules($rules); diff --git a/app/Api/V1/Requests/Models/Transaction/StoreRequest.php b/app/Api/V1/Requests/Models/Transaction/StoreRequest.php index f42b34ac06..3287c2b678 100644 --- a/app/Api/V1/Requests/Models/Transaction/StoreRequest.php +++ b/app/Api/V1/Requests/Models/Transaction/StoreRequest.php @@ -86,7 +86,7 @@ class StoreRequest extends FormRequest return [ // basic fields for group: - 'group_title' => 'min:1|max:1000|nullable', + 'group_title' => ['min:1', 'max:1000', 'nullable'], 'error_if_duplicate_hash' => [new IsBoolean()], 'fire_webhooks' => [new IsBoolean()], 'apply_rules' => [new IsBoolean()], @@ -97,42 +97,42 @@ class StoreRequest extends FormRequest 'transactions.*.zoom_level' => $locationRules['zoom_level'], // transaction rules (in array for splits): - 'transactions.*.type' => 'required|in:withdrawal,deposit,transfer,opening-balance,reconciliation', + 'transactions.*.type' => ['required', 'in:withdrawal,deposit,transfer,opening-balance,reconciliation'], 'transactions.*.date' => ['required', new IsDateOrTime()], - 'transactions.*.order' => 'numeric|min:0', + 'transactions.*.order' => ['numeric', 'min:0'], // currency info - 'transactions.*.currency_id' => 'numeric|exists:transaction_currencies,id|nullable', - 'transactions.*.currency_code' => 'min:3|max:51|exists:transaction_currencies,code|nullable', - 'transactions.*.foreign_currency_id' => 'numeric|exists:transaction_currencies,id|nullable', - 'transactions.*.foreign_currency_code' => 'min:3|max:51|exists:transaction_currencies,code|nullable', + 'transactions.*.currency_id' => ['numeric', 'exists:transaction_currencies,id', 'nullable'], + 'transactions.*.currency_code' => ['min:3', 'max:51', 'exists:transaction_currencies,code', 'nullable'], + 'transactions.*.foreign_currency_id' => ['numeric', 'exists:transaction_currencies,id', 'nullable'], + 'transactions.*.foreign_currency_code' => ['min:3', 'max:51', 'exists:transaction_currencies,code', 'nullable'], // amount 'transactions.*.amount' => ['required', new IsValidPositiveAmount()], 'transactions.*.foreign_amount' => ['nullable', new IsValidZeroOrMoreAmount()], // description - 'transactions.*.description' => 'nullable|min:1|max:1000', + 'transactions.*.description' => ['nullable', 'min:1', 'max:1000'], // source of transaction 'transactions.*.source_id' => ['numeric', 'nullable', new BelongsUser()], - 'transactions.*.source_name' => 'min:1|max:255|nullable', - 'transactions.*.source_iban' => 'min:1|max:255|nullable|iban', - 'transactions.*.source_number' => 'min:1|max:255|nullable', - 'transactions.*.source_bic' => 'min:1|max:255|nullable|bic', + 'transactions.*.source_name' => ['min:1', 'max:255', 'nullable'], + 'transactions.*.source_iban' => ['min:1', 'max:255', 'nullable', 'iban'], + 'transactions.*.source_number' => ['min:1', 'max:255', 'nullable'], + 'transactions.*.source_bic' => ['min:1', 'max:255', 'nullable', 'bic'], // destination of transaction 'transactions.*.destination_id' => ['numeric', 'nullable', new BelongsUser()], - 'transactions.*.destination_name' => 'min:1|max:255|nullable', - 'transactions.*.destination_iban' => 'min:1|max:255|nullable|iban', - 'transactions.*.destination_number' => 'min:1|max:255|nullable', - 'transactions.*.destination_bic' => 'min:1|max:255|nullable|bic', + 'transactions.*.destination_name' => ['min:1', 'max:255', 'nullable'], + 'transactions.*.destination_iban' => ['min:1', 'max:255', 'nullable', 'iban'], + 'transactions.*.destination_number' => ['min:1', 'max:255', 'nullable'], + 'transactions.*.destination_bic' => ['min:1', 'max:255', 'nullable', 'bic'], // budget, category, bill and piggy 'transactions.*.budget_id' => ['mustExist:budgets,id', new BelongsUser()], 'transactions.*.budget_name' => ['min:1', 'max:255', 'nullable', new BelongsUser()], 'transactions.*.category_id' => ['mustExist:categories,id', new BelongsUser(), 'nullable'], - 'transactions.*.category_name' => 'min:1|max:255|nullable', + 'transactions.*.category_name' => ['min:1', 'max:255', 'nullable'], 'transactions.*.bill_id' => ['numeric', 'nullable', 'mustExist:bills,id', new BelongsUser()], 'transactions.*.bill_name' => ['min:1', 'max:255', 'nullable', new BelongsUser()], 'transactions.*.piggy_bank_id' => ['numeric', 'nullable', 'mustExist:piggy_banks,id', new BelongsUser()], @@ -140,34 +140,34 @@ class StoreRequest extends FormRequest // other interesting fields 'transactions.*.reconciled' => [new IsBoolean()], - 'transactions.*.notes' => 'min:1|max:32768|nullable', - 'transactions.*.tags' => 'min:0|max:255', - 'transactions.*.tags.*' => 'min:0|max:255', + 'transactions.*.notes' => ['min:1', 'max:32768', 'nullable'], + 'transactions.*.tags' => ['min:0', 'max:255'], + 'transactions.*.tags.*' => ['min:0', 'max:255'], // meta info fields - 'transactions.*.internal_reference' => 'min:1|max:255|nullable', - 'transactions.*.external_id' => 'min:1|max:255|nullable', - 'transactions.*.recurrence_id' => 'min:1|max:255|nullable', - 'transactions.*.bunq_payment_id' => 'min:1|max:255|nullable', + 'transactions.*.internal_reference' => ['min:1', 'max:255', 'nullable'], + 'transactions.*.external_id' => ['min:1', 'max:255', 'nullable'], + 'transactions.*.recurrence_id' => ['min:1', 'max:255', 'nullable'], + 'transactions.*.bunq_payment_id' => ['min:1', 'max:255', 'nullable'], 'transactions.*.external_url' => sprintf('min:1|max:255|nullable|url:%s', $validProtocols), // SEPA fields: - 'transactions.*.sepa_cc' => 'min:1|max:255|nullable', - 'transactions.*.sepa_ct_op' => 'min:1|max:255|nullable', - 'transactions.*.sepa_ct_id' => 'min:1|max:255|nullable', - 'transactions.*.sepa_db' => 'min:1|max:255|nullable', - 'transactions.*.sepa_country' => 'min:1|max:255|nullable', - 'transactions.*.sepa_ep' => 'min:1|max:255|nullable', - 'transactions.*.sepa_ci' => 'min:1|max:255|nullable', - 'transactions.*.sepa_batch_id' => 'min:1|max:255|nullable', + 'transactions.*.sepa_cc' => ['min:1', 'max:255', 'nullable'], + 'transactions.*.sepa_ct_op' => ['min:1', 'max:255', 'nullable'], + 'transactions.*.sepa_ct_id' => ['min:1', 'max:255', 'nullable'], + 'transactions.*.sepa_db' => ['min:1', 'max:255', 'nullable'], + 'transactions.*.sepa_country' => ['min:1', 'max:255', 'nullable'], + 'transactions.*.sepa_ep' => ['min:1', 'max:255', 'nullable'], + 'transactions.*.sepa_ci' => ['min:1', 'max:255', 'nullable'], + 'transactions.*.sepa_batch_id' => ['min:1', 'max:255', 'nullable'], // dates - 'transactions.*.interest_date' => 'date|nullable|after:1970-01-02|before:2038-01-17', - 'transactions.*.book_date' => 'date|nullable|after:1970-01-02|before:2038-01-17', - 'transactions.*.process_date' => 'date|nullable|after:1970-01-02|before:2038-01-17', - 'transactions.*.due_date' => 'date|nullable|after:1970-01-02|before:2038-01-17', - 'transactions.*.payment_date' => 'date|nullable|after:1970-01-02|before:2038-01-17', - 'transactions.*.invoice_date' => 'date|nullable|after:1970-01-02|before:2038-01-17', + 'transactions.*.interest_date' => ['date', 'nullable', 'after:1970-01-02', 'before:2038-01-17'], + 'transactions.*.book_date' => ['date', 'nullable', 'after:1970-01-02', 'before:2038-01-17'], + 'transactions.*.process_date' => ['date', 'nullable', 'after:1970-01-02', 'before:2038-01-17'], + 'transactions.*.due_date' => ['date', 'nullable', 'after:1970-01-02', 'before:2038-01-17'], + 'transactions.*.payment_date' => ['date', 'nullable', 'after:1970-01-02', 'before:2038-01-17'], + 'transactions.*.invoice_date' => ['date', 'nullable', 'after:1970-01-02', 'before:2038-01-17'], ]; } diff --git a/app/Api/V1/Requests/Models/Transaction/UpdateRequest.php b/app/Api/V1/Requests/Models/Transaction/UpdateRequest.php index c703c2deef..d8efbfc330 100644 --- a/app/Api/V1/Requests/Models/Transaction/UpdateRequest.php +++ b/app/Api/V1/Requests/Models/Transaction/UpdateRequest.php @@ -145,76 +145,76 @@ class UpdateRequest extends FormRequest return [ // basic fields for group: - 'group_title' => 'min:1|max:1000|nullable', + 'group_title' => ['min:1', 'max:1000', 'nullable'], 'apply_rules' => [new IsBoolean()], // transaction rules (in array for splits): 'transactions.*.type' => 'in:withdrawal,deposit,transfer,opening-balance,reconciliation', 'transactions.*.date' => [new IsDateOrTime()], - 'transactions.*.order' => 'numeric|min:0', + 'transactions.*.order' => ['numeric', 'min:0'], // group id: 'transactions.*.transaction_journal_id' => ['nullable', 'numeric', new BelongsUser()], // currency info - 'transactions.*.currency_id' => 'numeric|exists:transaction_currencies,id|nullable', - 'transactions.*.currency_code' => 'min:3|max:51|exists:transaction_currencies,code|nullable', - 'transactions.*.foreign_currency_id' => 'nullable|numeric|exists:transaction_currencies,id', - 'transactions.*.foreign_currency_code' => 'nullable|min:3|max:51|exists:transaction_currencies,code', + 'transactions.*.currency_id' => ['numeric', 'exists:transaction_currencies,id', 'nullable'], + 'transactions.*.currency_code' => ['min:3', 'max:51', 'exists:transaction_currencies,code', 'nullable'], + 'transactions.*.foreign_currency_id' => ['nullable', 'numeric', 'exists:transaction_currencies,id'], + 'transactions.*.foreign_currency_code' => ['nullable', 'min:3', 'max:51', 'exists:transaction_currencies,code'], // amount 'transactions.*.amount' => [new IsValidPositiveAmount()], 'transactions.*.foreign_amount' => ['nullable', new IsValidZeroOrMoreAmount()], // description - 'transactions.*.description' => 'nullable|min:1|max:1000', + 'transactions.*.description' => ['nullable', 'min:1', 'max:1000'], // source of transaction 'transactions.*.source_id' => ['numeric', 'nullable', new BelongsUser()], - 'transactions.*.source_name' => 'min:1|max:255|nullable', + 'transactions.*.source_name' => ['min:1', 'max:255', 'nullable'], // destination of transaction 'transactions.*.destination_id' => ['numeric', 'nullable', new BelongsUser()], - 'transactions.*.destination_name' => 'min:1|max:255|nullable', + 'transactions.*.destination_name' => ['min:1', 'max:255', 'nullable'], // budget, category, bill and piggy 'transactions.*.budget_id' => ['mustExist:budgets,id', new BelongsUser(), 'nullable'], 'transactions.*.budget_name' => ['min:1', 'max:255', 'nullable', new BelongsUser()], 'transactions.*.category_id' => ['mustExist:categories,id', new BelongsUser(), 'nullable'], - 'transactions.*.category_name' => 'min:1|max:255|nullable', + 'transactions.*.category_name' => ['min:1', 'max:255', 'nullable'], 'transactions.*.bill_id' => ['numeric', 'nullable', 'mustExist:bills,id', new BelongsUser()], 'transactions.*.bill_name' => ['min:1', 'max:255', 'nullable', new BelongsUser()], // other interesting fields 'transactions.*.reconciled' => [new IsBoolean()], - 'transactions.*.notes' => 'min:1|max:32768|nullable', - 'transactions.*.tags' => 'min:0|max:255|nullable', - 'transactions.*.tags.*' => 'min:0|max:255', + 'transactions.*.notes' => ['min:1', 'max:32768', 'nullable'], + 'transactions.*.tags' => ['min:0', 'max:255', 'nullable'], + 'transactions.*.tags.*' => ['min:0', 'max:255'], // meta info fields - 'transactions.*.internal_reference' => 'min:1|max:255|nullable', - 'transactions.*.external_id' => 'min:1|max:255|nullable', - 'transactions.*.recurrence_id' => 'min:1|max:255|nullable', - 'transactions.*.bunq_payment_id' => 'min:1|max:255|nullable', + 'transactions.*.internal_reference' => ['min:1', 'max:255', 'nullable'], + 'transactions.*.external_id' => ['min:1', 'max:255', 'nullable'], + 'transactions.*.recurrence_id' => ['min:1', 'max:255', 'nullable'], + 'transactions.*.bunq_payment_id' => ['min:1', 'max:255', 'nullable'], 'transactions.*.external_url' => sprintf('min:1|max:255|nullable|url:%s', $validProtocols), // SEPA fields: - 'transactions.*.sepa_cc' => 'min:1|max:255|nullable', - 'transactions.*.sepa_ct_op' => 'min:1|max:255|nullable', - 'transactions.*.sepa_ct_id' => 'min:1|max:255|nullable', - 'transactions.*.sepa_db' => 'min:1|max:255|nullable', - 'transactions.*.sepa_country' => 'min:1|max:255|nullable', - 'transactions.*.sepa_ep' => 'min:1|max:255|nullable', - 'transactions.*.sepa_ci' => 'min:1|max:255|nullable', - 'transactions.*.sepa_batch_id' => 'min:1|max:255|nullable', + 'transactions.*.sepa_cc' => ['min:1', 'max:255', 'nullable'], + 'transactions.*.sepa_ct_op' => ['min:1', 'max:255', 'nullable'], + 'transactions.*.sepa_ct_id' => ['min:1', 'max:255', 'nullable'], + 'transactions.*.sepa_db' => ['min:1', 'max:255', 'nullable'], + 'transactions.*.sepa_country' => ['min:1', 'max:255', 'nullable'], + 'transactions.*.sepa_ep' => ['min:1', 'max:255', 'nullable'], + 'transactions.*.sepa_ci' => ['min:1', 'max:255', 'nullable'], + 'transactions.*.sepa_batch_id' => ['min:1', 'max:255', 'nullable'], // dates - 'transactions.*.interest_date' => 'date|nullable|after:1970-01-02|before:2038-01-17', - 'transactions.*.book_date' => 'date|nullable|after:1970-01-02|before:2038-01-17', - 'transactions.*.process_date' => 'date|nullable|after:1970-01-02|before:2038-01-17', - 'transactions.*.due_date' => 'date|nullable|after:1970-01-02|before:2038-01-17', - 'transactions.*.payment_date' => 'date|nullable|after:1970-01-02|before:2038-01-17', - 'transactions.*.invoice_date' => 'date|nullable|after:1970-01-02|before:2038-01-17', + 'transactions.*.interest_date' => ['date', 'nullable', 'after:1970-01-02', 'before:2038-01-17'], + 'transactions.*.book_date' => ['date', 'nullable', 'after:1970-01-02', 'before:2038-01-17'], + 'transactions.*.process_date' => ['date', 'nullable', 'after:1970-01-02', 'before:2038-01-17'], + 'transactions.*.due_date' => ['date', 'nullable', 'after:1970-01-02', 'before:2038-01-17'], + 'transactions.*.payment_date' => ['date', 'nullable', 'after:1970-01-02', 'before:2038-01-17'], + 'transactions.*.invoice_date' => ['date', 'nullable', 'after:1970-01-02', 'before:2038-01-17'], ]; } diff --git a/app/Api/V1/Requests/Models/TransactionCurrency/StoreRequest.php b/app/Api/V1/Requests/Models/TransactionCurrency/StoreRequest.php index be16685086..8d30e1b866 100644 --- a/app/Api/V1/Requests/Models/TransactionCurrency/StoreRequest.php +++ b/app/Api/V1/Requests/Models/TransactionCurrency/StoreRequest.php @@ -69,10 +69,10 @@ class StoreRequest extends FormRequest public function rules(): array { return [ - 'name' => 'required|min:1|max:255|unique:transaction_currencies,name', - 'code' => 'required|min:3|max:32|unique:transaction_currencies,code', - 'symbol' => 'required|min:1|max:32|unique:transaction_currencies,symbol', - 'decimal_places' => 'numeric|min:0|max:12', + 'name' => ['required', 'min:1', 'max:255', 'unique:transaction_currencies,name'], + 'code' => ['required', 'min:3', 'max:32', 'unique:transaction_currencies,code'], + 'symbol' => ['required', 'min:1', 'max:32', 'unique:transaction_currencies,symbol'], + 'decimal_places' => ['numeric', 'min:0', 'max:12'], 'enabled' => [new IsBoolean()], 'default' => [new IsBoolean()], ]; diff --git a/app/Api/V1/Requests/Models/TransactionCurrency/UpdateRequest.php b/app/Api/V1/Requests/Models/TransactionCurrency/UpdateRequest.php index 7e202ac387..5c30faa6d6 100644 --- a/app/Api/V1/Requests/Models/TransactionCurrency/UpdateRequest.php +++ b/app/Api/V1/Requests/Models/TransactionCurrency/UpdateRequest.php @@ -82,7 +82,7 @@ class UpdateRequest extends FormRequest 'name' => sprintf('min:1|max:255|unique:transaction_currencies,name,%d', $currency->id), 'code' => sprintf('min:3|max:32|unique:transaction_currencies,code,%d', $currency->id), 'symbol' => sprintf('min:1|max:32|unique:transaction_currencies,symbol,%d', $currency->id), - 'decimal_places' => 'numeric|min:0|max:12', + 'decimal_places' => ['numeric', 'min:0', 'max:12'], 'enabled' => [new IsBoolean()], 'default' => [new IsBoolean()], ]; diff --git a/app/Api/V1/Requests/Models/TransactionLink/StoreRequest.php b/app/Api/V1/Requests/Models/TransactionLink/StoreRequest.php index ac0bec8fc5..d6d1db01b0 100644 --- a/app/Api/V1/Requests/Models/TransactionLink/StoreRequest.php +++ b/app/Api/V1/Requests/Models/TransactionLink/StoreRequest.php @@ -63,11 +63,11 @@ class StoreRequest extends FormRequest public function rules(): array { return [ - 'link_type_id' => 'exists:link_types,id|required_without:link_type_name', - 'link_type_name' => 'exists:link_types,name|required_without:link_type_id', - 'inward_id' => 'required|belongsToUser:transaction_journals,id|different:outward_id', - 'outward_id' => 'required|belongsToUser:transaction_journals,id|different:inward_id', - 'notes' => 'min:1|max:32768|nullable', + 'link_type_id' => ['exists:link_types,id', 'required_without:link_type_name'], + 'link_type_name' => ['exists:link_types,name', 'required_without:link_type_id'], + 'inward_id' => ['required', 'belongsToUser:transaction_journals,id', 'different:outward_id'], + 'outward_id' => ['required', 'belongsToUser:transaction_journals,id', 'different:inward_id'], + 'notes' => ['min:1', 'max:32768', 'nullable'], ]; } diff --git a/app/Api/V1/Requests/Models/TransactionLink/UpdateRequest.php b/app/Api/V1/Requests/Models/TransactionLink/UpdateRequest.php index 66e2ee60c0..f4a6743417 100644 --- a/app/Api/V1/Requests/Models/TransactionLink/UpdateRequest.php +++ b/app/Api/V1/Requests/Models/TransactionLink/UpdateRequest.php @@ -65,9 +65,9 @@ class UpdateRequest extends FormRequest return [ 'link_type_id' => 'exists:link_types,id', 'link_type_name' => 'exists:link_types,name', - 'inward_id' => 'belongsToUser:transaction_journals,id|different:outward_id', - 'outward_id' => 'belongsToUser:transaction_journals,id|different:inward_id', - 'notes' => 'min:1|max:32768|nullable', + 'inward_id' => ['belongsToUser:transaction_journals,id', 'different:outward_id'], + 'outward_id' => ['belongsToUser:transaction_journals,id', 'different:inward_id'], + 'notes' => ['min:1', 'max:32768', 'nullable'], ]; } diff --git a/app/Api/V1/Requests/Models/TransactionLinkType/StoreRequest.php b/app/Api/V1/Requests/Models/TransactionLinkType/StoreRequest.php index 71bd383107..ef7b405872 100644 --- a/app/Api/V1/Requests/Models/TransactionLinkType/StoreRequest.php +++ b/app/Api/V1/Requests/Models/TransactionLinkType/StoreRequest.php @@ -52,9 +52,9 @@ class StoreRequest extends FormRequest public function rules(): array { return [ - 'name' => 'required|unique:link_types,name|min:1|max:1024', - 'outward' => 'required|unique:link_types,outward|min:1|different:inward|max:1024', - 'inward' => 'required|unique:link_types,inward|min:1|different:outward|max:1024', + 'name' => ['required', 'unique:link_types,name', 'min:1', 'max:1024'], + 'outward' => ['required', 'unique:link_types,outward', 'min:1', 'different:inward', 'max:1024'], + 'inward' => ['required', 'unique:link_types,inward', 'min:1', 'different:outward', 'max:1024'], ]; } } diff --git a/app/Api/V1/Requests/Models/Webhook/CreateRequest.php b/app/Api/V1/Requests/Models/Webhook/CreateRequest.php index 3c8e444425..909d5071eb 100644 --- a/app/Api/V1/Requests/Models/Webhook/CreateRequest.php +++ b/app/Api/V1/Requests/Models/Webhook/CreateRequest.php @@ -75,16 +75,16 @@ class CreateRequest extends FormRequest $validProtocols = FireflyConfig::get('valid_url_protocols', config('firefly.valid_url_protocols'))->data; return [ - 'title' => 'required|min:1|max:255|uniqueObjectForUser:webhooks,title', + 'title' => ['required', 'min:1', 'max:255', 'uniqueObjectForUser:webhooks,title'], 'active' => [new IsBoolean()], 'trigger' => 'prohibited', - 'triggers' => 'required|array|min:1|max:10', + 'triggers' => ['required', 'array', 'min:1', 'max:10'], 'triggers.*' => sprintf('required|in:%s', $triggers), 'response' => 'prohibited', - 'responses' => 'required|array|min:1|max:1', + 'responses' => ['required', 'array', 'min:1', 'max:1'], 'responses.*' => sprintf('required|in:%s', $responses), 'delivery' => 'prohibited', - 'deliveries' => 'required|array|min:1|max:1', + 'deliveries' => ['required', 'array', 'min:1', 'max:1'], 'deliveries.*' => sprintf('required|in:%s', $deliveries), 'url' => ['required', sprintf('url:%s', $validProtocols), new IsValidWebhookUrl()], ]; diff --git a/app/Api/V1/Requests/Models/Webhook/UpdateRequest.php b/app/Api/V1/Requests/Models/Webhook/UpdateRequest.php index 27629cec58..c06a822fd5 100644 --- a/app/Api/V1/Requests/Models/Webhook/UpdateRequest.php +++ b/app/Api/V1/Requests/Models/Webhook/UpdateRequest.php @@ -82,13 +82,13 @@ class UpdateRequest extends FormRequest 'title' => sprintf('min:1|max:255|uniqueObjectForUser:webhooks,title,%d', $webhook->id), 'active' => [new IsBoolean()], 'trigger' => 'prohibited', - 'triggers' => 'required|array|min:1|max:10', + 'triggers' => ['required', 'array', 'min:1', 'max:10'], 'triggers.*' => sprintf('required|in:%s', $triggers), 'response' => 'prohibited', - 'responses' => 'required|array|min:1|max:1', + 'responses' => ['required', 'array', 'min:1', 'max:1'], 'responses.*' => sprintf('required|in:%s', $responses), 'delivery' => 'prohibited', - 'deliveries' => 'required|array|min:1|max:1', + 'deliveries' => ['required', 'array', 'min:1', 'max:1'], 'deliveries.*' => sprintf('required|in:%s', $deliveries), 'url' => [sprintf('url:%s', $validProtocols), sprintf('uniqueExistingWebhook:%d', $webhook->id), new IsValidWebhookUrl()], ]; diff --git a/app/Api/V1/Requests/PaginationRequest.php b/app/Api/V1/Requests/PaginationRequest.php index c47bbbee74..e86c3dd34a 100644 --- a/app/Api/V1/Requests/PaginationRequest.php +++ b/app/Api/V1/Requests/PaginationRequest.php @@ -50,8 +50,8 @@ class PaginationRequest extends ApiRequest { return [ 'sort' => ['nullable', new IsValidSortInstruction((string) $this->sortClass)], - 'limit' => 'numeric|min:1|max:131337', - 'page' => 'numeric|min:1|max:131337', + 'limit' => ['numeric', 'min:1', 'max:131337'], + 'page' => ['numeric', 'min:1', 'max:131337'], ]; } diff --git a/app/Api/V1/Requests/Search/CountRequest.php b/app/Api/V1/Requests/Search/CountRequest.php index 846ee4d197..dcb55549e0 100644 --- a/app/Api/V1/Requests/Search/CountRequest.php +++ b/app/Api/V1/Requests/Search/CountRequest.php @@ -34,10 +34,10 @@ class CountRequest extends AggregateFormRequest public function rules(): array { return [ - 'notes' => 'string|min:1|max:255', - 'external_identifier' => 'string|min:1|max:255', - 'description' => 'string|min:1|max:255', - 'internal_reference' => 'string|min:1|max:255', + 'notes' => ['string', 'min:1', 'max:255'], + 'external_identifier' => ['string', 'min:1', 'max:255'], + 'description' => ['string', 'min:1', 'max:255'], + 'internal_reference' => ['string', 'min:1', 'max:255'], 'include_deleted' => new IsBoolean(), ]; } diff --git a/app/Api/V1/Requests/System/CronRequest.php b/app/Api/V1/Requests/System/CronRequest.php index f1d54b9eba..a7cd1607bf 100644 --- a/app/Api/V1/Requests/System/CronRequest.php +++ b/app/Api/V1/Requests/System/CronRequest.php @@ -68,6 +68,6 @@ class CronRequest extends FormRequest */ public function rules(): array { - return ['force' => 'in:true,false', 'date' => 'nullable|date|after:1970-01-02|before:2038-01-17']; + return ['force' => 'in:true,false', 'date' => ['nullable', 'date', 'after:1970-01-02', 'before:2038-01-17']]; } } diff --git a/app/Api/V1/Requests/System/UpdateRequest.php b/app/Api/V1/Requests/System/UpdateRequest.php index 4d9c1d772d..cb01863154 100644 --- a/app/Api/V1/Requests/System/UpdateRequest.php +++ b/app/Api/V1/Requests/System/UpdateRequest.php @@ -77,10 +77,10 @@ class UpdateRequest extends FormRequest return ['value' => ['required', new IsBoolean()]]; } if ('configuration.permission_update_check' === $name) { - return ['value' => 'required|numeric|min:-1|max:1']; + return ['value' => ['required', 'numeric', 'min:-1', 'max:1']]; } if (in_array($name, $this->integers, strict: true)) { - return ['value' => 'required|numeric|min:464272080']; + return ['value' => ['required', 'numeric', 'min:464272080']]; } return ['value' => 'required']; diff --git a/app/Api/V1/Requests/System/UserStoreRequest.php b/app/Api/V1/Requests/System/UserStoreRequest.php index 76732fddf3..8774692d29 100644 --- a/app/Api/V1/Requests/System/UserStoreRequest.php +++ b/app/Api/V1/Requests/System/UserStoreRequest.php @@ -71,7 +71,7 @@ class UserStoreRequest extends FormRequest public function rules(): array { return [ - 'email' => 'required|email|unique:users,email', + 'email' => ['required', 'email', 'unique:users,email'], 'blocked' => [new IsBoolean()], 'blocked_code' => 'in:email_changed', 'role' => 'in:owner,demo', diff --git a/app/Console/Commands/Correction/ClearsEmptyForeignAmounts.php b/app/Console/Commands/Correction/ClearsEmptyForeignAmounts.php index e46b3197db..94e1d73bb8 100644 --- a/app/Console/Commands/Correction/ClearsEmptyForeignAmounts.php +++ b/app/Console/Commands/Correction/ClearsEmptyForeignAmounts.php @@ -52,15 +52,15 @@ class ClearsEmptyForeignAmounts extends Command public function handle(): int { // transaction: has no amount, but reference to currency. - $count = Transaction::whereNull('foreign_amount')->whereNotNull('foreign_currency_id')->count(); + $count = Transaction::query()->whereNull('foreign_amount')->whereNotNull('foreign_currency_id')->count(); if ($count > 0) { - Transaction::whereNull('foreign_amount')->whereNotNull('foreign_currency_id')->update(['foreign_currency_id' => null]); + Transaction::query()->whereNull('foreign_amount')->whereNotNull('foreign_currency_id')->update(['foreign_currency_id' => null]); $this->friendlyInfo(sprintf('Corrected %d invalid foreign amount reference(s)', $count)); } // transaction: has amount, but no currency. - $count = Transaction::whereNull('foreign_currency_id')->whereNotNull('foreign_amount')->count(); + $count = Transaction::query()->whereNull('foreign_currency_id')->whereNotNull('foreign_amount')->count(); if ($count > 0) { - Transaction::whereNull('foreign_currency_id')->whereNotNull('foreign_amount')->update(['foreign_amount' => null]); + Transaction::query()->whereNull('foreign_currency_id')->whereNotNull('foreign_amount')->update(['foreign_amount' => null]); $this->friendlyInfo(sprintf('Corrected %d invalid foreign amount reference(s)', $count)); } diff --git a/app/Console/Commands/Correction/CorrectsAmounts.php b/app/Console/Commands/Correction/CorrectsAmounts.php index cfe775380e..0477b37473 100644 --- a/app/Console/Commands/Correction/CorrectsAmounts.php +++ b/app/Console/Commands/Correction/CorrectsAmounts.php @@ -88,7 +88,7 @@ class CorrectsAmounts extends Command /** @var AccountRepositoryInterface $repository */ $repository = app(AccountRepositoryInterface::class); - $type = TransactionType::where('type', TransactionTypeEnum::TRANSFER->value)->first(); + $type = TransactionType::query()->where('type', TransactionTypeEnum::TRANSFER->value)->first(); $journals = TransactionJournal::leftJoin('transactions', 'transactions.transaction_journal_id', '=', 'transaction_journals.id') ->whereNotNull('transactions.foreign_amount') ->where('transaction_journals.transaction_type_id', $type->id) @@ -188,7 +188,7 @@ class CorrectsAmounts extends Command private function fixAutoBudgets(): void { - $count = AutoBudget::where('amount', '<', 0)->update(['amount' => DB::raw('amount * -1')]); + $count = AutoBudget::query()->where('amount', '<', 0)->update(['amount' => DB::raw('amount * -1')]); if (0 === $count) { return; } @@ -197,7 +197,7 @@ class CorrectsAmounts extends Command private function fixAvailableBudgets(): void { - $count = AvailableBudget::where('amount', '<', 0)->update(['amount' => DB::raw('amount * -1')]); + $count = AvailableBudget::query()->where('amount', '<', 0)->update(['amount' => DB::raw('amount * -1')]); if (0 === $count) { return; } @@ -207,8 +207,8 @@ class CorrectsAmounts extends Command private function fixBills(): void { $count = 0; - $count += Bill::where('amount_max', '<', 0)->update(['amount_max' => DB::raw('amount_max * -1')]); - $count += Bill::where('amount_min', '<', 0)->update(['amount_min' => DB::raw('amount_min * -1')]); + $count += Bill::query()->where('amount_max', '<', 0)->update(['amount_max' => DB::raw('amount_max * -1')]); + $count += Bill::query()->where('amount_min', '<', 0)->update(['amount_min' => DB::raw('amount_min * -1')]); if (0 === $count) { return; } @@ -217,7 +217,7 @@ class CorrectsAmounts extends Command private function fixBudgetLimits(): void { - $count = BudgetLimit::where('amount', '<', 0)->update(['amount' => DB::raw('amount * -1')]); + $count = BudgetLimit::query()->where('amount', '<', 0)->update(['amount' => DB::raw('amount * -1')]); if (0 === $count) { return; } @@ -226,7 +226,7 @@ class CorrectsAmounts extends Command private function fixExchangeRates(): void { - $count = CurrencyExchangeRate::where('rate', '<', 0)->update(['rate' => DB::raw('rate * -1')]); + $count = CurrencyExchangeRate::query()->where('rate', '<', 0)->update(['rate' => DB::raw('rate * -1')]); if (0 === $count) { return; } @@ -235,7 +235,7 @@ class CorrectsAmounts extends Command private function fixPiggyBanks(): void { - $count = PiggyBank::where('target_amount', '<', 0)->update(['target_amount' => DB::raw('target_amount * -1')]); + $count = PiggyBank::query()->where('target_amount', '<', 0)->update(['target_amount' => DB::raw('target_amount * -1')]); if (0 === $count) { return; } @@ -245,8 +245,8 @@ class CorrectsAmounts extends Command private function fixRecurrences(): void { $count = 0; - $count += RecurrenceTransaction::where('amount', '<', 0)->update(['amount' => DB::raw('amount * -1')]); - $count += RecurrenceTransaction::where('foreign_amount', '<', 0)->update(['foreign_amount' => DB::raw('foreign_amount * -1')]); + $count += RecurrenceTransaction::query()->where('amount', '<', 0)->update(['amount' => DB::raw('amount * -1')]); + $count += RecurrenceTransaction::query()->where('foreign_amount', '<', 0)->update(['foreign_amount' => DB::raw('foreign_amount * -1')]); if (0 === $count) { return; } @@ -285,7 +285,7 @@ class CorrectsAmounts extends Command */ private function fixRuleTriggers(): void { - $set = RuleTrigger::whereIn('trigger_type', ['amount_less', 'amount_more', 'amount_is'])->get(); + $set = RuleTrigger::query()->whereIn('trigger_type', ['amount_less', 'amount_more', 'amount_is'])->get(); $fixed = 0; /** @var RuleTrigger $item */ diff --git a/app/Console/Commands/Correction/CorrectsCurrencies.php b/app/Console/Commands/Correction/CorrectsCurrencies.php index ba2fcf776e..21a46ba24b 100644 --- a/app/Console/Commands/Correction/CorrectsCurrencies.php +++ b/app/Console/Commands/Correction/CorrectsCurrencies.php @@ -81,7 +81,7 @@ class CorrectsCurrencies extends Command } // get all from journals: - $journals = TransactionJournal::where('user_group_id', $userGroup->id)->groupBy('transaction_currency_id')->get(['transaction_currency_id']); + $journals = TransactionJournal::query()->where('user_group_id', $userGroup->id)->groupBy('transaction_currency_id')->get(['transaction_currency_id']); foreach ($journals as $entry) { $found[] = (int) $entry->transaction_currency_id; } diff --git a/app/Console/Commands/Correction/CorrectsGroupAccounts.php b/app/Console/Commands/Correction/CorrectsGroupAccounts.php index 852098eb4c..d987953b42 100644 --- a/app/Console/Commands/Correction/CorrectsGroupAccounts.php +++ b/app/Console/Commands/Correction/CorrectsGroupAccounts.php @@ -49,7 +49,7 @@ class CorrectsGroupAccounts extends Command { Log::debug('Start of correction:group-accounts'); $groups = []; - $res = TransactionJournal::groupBy('transaction_group_id')->get(['transaction_group_id', DB::raw('COUNT(transaction_group_id) as the_count')]); + $res = TransactionJournal::query()->groupBy('transaction_group_id')->get(['transaction_group_id', DB::raw('COUNT(transaction_group_id) as the_count')]); /** @var TransactionJournal $journal */ foreach ($res as $journal) { diff --git a/app/Console/Commands/Correction/CorrectsIbans.php b/app/Console/Commands/Correction/CorrectsIbans.php index dca465b685..4c7e6e571e 100644 --- a/app/Console/Commands/Correction/CorrectsIbans.php +++ b/app/Console/Commands/Correction/CorrectsIbans.php @@ -44,7 +44,7 @@ class CorrectsIbans extends Command */ public function handle(): int { - $accounts = Account::with('accountMeta')->get(); + $accounts = Account::query()->with('accountMeta')->get(); $this->filterIbans($accounts); $this->countAndCorrectIbans($accounts); diff --git a/app/Console/Commands/Correction/CorrectsInvertedBudgetLimits.php b/app/Console/Commands/Correction/CorrectsInvertedBudgetLimits.php index aff0cc704a..7b812ab72d 100644 --- a/app/Console/Commands/Correction/CorrectsInvertedBudgetLimits.php +++ b/app/Console/Commands/Correction/CorrectsInvertedBudgetLimits.php @@ -53,7 +53,7 @@ class CorrectsInvertedBudgetLimits extends Command */ public function handle(): int { - $set = BudgetLimit::where('start_date', '>', DB::raw('end_date'))->get(); + $set = BudgetLimit::query()->where('start_date', '>', DB::raw('end_date'))->get(); if (0 === $set->count()) { Log::debug('No inverted budget limits found.'); diff --git a/app/Console/Commands/Correction/CorrectsLongDescriptions.php b/app/Console/Commands/Correction/CorrectsLongDescriptions.php index 4817a8a750..c57c4eb1c6 100644 --- a/app/Console/Commands/Correction/CorrectsLongDescriptions.php +++ b/app/Console/Commands/Correction/CorrectsLongDescriptions.php @@ -44,7 +44,7 @@ class CorrectsLongDescriptions extends Command */ public function handle(): int { - $journals = TransactionJournal::where(DB::raw('LENGTH(description)'), '>', self::MAX_LENGTH)->get(['id', 'description']); + $journals = TransactionJournal::query()->where(DB::raw('LENGTH(description)'), '>', self::MAX_LENGTH)->get(['id', 'description']); $count = 0; /** @var TransactionJournal $journal */ @@ -57,7 +57,7 @@ class CorrectsLongDescriptions extends Command } } - $groups = TransactionGroup::where(DB::raw('LENGTH(title)'), '>', self::MAX_LENGTH)->get(['id', 'title']); + $groups = TransactionGroup::query()->where(DB::raw('LENGTH(title)'), '>', self::MAX_LENGTH)->get(['id', 'title']); /** @var TransactionGroup $group */ foreach ($groups as $group) { diff --git a/app/Console/Commands/Correction/CorrectsPiggyBanks.php b/app/Console/Commands/Correction/CorrectsPiggyBanks.php index 66a737532a..c6319d5d1c 100644 --- a/app/Console/Commands/Correction/CorrectsPiggyBanks.php +++ b/app/Console/Commands/Correction/CorrectsPiggyBanks.php @@ -42,7 +42,7 @@ class CorrectsPiggyBanks extends Command public function handle(): int { $count = 0; - $set = PiggyBankEvent::with(['PiggyBank', 'TransactionJournal'])->get(); + $set = PiggyBankEvent::query()->with(['PiggyBank', 'TransactionJournal'])->get(); /** @var PiggyBankEvent $event */ foreach ($set as $event) { diff --git a/app/Console/Commands/Correction/CorrectsPreferences.php b/app/Console/Commands/Correction/CorrectsPreferences.php index 1787094c95..8113234e31 100644 --- a/app/Console/Commands/Correction/CorrectsPreferences.php +++ b/app/Console/Commands/Correction/CorrectsPreferences.php @@ -47,7 +47,7 @@ class CorrectsPreferences extends Command foreach ($users as $user) { $count = 0; foreach ($items as $item) { - $preference = Preference::where('name', $item)->where('user_id', $user->id)->first(); + $preference = Preference::query()->where('name', $item)->where('user_id', $user->id)->first(); if (null === $preference) { continue; } diff --git a/app/Console/Commands/Correction/CorrectsTransactionTypes.php b/app/Console/Commands/Correction/CorrectsTransactionTypes.php index c50a2c0b97..6c900f6f3a 100644 --- a/app/Console/Commands/Correction/CorrectsTransactionTypes.php +++ b/app/Console/Commands/Correction/CorrectsTransactionTypes.php @@ -81,7 +81,7 @@ class CorrectsTransactionTypes extends Command */ private function collectJournals(): Collection { - return TransactionJournal::with(['transactionType', 'transactions', 'transactions.account', 'transactions.account.accountType'])->get(); + return TransactionJournal::query()->with(['transactionType', 'transactions', 'transactions.account', 'transactions.account.accountType'])->get(); } private function fixJournal(TransactionJournal $journal): bool diff --git a/app/Console/Commands/Correction/CorrectsTransferBudgets.php b/app/Console/Commands/Correction/CorrectsTransferBudgets.php index dacb03b907..d7d777fd2a 100644 --- a/app/Console/Commands/Correction/CorrectsTransferBudgets.php +++ b/app/Console/Commands/Correction/CorrectsTransferBudgets.php @@ -42,7 +42,7 @@ class CorrectsTransferBudgets extends Command */ public function handle(): int { - $set = TransactionJournal::distinct() + $set = TransactionJournal::query()->distinct() ->leftJoin('transaction_types', 'transaction_types.id', '=', 'transaction_journals.transaction_type_id') ->leftJoin('budget_transaction_journal', 'transaction_journals.id', '=', 'budget_transaction_journal.transaction_journal_id') ->whereNotIn('transaction_types.type', [TransactionTypeEnum::WITHDRAWAL->value]) diff --git a/app/Console/Commands/Correction/CorrectsUnevenAmount.php b/app/Console/Commands/Correction/CorrectsUnevenAmount.php index c26de356ce..5a640db53f 100644 --- a/app/Console/Commands/Correction/CorrectsUnevenAmount.php +++ b/app/Console/Commands/Correction/CorrectsUnevenAmount.php @@ -76,7 +76,7 @@ class CorrectsUnevenAmount extends Command $repository = app(AccountRepositoryInterface::class); Log::debug('convertOldStyleTransactions()'); $count = 0; - $transactions = Transaction::distinct() + $transactions = Transaction::query()->distinct() ->leftJoin('transaction_journals', 'transaction_journals.id', 'transactions.transaction_journal_id') ->leftJoin('transaction_types', 'transaction_types.id', 'transaction_journals.transaction_type_id') ->leftJoin('accounts', 'accounts.id', 'transactions.account_id') @@ -188,7 +188,7 @@ class CorrectsUnevenAmount extends Command { Log::debug('convertOldStyleTransfers()'); // select transactions with a foreign amount and a foreign currency. and it's a transfer. and they are different. - $transactions = Transaction::distinct() + $transactions = Transaction::query()->distinct() ->leftJoin('transaction_journals', 'transaction_journals.id', 'transactions.transaction_journal_id') ->leftJoin('transaction_types', 'transaction_types.id', 'transaction_journals.transaction_type_id') ->where('transaction_types.type', TransactionTypeEnum::TRANSFER->value) @@ -262,8 +262,8 @@ class CorrectsUnevenAmount extends Command $journal->id ?? 0, $journal->description ?? '' )); - Transaction::where('transaction_journal_id', $journal->id ?? 0)->forceDelete(); - TransactionJournal::where('id', $journal->id ?? 0)->forceDelete(); + Transaction::query()->where('transaction_journal_id', $journal->id ?? 0)->forceDelete(); + TransactionJournal::query()->where('id', $journal->id ?? 0)->forceDelete(); ++$this->count; return; @@ -282,8 +282,8 @@ class CorrectsUnevenAmount extends Command $journal->description ?? '' )); - Transaction::where('transaction_journal_id', $journal->id ?? 0)->forceDelete(); - TransactionJournal::where('id', $journal->id ?? 0)->forceDelete(); + Transaction::query()->where('transaction_journal_id', $journal->id ?? 0)->forceDelete(); + TransactionJournal::query()->where('id', $journal->id ?? 0)->forceDelete(); ++$this->count; return; @@ -430,7 +430,7 @@ class CorrectsUnevenAmount extends Command /** @var TransactionJournal $journal */ foreach ($journals as $journal) { if (!$this->isForeignCurrencyTransfer($journal) && !$this->isBetweenAssetAndLiability($journal)) { - Transaction::where('transaction_journal_id', $journal->id)->update(['transaction_currency_id' => $journal->transaction_currency_id]); + Transaction::query()->where('transaction_journal_id', $journal->id)->update(['transaction_currency_id' => $journal->transaction_currency_id]); ++$count; continue; diff --git a/app/Console/Commands/Correction/CreatesGroupMemberships.php b/app/Console/Commands/Correction/CreatesGroupMemberships.php index 20968c04b9..b6156b5b78 100644 --- a/app/Console/Commands/Correction/CreatesGroupMemberships.php +++ b/app/Console/Commands/Correction/CreatesGroupMemberships.php @@ -50,17 +50,17 @@ class CreatesGroupMemberships extends Command public static function createGroupMembership(User $user): void { // check if membership exists - $userGroup = UserGroup::where('title', $user->email)->first(); + $userGroup = UserGroup::query()->where('title', $user->email)->first(); if (null === $userGroup) { $userGroup = UserGroup::create(['title' => $user->email]); } - $userRole = UserRole::where('title', UserRoleEnum::OWNER->value)->first(); + $userRole = UserRole::query()->where('title', UserRoleEnum::OWNER->value)->first(); if (null === $userRole) { throw new FireflyException('Firefly III could not find a user role. Please make sure all migrations have run.'); } - $membership = GroupMembership::where('user_id', $user->id)->where('user_group_id', $userGroup->id)->where('user_role_id', $userRole->id)->first(); + $membership = GroupMembership::query()->where('user_id', $user->id)->where('user_group_id', $userGroup->id)->where('user_role_id', $userRole->id)->first(); if (null === $membership) { GroupMembership::create(['user_id' => $user->id, 'user_role_id' => $userRole->id, 'user_group_id' => $userGroup->id]); } diff --git a/app/Console/Commands/Correction/CreatesLinkTypes.php b/app/Console/Commands/Correction/CreatesLinkTypes.php index 1cdbb05b25..7aa9098c60 100644 --- a/app/Console/Commands/Correction/CreatesLinkTypes.php +++ b/app/Console/Commands/Correction/CreatesLinkTypes.php @@ -49,7 +49,7 @@ class CreatesLinkTypes extends Command 'Reimbursement' => ['(partially) reimburses', 'is (partially) reimbursed by'], ]; foreach ($set as $name => $values) { - $link = LinkType::where('name', $name)->first(); + $link = LinkType::query()->where('name', $name)->first(); if (null === $link) { $link = new LinkType(); $link->name = $name; diff --git a/app/Console/Commands/Correction/RemovesBills.php b/app/Console/Commands/Correction/RemovesBills.php index a47ad03fc7..7fd46bd5d8 100644 --- a/app/Console/Commands/Correction/RemovesBills.php +++ b/app/Console/Commands/Correction/RemovesBills.php @@ -43,11 +43,11 @@ class RemovesBills extends Command public function handle(): int { /** @var null|TransactionType $withdrawal */ - $withdrawal = TransactionType::where('type', TransactionTypeEnum::WITHDRAWAL->value)->first(); + $withdrawal = TransactionType::query()->where('type', TransactionTypeEnum::WITHDRAWAL->value)->first(); if (null === $withdrawal) { return 0; } - $journals = TransactionJournal::whereNotNull('bill_id')->where('transaction_type_id', '!=', $withdrawal->id)->get(); + $journals = TransactionJournal::query()->whereNotNull('bill_id')->where('transaction_type_id', '!=', $withdrawal->id)->get(); /** @var TransactionJournal $journal */ foreach ($journals as $journal) { diff --git a/app/Console/Commands/Correction/RemovesEmptyGroups.php b/app/Console/Commands/Correction/RemovesEmptyGroups.php index 64c9f25420..018c5d80a0 100644 --- a/app/Console/Commands/Correction/RemovesEmptyGroups.php +++ b/app/Console/Commands/Correction/RemovesEmptyGroups.php @@ -57,7 +57,7 @@ class RemovesEmptyGroups extends Command // again, chunks for SQLite. $chunks = array_chunk($groupIds, 500); foreach ($chunks as $chunk) { - TransactionGroup::whereNull('deleted_at')->whereIn('id', $chunk)->delete(); + TransactionGroup::query()->whereNull('deleted_at')->whereIn('id', $chunk)->delete(); } } diff --git a/app/Console/Commands/Correction/RemovesEmptyJournals.php b/app/Console/Commands/Correction/RemovesEmptyJournals.php index 1dc3517d58..df686e29d0 100644 --- a/app/Console/Commands/Correction/RemovesEmptyJournals.php +++ b/app/Console/Commands/Correction/RemovesEmptyJournals.php @@ -80,7 +80,7 @@ class RemovesEmptyJournals extends Command */ private function deleteUnevenJournals(): void { - $set = Transaction::whereNull('deleted_at')->groupBy('transactions.transaction_journal_id')->get([ + $set = Transaction::query()->whereNull('deleted_at')->groupBy('transactions.transaction_journal_id')->get([ DB::raw('COUNT(transactions.transaction_journal_id) as the_count'), 'transaction_journal_id', ]); @@ -100,7 +100,7 @@ class RemovesEmptyJournals extends Command Log::error($e->getTraceAsString()); } - Transaction::where('transaction_journal_id', $row->transaction_journal_id)->delete(); + Transaction::query()->where('transaction_journal_id', $row->transaction_journal_id)->delete(); $this->friendlyWarning(sprintf( 'Deleted transaction journal #%d because it had an uneven number of transactions.', $row->transaction_journal_id diff --git a/app/Console/Commands/Correction/RemovesLinksToDeletedObjects.php b/app/Console/Commands/Correction/RemovesLinksToDeletedObjects.php index 232e8b91c8..80941cbbd2 100644 --- a/app/Console/Commands/Correction/RemovesLinksToDeletedObjects.php +++ b/app/Console/Commands/Correction/RemovesLinksToDeletedObjects.php @@ -57,10 +57,10 @@ class RemovesLinksToDeletedObjects extends Command */ public function handle(): void { - $deletedTags = Tag::withTrashed()->whereNotNull('deleted_at')->get('tags.id')->pluck('id')->toArray(); - $deletedJournals = TransactionJournal::withTrashed()->whereNotNull('deleted_at')->get('transaction_journals.id')->pluck('id')->toArray(); - $deletedBudgets = Budget::withTrashed()->whereNotNull('deleted_at')->get('budgets.id')->pluck('id')->toArray(); - $deletedCategories = Category::withTrashed()->whereNotNull('deleted_at')->get('categories.id')->pluck('id')->toArray(); + $deletedTags = Tag::query()->withTrashed()->whereNotNull('deleted_at')->get('tags.id')->pluck('id')->toArray(); + $deletedJournals = TransactionJournal::query()->withTrashed()->whereNotNull('deleted_at')->get('transaction_journals.id')->pluck('id')->toArray(); + $deletedBudgets = Budget::query()->withTrashed()->whereNotNull('deleted_at')->get('budgets.id')->pluck('id')->toArray(); + $deletedCategories = Category::query()->withTrashed()->whereNotNull('deleted_at')->get('categories.id')->pluck('id')->toArray(); if (count($deletedTags) > 0) { $this->cleanupTags($deletedTags); diff --git a/app/Console/Commands/Correction/RemovesOrphanedTransactions.php b/app/Console/Commands/Correction/RemovesOrphanedTransactions.php index 7ca6ef47e4..8f088b43d0 100644 --- a/app/Console/Commands/Correction/RemovesOrphanedTransactions.php +++ b/app/Console/Commands/Correction/RemovesOrphanedTransactions.php @@ -67,7 +67,7 @@ class RemovesOrphanedTransactions extends Command /** @var null|TransactionJournal $journal */ $journal = TransactionJournal::find($transaction->transaction_journal_id); $journal?->delete(); - Transaction::where('transaction_journal_id', $transaction->transaction_journal_id)->delete(); + Transaction::query()->where('transaction_journal_id', $transaction->transaction_journal_id)->delete(); $this->friendlyWarning(sprintf( 'Deleted transaction journal #%d because account #%d was already deleted.', $transaction->transaction_journal_id, @@ -93,7 +93,7 @@ class RemovesOrphanedTransactions extends Command $this->friendlyInfo(sprintf('Found %d orphaned journal(s).', $count)); foreach ($set as $entry) { /** @var null|TransactionJournal $journal */ - $journal = TransactionJournal::withTrashed()->find($entry->id); + $journal = TransactionJournal::query()->withTrashed()->find($entry->id); if (null !== $journal) { $journal->delete(); $this->friendlyWarning(sprintf( diff --git a/app/Console/Commands/Correction/RemovesZeroAmount.php b/app/Console/Commands/Correction/RemovesZeroAmount.php index fd9d1c344e..c7d19f59c5 100644 --- a/app/Console/Commands/Correction/RemovesZeroAmount.php +++ b/app/Console/Commands/Correction/RemovesZeroAmount.php @@ -42,16 +42,16 @@ class RemovesZeroAmount extends Command */ public function handle(): int { - $set = Transaction::where('amount', 0)->get(['transaction_journal_id'])->pluck('transaction_journal_id')->toArray(); + $set = Transaction::query()->where('amount', 0)->get(['transaction_journal_id'])->pluck('transaction_journal_id')->toArray(); $set = array_unique($set); - $journals = TransactionJournal::whereIn('id', $set)->get(); + $journals = TransactionJournal::query()->whereIn('id', $set)->get(); /** @var TransactionJournal $journal */ foreach ($journals as $journal) { $this->friendlyWarning(sprintf('Deleted transaction journal #%d because the amount is zero (0.00).', $journal->id)); $journal->delete(); - Transaction::where('transaction_journal_id', $journal->id)->delete(); + Transaction::query()->where('transaction_journal_id', $journal->id)->delete(); } return 0; diff --git a/app/Console/Commands/System/ForcesDecimalSize.php b/app/Console/Commands/System/ForcesDecimalSize.php index ab0be39b74..51c23275e0 100644 --- a/app/Console/Commands/System/ForcesDecimalSize.php +++ b/app/Console/Commands/System/ForcesDecimalSize.php @@ -490,7 +490,7 @@ class ForcesDecimalSize extends Command { // select all transactions with this currency and issue. /** @var Builder $query */ - $query = Transaction::where('transaction_currency_id', $currency->id)->where( + $query = Transaction::query()->where('transaction_currency_id', $currency->id)->where( DB::raw(sprintf('CAST(amount as %s)', $this->cast)), $this->operator, DB::raw(sprintf($this->regularExpression, $currency->decimal_places)) @@ -519,7 +519,7 @@ class ForcesDecimalSize extends Command // select all transactions with this FOREIGN currency and issue. /** @var Builder $query */ - $query = Transaction::where('foreign_currency_id', $currency->id)->where( + $query = Transaction::query()->where('foreign_currency_id', $currency->id)->where( DB::raw(sprintf('CAST(foreign_amount as %s)', $this->cast)), $this->operator, DB::raw(sprintf($this->regularExpression, $currency->decimal_places)) diff --git a/app/Console/Commands/Upgrade/AddsTransactionIdentifiers.php b/app/Console/Commands/Upgrade/AddsTransactionIdentifiers.php index 6676dc04a9..7e6b6dc91c 100644 --- a/app/Console/Commands/Upgrade/AddsTransactionIdentifiers.php +++ b/app/Console/Commands/Upgrade/AddsTransactionIdentifiers.php @@ -93,7 +93,7 @@ class AddsTransactionIdentifiers extends Command try { /** @var Transaction $opposing */ - $opposing = Transaction::where('transaction_journal_id', $transaction->transaction_journal_id) + $opposing = Transaction::query()->where('transaction_journal_id', $transaction->transaction_journal_id) ->where('amount', $amount) ->where('identifier', '=', 0) ->whereNotIn('id', $exclude) diff --git a/app/Console/Commands/Upgrade/UpgradesAccountCurrencies.php b/app/Console/Commands/Upgrade/UpgradesAccountCurrencies.php index 86912917a5..7af47de7fc 100644 --- a/app/Console/Commands/Upgrade/UpgradesAccountCurrencies.php +++ b/app/Console/Commands/Upgrade/UpgradesAccountCurrencies.php @@ -106,7 +106,7 @@ class UpgradesAccountCurrencies extends Command // both 0? set to default currency: if (0 === $accountCurrency && 0 === $obCurrency) { - AccountMeta::where('account_id', $account->id)->where('name', 'currency_id')->forceDelete(); + AccountMeta::query()->where('account_id', $account->id)->where('name', 'currency_id')->forceDelete(); AccountMeta::create(['account_id' => $account->id, 'name' => 'currency_id', 'data' => $currency->id]); $this->friendlyInfo(sprintf('Account #%d ("%s") now has a currency setting (%s).', $account->id, $account->name, $currency->code)); ++$this->count; diff --git a/app/Console/Commands/Upgrade/UpgradesAccountMetaData.php b/app/Console/Commands/Upgrade/UpgradesAccountMetaData.php index 0aedf414a1..d07703b5ae 100644 --- a/app/Console/Commands/Upgrade/UpgradesAccountMetaData.php +++ b/app/Console/Commands/Upgrade/UpgradesAccountMetaData.php @@ -66,10 +66,10 @@ class UpgradesAccountMetaData extends Command * @var string $new */ foreach ($array as $old => $new) { - $count += AccountMeta::where('name', $old)->update(['name' => $new]); + $count += AccountMeta::query()->where('name', $old)->update(['name' => $new]); // delete empty entries while we're at it. - AccountMeta::where('name', $new)->where('data', '""')->delete(); + AccountMeta::query()->where('name', $new)->where('data', '""')->delete(); } $this->markAsExecuted(); diff --git a/app/Console/Commands/Upgrade/UpgradesBudgetLimitPeriods.php b/app/Console/Commands/Upgrade/UpgradesBudgetLimitPeriods.php index a318f8ed55..f6960350fb 100644 --- a/app/Console/Commands/Upgrade/UpgradesBudgetLimitPeriods.php +++ b/app/Console/Commands/Upgrade/UpgradesBudgetLimitPeriods.php @@ -152,7 +152,7 @@ class UpgradesBudgetLimitPeriods extends Command private function theresNoLimit(): void { - $limits = BudgetLimit::whereNull('period')->get(); + $limits = BudgetLimit::query()->whereNull('period')->get(); /** @var BudgetLimit $limit */ foreach ($limits as $limit) { diff --git a/app/Console/Commands/Upgrade/UpgradesCreditCardLiabilities.php b/app/Console/Commands/Upgrade/UpgradesCreditCardLiabilities.php index ca34b5256a..be85e4cdd1 100644 --- a/app/Console/Commands/Upgrade/UpgradesCreditCardLiabilities.php +++ b/app/Console/Commands/Upgrade/UpgradesCreditCardLiabilities.php @@ -55,8 +55,8 @@ class UpgradesCreditCardLiabilities extends Command return 0; } - $ccType = AccountType::where('type', AccountTypeEnum::CREDITCARD->value)->first(); - $debtType = AccountType::where('type', AccountTypeEnum::DEBT->value)->first(); + $ccType = AccountType::query()->where('type', AccountTypeEnum::CREDITCARD->value)->first(); + $debtType = AccountType::query()->where('type', AccountTypeEnum::DEBT->value)->first(); if (null === $ccType || null === $debtType) { $this->markAsExecuted(); @@ -64,7 +64,7 @@ class UpgradesCreditCardLiabilities extends Command } /** @var Collection $accounts */ - $accounts = Account::where('account_type_id', $ccType->id)->get(); + $accounts = Account::query()->where('account_type_id', $ccType->id)->get(); foreach ($accounts as $account) { $account->account_type_id = $debtType->id; $account->save(); diff --git a/app/Console/Commands/Upgrade/UpgradesCurrencyPreferences.php b/app/Console/Commands/Upgrade/UpgradesCurrencyPreferences.php index 6b77443bc6..a05bd454c2 100644 --- a/app/Console/Commands/Upgrade/UpgradesCurrencyPreferences.php +++ b/app/Console/Commands/Upgrade/UpgradesCurrencyPreferences.php @@ -66,7 +66,7 @@ class UpgradesCurrencyPreferences extends Command private function getPreference(User $user): string { - $preference = Preference::where('user_id', $user->id) + $preference = Preference::query()->where('user_id', $user->id) ->where('name', 'currencyPreference') ->first(['id', 'user_id', 'name', 'data', 'updated_at', 'created_at']) ; @@ -144,7 +144,7 @@ class UpgradesCurrencyPreferences extends Command try { $primaryCurrency = Amount::getTransactionCurrencyByCode($preference); } catch (FireflyException) { - $primaryCurrency = TransactionCurrency::where('code', 'EUR')->first(); + $primaryCurrency = TransactionCurrency::query()->where('code', 'EUR')->first(); } $user->currencies()->updateExistingPivot($primaryCurrency->id, ['user_default' => true]); $user->userGroup->currencies()->updateExistingPivot($primaryCurrency->id, ['group_default' => true]); diff --git a/app/Console/Commands/Upgrade/UpgradesJournalMetaData.php b/app/Console/Commands/Upgrade/UpgradesJournalMetaData.php index ff6c433256..ff0d9bc184 100644 --- a/app/Console/Commands/Upgrade/UpgradesJournalMetaData.php +++ b/app/Console/Commands/Upgrade/UpgradesJournalMetaData.php @@ -131,7 +131,7 @@ class UpgradesJournalMetaData extends Command $allIds = $this->getIdsForBudgets(); $chunks = array_chunk($allIds, 500); foreach ($chunks as $journalIds) { - $collected = TransactionJournal::whereIn('id', $journalIds)->with(['transactions', 'budgets', 'transactions.budgets'])->get(); + $collected = TransactionJournal::query()->whereIn('id', $journalIds)->with(['transactions', 'budgets', 'transactions.budgets'])->get(); $journals = $journals->merge($collected); } @@ -180,7 +180,7 @@ class UpgradesJournalMetaData extends Command $chunks = array_chunk($allIds, 500); foreach ($chunks as $chunk) { - $collected = TransactionJournal::whereIn('id', $chunk)->with(['transactions', 'categories', 'transactions.categories'])->get(); + $collected = TransactionJournal::query()->whereIn('id', $chunk)->with(['transactions', 'categories', 'transactions.categories'])->get(); $journals = $journals->merge($collected); } diff --git a/app/Console/Commands/Upgrade/UpgradesMultiPiggyBanks.php b/app/Console/Commands/Upgrade/UpgradesMultiPiggyBanks.php index 53488e5acc..a6deb2b485 100644 --- a/app/Console/Commands/Upgrade/UpgradesMultiPiggyBanks.php +++ b/app/Console/Commands/Upgrade/UpgradesMultiPiggyBanks.php @@ -105,7 +105,7 @@ class UpgradesMultiPiggyBanks extends Command { $this->repository = app(PiggyBankRepositoryInterface::class); $this->accountRepository = app(AccountRepositoryInterface::class); - $set = PiggyBank::whereNotNull('account_id')->get(); + $set = PiggyBank::query()->whereNotNull('account_id')->get(); Log::debug(sprintf('Will update %d piggy banks(s).', $set->count())); /** @var PiggyBank $piggyBank */ diff --git a/app/Console/Commands/Upgrade/UpgradesRecurrenceMetaData.php b/app/Console/Commands/Upgrade/UpgradesRecurrenceMetaData.php index 1be87e4fbd..9ab53d5b14 100644 --- a/app/Console/Commands/Upgrade/UpgradesRecurrenceMetaData.php +++ b/app/Console/Commands/Upgrade/UpgradesRecurrenceMetaData.php @@ -104,7 +104,7 @@ class UpgradesRecurrenceMetaData extends Command { $count = 0; // get all recurrence meta data: - $collection = RecurrenceMeta::with('recurrence')->get(); + $collection = RecurrenceMeta::query()->with('recurrence')->get(); /** @var RecurrenceMeta $meta */ foreach ($collection as $meta) { diff --git a/app/Console/Commands/Upgrade/UpgradesRuleActions.php b/app/Console/Commands/Upgrade/UpgradesRuleActions.php index 20664ce64d..78ef237238 100644 --- a/app/Console/Commands/Upgrade/UpgradesRuleActions.php +++ b/app/Console/Commands/Upgrade/UpgradesRuleActions.php @@ -106,7 +106,7 @@ class UpgradesRuleActions extends Command 'move_descr_to_notes', 'move_notes_to_descr', ]; - $actions = RuleAction::whereIn('action_type', $obsolete)->get(); + $actions = RuleAction::query()->whereIn('action_type', $obsolete)->get(); /** @var RuleAction $action */ foreach ($actions as $action) { diff --git a/app/Console/Commands/Upgrade/UpgradesWebhooks.php b/app/Console/Commands/Upgrade/UpgradesWebhooks.php index d75f6071d6..6515800b6b 100644 --- a/app/Console/Commands/Upgrade/UpgradesWebhooks.php +++ b/app/Console/Commands/Upgrade/UpgradesWebhooks.php @@ -84,9 +84,9 @@ class UpgradesWebhooks extends Command return; } - $deliveryModel = WebhookDeliveryModel::where('key', $delivery->value)->first(); - $responseModel = WebhookResponseModel::where('key', $response->value)->first(); - $triggerModel = WebhookTriggerModel::where('key', $trigger->value)->first(); + $deliveryModel = WebhookDeliveryModel::query()->where('key', $delivery->value)->first(); + $responseModel = WebhookResponseModel::query()->where('key', $response->value)->first(); + $triggerModel = WebhookTriggerModel::query()->where('key', $trigger->value)->first(); if (in_array(null, [$deliveryModel, $responseModel, $triggerModel], true)) { $this->friendlyError(sprintf('[b] Webhook #%d has an invalid delivery, response or trigger model. Will not upgrade.', $webhook->id)); @@ -104,7 +104,7 @@ class UpgradesWebhooks extends Command private function upgradeWebhooks(): void { - $set = Webhook::where('delivery', '>', 1)->orWhere('trigger', '>', 1)->orWhere('response', '>', 1)->get(); + $set = Webhook::query()->where('delivery', '>', 1)->orWhere('trigger', '>', 1)->orWhere('response', '>', 1)->get(); /** @var Webhook $webhook */ foreach ($set as $webhook) { diff --git a/app/Factory/AccountFactory.php b/app/Factory/AccountFactory.php index f665de20ba..4265b11ae5 100644 --- a/app/Factory/AccountFactory.php +++ b/app/Factory/AccountFactory.php @@ -157,7 +157,7 @@ class AccountFactory if (null === $result) { $types = config(sprintf('firefly.accountTypeByIdentifier.%s', $accountTypeName)) ?? []; if (0 !== count($types)) { - $result = AccountType::whereIn('type', $types)->first(); + $result = AccountType::query()->whereIn('type', $types)->first(); } } if (null === $result) { diff --git a/app/Factory/TransactionCurrencyFactory.php b/app/Factory/TransactionCurrencyFactory.php index 013a43db95..3b7ee88511 100644 --- a/app/Factory/TransactionCurrencyFactory.php +++ b/app/Factory/TransactionCurrencyFactory.php @@ -46,9 +46,9 @@ class TransactionCurrencyFactory $data['decimal_places'] = (int) $data['decimal_places']; // if the code already exists (deleted) // force delete it and then create the transaction: - $count = TransactionCurrency::withTrashed()->whereCode($data['code'])->count(); + $count = TransactionCurrency::query()->withTrashed()->whereCode($data['code'])->count(); if (1 === $count) { - $old = TransactionCurrency::withTrashed()->whereCode($data['code'])->first(); + $old = TransactionCurrency::query()->withTrashed()->whereCode($data['code'])->first(); $old->forceDelete(); Log::warning(sprintf('Force deleted old currency with ID #%d and code "%s".', $old->id, $data['code'])); } diff --git a/app/Factory/TransactionJournalFactory.php b/app/Factory/TransactionJournalFactory.php index 1ac24dc68d..e21089de5d 100644 --- a/app/Factory/TransactionJournalFactory.php +++ b/app/Factory/TransactionJournalFactory.php @@ -425,7 +425,7 @@ class TransactionJournalFactory Log::debug('Will verify duplicate!'); /** @var null|TransactionJournalMeta $result */ - $result = TransactionJournalMeta::withTrashed() + $result = TransactionJournalMeta::query()->withTrashed() ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'journal_meta.transaction_journal_id') ->whereNotNull('transaction_journals.id') ->where('transaction_journals.user_id', $this->user->id) diff --git a/app/Handlers/Observer/DeletedAccountObserver.php b/app/Handlers/Observer/DeletedAccountObserver.php index fc434afd50..bf7b9cab96 100644 --- a/app/Handlers/Observer/DeletedAccountObserver.php +++ b/app/Handlers/Observer/DeletedAccountObserver.php @@ -49,18 +49,18 @@ class DeletedAccountObserver $repository->destroy($attachment); } - $journalIds = Transaction::where('account_id', $account->id)->get(['transactions.transaction_journal_id'])->pluck('transaction_journal_id')->toArray(); + $journalIds = Transaction::query()->where('account_id', $account->id)->get(['transactions.transaction_journal_id'])->pluck('transaction_journal_id')->toArray(); $groupIds = array_map(function (array $item) { return $item['transaction_group_id']; - }, TransactionJournal::whereIn('id', $journalIds)->get(['transaction_journals.transaction_group_id'])->toArray()); + }, TransactionJournal::query()->whereIn('id', $journalIds)->get(['transaction_journals.transaction_group_id'])->toArray()); if (count($journalIds) > 0) { - Transaction::whereIn('transaction_journal_id', $journalIds)->delete(); - TransactionJournal::whereIn('id', $journalIds)->delete(); + Transaction::query()->whereIn('transaction_journal_id', $journalIds)->delete(); + TransactionJournal::query()->whereIn('id', $journalIds)->delete(); } if (count($groupIds) > 0) { - TransactionGroup::whereIn('id', $groupIds)->delete(); + TransactionGroup::query()->whereIn('id', $groupIds)->delete(); } Log::debug(sprintf('Delete %d journal(s)', count($journalIds))); diff --git a/app/Handlers/Observer/DeletedTransactionJournalObserver.php b/app/Handlers/Observer/DeletedTransactionJournalObserver.php index e8fd082a91..10aeca5204 100644 --- a/app/Handlers/Observer/DeletedTransactionJournalObserver.php +++ b/app/Handlers/Observer/DeletedTransactionJournalObserver.php @@ -50,8 +50,8 @@ class DeletedTransactionJournalObserver }); // delete all links: - TransactionJournalLink::where('source_id', $transactionJournal->id)->delete(); - TransactionJournalLink::where('destination_id', $transactionJournal->id)->delete(); + TransactionJournalLink::query()->where('source_id', $transactionJournal->id)->delete(); + TransactionJournalLink::query()->where('destination_id', $transactionJournal->id)->delete(); // update events // TODO move to repository diff --git a/app/Http/Controllers/Auth/ForgotPasswordController.php b/app/Http/Controllers/Auth/ForgotPasswordController.php index 13873ebe9f..82e9c0741f 100644 --- a/app/Http/Controllers/Auth/ForgotPasswordController.php +++ b/app/Http/Controllers/Auth/ForgotPasswordController.php @@ -84,7 +84,7 @@ final class ForgotPasswordController extends Controller // verify if the user is not a demo user. If so, we give him back an error. /** @var null|User $user */ - $user = User::where('email', $request->get('email'))->first(); + $user = User::query()->where('email', $request->get('email'))->first(); if (null !== $user && $repository->hasRole($user, 'demo')) { return back()->withErrors(['email' => (string) trans('firefly.cannot_reset_demo_user')]); diff --git a/app/Http/Controllers/DebugController.php b/app/Http/Controllers/DebugController.php index 6cbddee0a0..2a7938ae64 100644 --- a/app/Http/Controllers/DebugController.php +++ b/app/Http/Controllers/DebugController.php @@ -114,7 +114,7 @@ final class DebugController extends Controller Artisan::call('route:clear'); Artisan::call('view:clear'); - PeriodStatistic::where('id', '>', 0)->delete(); + PeriodStatistic::query()->where('id', '>', 0)->delete(); // also do some recalculations. Artisan::call('correction:recalculates-liabilities'); diff --git a/app/Http/Middleware/Range.php b/app/Http/Middleware/Range.php index 94b2f34789..3df7724625 100644 --- a/app/Http/Middleware/Range.php +++ b/app/Http/Middleware/Range.php @@ -73,7 +73,7 @@ class Range app('view')->share('listLength', $pref); // share security message: - if (FireflyConfig::has('upgrade_security_message') && FireflyConfig::has('upgrade_security_level')) { + if (FireflyConfig::query()->has('upgrade_security_message') && FireflyConfig::query()->has('upgrade_security_level')) { app('view')->share('upgrade_security_message', FireflyConfig::get('upgrade_security_message')->data); app('view')->share('upgrade_security_level', FireflyConfig::get('upgrade_security_level')->data); } diff --git a/app/Http/Requests/AccountFormRequest.php b/app/Http/Requests/AccountFormRequest.php index 78c8a18f37..d6c0351102 100644 --- a/app/Http/Requests/AccountFormRequest.php +++ b/app/Http/Requests/AccountFormRequest.php @@ -104,14 +104,14 @@ class AccountFormRequest extends FormRequest $types = implode(',', array_keys(config('firefly.subTitlesByIdentifier'))); $ccPaymentTypes = implode(',', array_keys(config('firefly.ccTypes'))); $rules = [ - 'name' => 'required|max:1024|min:1|uniqueAccountForUser', + 'name' => ['required', 'max:1024', 'min:1', 'uniqueAccountForUser'], 'opening_balance' => ['nullable', new IsValidAmount()], - 'opening_balance_date' => 'date|required_with:opening_balance|nullable', + 'opening_balance_date' => ['date', 'required_with:opening_balance', 'nullable'], 'iban' => ['iban', 'nullable', new UniqueIban(null, $this->convertString('objectType'))], - 'BIC' => 'bic|nullable', + 'BIC' => ['bic', 'nullable'], 'virtual_balance' => ['nullable', new IsValidAmount()], 'currency_id' => 'exists:transaction_currencies,id', - 'account_number' => 'min:1|max:255|uniqueAccountNumberForUser|nullable', + 'account_number' => ['min:1', 'max:255', 'uniqueAccountNumberForUser', 'nullable'], 'account_role' => 'in:'.$accountRoles, 'active' => 'boolean', 'cc_type' => 'in:'.$ccPaymentTypes, @@ -119,7 +119,7 @@ class AccountFormRequest extends FormRequest 'amount_currency_id_virtual_balance' => 'exists:transaction_currencies,id', 'what' => 'in:'.$types, 'interest_period' => 'in:daily,monthly,yearly', - 'notes' => 'min:1|max:32768|nullable', + 'notes' => ['min:1', 'max:32768', 'nullable'], ]; $rules = Location::requestRules($rules); diff --git a/app/Http/Requests/AttachmentFormRequest.php b/app/Http/Requests/AttachmentFormRequest.php index dd2ceb67c4..2538663fec 100644 --- a/app/Http/Requests/AttachmentFormRequest.php +++ b/app/Http/Requests/AttachmentFormRequest.php @@ -53,7 +53,7 @@ class AttachmentFormRequest extends FormRequest public function rules(): array { // fixed - return ['title' => 'min:1|max:255|nullable', 'notes' => 'min:1|max:32768|nullable']; + return ['title' => ['min:1', 'max:255', 'nullable'], 'notes' => ['min:1', 'max:32768', 'nullable']]; } public function withValidator(Validator $validator): void diff --git a/app/Http/Requests/BillStoreRequest.php b/app/Http/Requests/BillStoreRequest.php index 5b696bb05f..17ab1c55e1 100644 --- a/app/Http/Requests/BillStoreRequest.php +++ b/app/Http/Requests/BillStoreRequest.php @@ -68,16 +68,16 @@ class BillStoreRequest extends FormRequest public function rules(): array { return [ - 'name' => 'required|min:1|max:255|uniqueObjectForUser:bills,name', + 'name' => ['required', 'min:1', 'max:255', 'uniqueObjectForUser:bills,name'], 'amount_min' => ['required', new IsValidPositiveAmount()], 'amount_max' => ['required', new IsValidPositiveAmount()], - 'transaction_currency_id' => 'required|exists:transaction_currencies,id', - 'date' => 'required|date', - 'notes' => 'min:1|max:32768|nullable', - 'bill_end_date' => 'nullable|date', - 'extension_date' => 'nullable|date', + 'transaction_currency_id' => ['required', 'exists:transaction_currencies,id'], + 'date' => ['required', 'date'], + 'notes' => ['min:1', 'max:32768', 'nullable'], + 'bill_end_date' => ['nullable', 'date'], + 'extension_date' => ['nullable', 'date'], 'repeat_freq' => sprintf('required|in:%s', implode(',', config('firefly.bill_periods'))), - 'skip' => 'required|integer|gte:0|lte:31', + 'skip' => ['required', 'integer', 'gte:0', 'lte:31'], 'active' => 'boolean', ]; } diff --git a/app/Http/Requests/BillUpdateRequest.php b/app/Http/Requests/BillUpdateRequest.php index 6959c307cd..195e00b9e0 100644 --- a/app/Http/Requests/BillUpdateRequest.php +++ b/app/Http/Requests/BillUpdateRequest.php @@ -75,14 +75,14 @@ class BillUpdateRequest extends FormRequest 'name' => sprintf('required|min:1|max:255|uniqueObjectForUser:bills,name,%d', $bill->id), 'amount_min' => ['required', new IsValidPositiveAmount()], 'amount_max' => ['required', new IsValidPositiveAmount()], - 'transaction_currency_id' => 'required|exists:transaction_currencies,id', - 'date' => 'required|date', - 'bill_end_date' => 'nullable|date', - 'extension_date' => 'nullable|date', + 'transaction_currency_id' => ['required', 'exists:transaction_currencies,id'], + 'date' => ['required', 'date'], + 'bill_end_date' => ['nullable', 'date'], + 'extension_date' => ['nullable', 'date'], 'repeat_freq' => sprintf('required|in:%s', implode(',', config('firefly.bill_periods'))), - 'skip' => 'required|integer|gte:0|lte:31', + 'skip' => ['required', 'integer', 'gte:0', 'lte:31'], 'active' => 'boolean', - 'notes' => 'min:1|max:32768|nullable', + 'notes' => ['min:1', 'max:32768', 'nullable'], ]; } diff --git a/app/Http/Requests/BudgetFormStoreRequest.php b/app/Http/Requests/BudgetFormStoreRequest.php index 06803814aa..befdbba4f9 100644 --- a/app/Http/Requests/BudgetFormStoreRequest.php +++ b/app/Http/Requests/BudgetFormStoreRequest.php @@ -63,13 +63,13 @@ class BudgetFormStoreRequest extends FormRequest public function rules(): array { return [ - 'name' => 'required|min:1|max:255|uniqueObjectForUser:budgets,name', - 'active' => 'numeric|min:0|max:1', - 'auto_budget_type' => 'numeric|integer|gte:0|lte:3', + 'name' => ['required', 'min:1', 'max:255', 'uniqueObjectForUser:budgets,name'], + 'active' => ['numeric', 'min:0', 'max:1'], + 'auto_budget_type' => ['numeric', 'integer', 'gte:0', 'lte:3'], 'auto_budget_currency_id' => 'exists:transaction_currencies,id', 'auto_budget_amount' => ['required_if:auto_budget_type,1', 'required_if:auto_budget_type,2', new IsValidPositiveAmount()], 'auto_budget_period' => 'in:daily,weekly,monthly,quarterly,half_year,yearly', - 'notes' => 'min:1|max:32768|nullable', + 'notes' => ['min:1', 'max:32768', 'nullable'], ]; } diff --git a/app/Http/Requests/BudgetFormUpdateRequest.php b/app/Http/Requests/BudgetFormUpdateRequest.php index daf52e51c7..0e4d58f1e3 100644 --- a/app/Http/Requests/BudgetFormUpdateRequest.php +++ b/app/Http/Requests/BudgetFormUpdateRequest.php @@ -75,12 +75,12 @@ class BudgetFormUpdateRequest extends FormRequest return [ 'name' => $nameRule, - 'active' => 'numeric|min:0|max:1', - 'auto_budget_type' => 'numeric|integer|gte:0|lte:31', + 'active' => ['numeric', 'min:0', 'max:1'], + 'auto_budget_type' => ['numeric', 'integer', 'gte:0', 'lte:31'], 'auto_budget_currency_id' => 'exists:transaction_currencies,id', 'auto_budget_amount' => ['required_if:auto_budget_type,1', 'required_if:auto_budget_type,2|numeric', new IsValidPositiveAmount()], 'auto_budget_period' => 'in:daily,weekly,monthly,quarterly,half_year,yearly', - 'notes' => 'min:1|max:32768|nullable', + 'notes' => ['min:1', 'max:32768', 'nullable'], ]; } diff --git a/app/Http/Requests/BudgetIncomeRequest.php b/app/Http/Requests/BudgetIncomeRequest.php index 5e10753e49..79ace5ccf6 100644 --- a/app/Http/Requests/BudgetIncomeRequest.php +++ b/app/Http/Requests/BudgetIncomeRequest.php @@ -44,7 +44,7 @@ class BudgetIncomeRequest extends FormRequest public function rules(): array { // fixed - return ['amount' => ['required', new IsValidPositiveAmount()], 'start' => 'required|date|before:end', 'end' => 'required|date|after:start']; + return ['amount' => ['required', new IsValidPositiveAmount()], 'start' => ['required', 'date', 'before:end'], 'end' => ['required', 'date', 'after:start']]; } public function withValidator(Validator $validator): void diff --git a/app/Http/Requests/BulkEditJournalRequest.php b/app/Http/Requests/BulkEditJournalRequest.php index 16114324dd..f01dd39e2e 100644 --- a/app/Http/Requests/BulkEditJournalRequest.php +++ b/app/Http/Requests/BulkEditJournalRequest.php @@ -45,7 +45,7 @@ class BulkEditJournalRequest extends FormRequest public function rules(): array { // fixed - return ['journals.*' => 'required|belongsToUser:transaction_journals,id', 'tags_action' => 'in:no_nothing,do_replace,do_append']; + return ['journals.*' => ['required', 'belongsToUser:transaction_journals,id'], 'tags_action' => 'in:no_nothing,do_replace,do_append']; } public function withValidator(Validator $validator): void diff --git a/app/Http/Requests/CategoryFormRequest.php b/app/Http/Requests/CategoryFormRequest.php index 93ab081178..d9cf9456a8 100644 --- a/app/Http/Requests/CategoryFormRequest.php +++ b/app/Http/Requests/CategoryFormRequest.php @@ -63,7 +63,7 @@ class CategoryFormRequest extends FormRequest } // fixed - return ['name' => $nameRule, 'notes' => 'min:1|max:32768|nullable']; + return ['name' => $nameRule, 'notes' => ['min:1', 'max:32768', 'nullable']]; } public function withValidator(Validator $validator): void diff --git a/app/Http/Requests/ConfigurationRequest.php b/app/Http/Requests/ConfigurationRequest.php index 58eacb58c3..ab70eec2a9 100644 --- a/app/Http/Requests/ConfigurationRequest.php +++ b/app/Http/Requests/ConfigurationRequest.php @@ -62,15 +62,15 @@ class ConfigurationRequest extends FormRequest { // fixed return [ - 'single_user_mode' => 'min:0|max:1|numeric', - 'enable_exchange_rates' => 'min:0|max:1|numeric', - 'use_running_balance' => 'min:0|max:1|numeric', - 'enable_external_map' => 'min:0|max:1|numeric', - 'enable_external_rates' => 'min:0|max:1|numeric', - 'allow_webhooks' => 'min:0|max:1|numeric', - 'enable_batch_processing' => 'min:0|max:1|numeric', - 'valid_url_protocols' => 'min:0|max:255', - 'is_demo_site' => 'min:0|max:1|numeric', + 'single_user_mode' => ['min:0', 'max:1', 'numeric'], + 'enable_exchange_rates' => ['min:0', 'max:1', 'numeric'], + 'use_running_balance' => ['min:0', 'max:1', 'numeric'], + 'enable_external_map' => ['min:0', 'max:1', 'numeric'], + 'enable_external_rates' => ['min:0', 'max:1', 'numeric'], + 'allow_webhooks' => ['min:0', 'max:1', 'numeric'], + 'enable_batch_processing' => ['min:0', 'max:1', 'numeric'], + 'valid_url_protocols' => ['min:0', 'max:255'], + 'is_demo_site' => ['min:0', 'max:1', 'numeric'], ]; } diff --git a/app/Http/Requests/CurrencyFormRequest.php b/app/Http/Requests/CurrencyFormRequest.php index 77e4cb92b2..b648f7e77a 100644 --- a/app/Http/Requests/CurrencyFormRequest.php +++ b/app/Http/Requests/CurrencyFormRequest.php @@ -61,10 +61,10 @@ class CurrencyFormRequest extends FormRequest { // fixed $rules = [ - 'name' => 'required|max:48|min:1|uniqueCurrencyName', - 'code' => 'required|min:3|max:51|uniqueCurrencyCode', - 'symbol' => 'required|min:1|max:51|uniqueCurrencySymbol', - 'decimal_places' => 'required|min:0|max:12|numeric', + 'name' => ['required', 'max:48', 'min:1', 'uniqueCurrencyName'], + 'code' => ['required', 'min:3', 'max:51', 'uniqueCurrencyCode'], + 'symbol' => ['required', 'min:1', 'max:51', 'uniqueCurrencySymbol'], + 'decimal_places' => ['required', 'min:0', 'max:12', 'numeric'], 'enabled' => 'in:0,1', ]; @@ -73,10 +73,10 @@ class CurrencyFormRequest extends FormRequest if (null !== $currency) { return [ - 'name' => 'required|max:48|min:1', - 'code' => 'required|min:3|max:51', - 'symbol' => 'required|min:1|max:51', - 'decimal_places' => 'required|min:0|max:12|numeric', + 'name' => ['required', 'max:48', 'min:1'], + 'code' => ['required', 'min:3', 'max:51'], + 'symbol' => ['required', 'min:1', 'max:51'], + 'decimal_places' => ['required', 'min:0', 'max:12', 'numeric'], 'enabled' => 'in:0,1', ]; } diff --git a/app/Http/Requests/EmailFormRequest.php b/app/Http/Requests/EmailFormRequest.php index f3d077c309..912925de07 100644 --- a/app/Http/Requests/EmailFormRequest.php +++ b/app/Http/Requests/EmailFormRequest.php @@ -45,7 +45,7 @@ class EmailFormRequest extends FormRequest public function rules(): array { // fixed - return ['email' => 'required|email']; + return ['email' => ['required', 'email']]; } public function withValidator(Validator $validator): void diff --git a/app/Http/Requests/ExistingTokenFormRequest.php b/app/Http/Requests/ExistingTokenFormRequest.php index 3be5efa3fc..4b45efbe5c 100644 --- a/app/Http/Requests/ExistingTokenFormRequest.php +++ b/app/Http/Requests/ExistingTokenFormRequest.php @@ -43,7 +43,7 @@ class ExistingTokenFormRequest extends FormRequest public function rules(): array { // fixed - return ['password' => 'required|currentPassword', 'code' => 'required|existingMfaCode']; + return ['password' => ['required', 'currentPassword'], 'code' => ['required', 'existingMfaCode']]; } public function withValidator(Validator $validator): void diff --git a/app/Http/Requests/InviteUserFormRequest.php b/app/Http/Requests/InviteUserFormRequest.php index 7febb59679..a49f9b4635 100644 --- a/app/Http/Requests/InviteUserFormRequest.php +++ b/app/Http/Requests/InviteUserFormRequest.php @@ -45,7 +45,7 @@ class InviteUserFormRequest extends FormRequest */ public function rules(): array { - return ['invited_user' => 'required|email|unique:invited_users,email']; + return ['invited_user' => ['required', 'email', 'unique:invited_users,email']]; } public function withValidator(Validator $validator): void diff --git a/app/Http/Requests/LinkTypeFormRequest.php b/app/Http/Requests/LinkTypeFormRequest.php index 3c8bf21cc0..3f0e8450b6 100644 --- a/app/Http/Requests/LinkTypeFormRequest.php +++ b/app/Http/Requests/LinkTypeFormRequest.php @@ -59,8 +59,8 @@ class LinkTypeFormRequest extends FormRequest return [ 'id' => $idRule, 'name' => $nameRule, - 'inward' => 'required|max:255|min:1|different:outward', - 'outward' => 'required|max:255|min:1|different:inward', + 'inward' => ['required', 'max:255', 'min:1', 'different:outward'], + 'outward' => ['required', 'max:255', 'min:1', 'different:inward'], ]; } diff --git a/app/Http/Requests/MassDeleteJournalRequest.php b/app/Http/Requests/MassDeleteJournalRequest.php index 224d0a8aac..29dd674920 100644 --- a/app/Http/Requests/MassDeleteJournalRequest.php +++ b/app/Http/Requests/MassDeleteJournalRequest.php @@ -43,7 +43,7 @@ class MassDeleteJournalRequest extends FormRequest public function rules(): array { // fixed - return ['confirm_mass_delete.*' => 'required|belongsToUser:transaction_journals,id']; + return ['confirm_mass_delete.*' => ['required', 'belongsToUser:transaction_journals,id']]; } public function withValidator(Validator $validator): void diff --git a/app/Http/Requests/MassEditJournalRequest.php b/app/Http/Requests/MassEditJournalRequest.php index 25963c50b2..febcbb8814 100644 --- a/app/Http/Requests/MassEditJournalRequest.php +++ b/app/Http/Requests/MassEditJournalRequest.php @@ -45,10 +45,10 @@ class MassEditJournalRequest extends FormRequest // fixed return [ - 'description.*' => 'required|min:1|max:1024', - 'source_id.*' => 'numeric|belongsToUser:accounts,id', - 'destination_id.*' => 'numeric|belongsToUser:accounts,id', - 'journals.*' => 'numeric|belongsToUser:transaction_journals,id', + 'description.*' => ['required', 'min:1', 'max:1024'], + 'source_id.*' => ['numeric', 'belongsToUser:accounts,id'], + 'destination_id.*' => ['numeric', 'belongsToUser:accounts,id'], + 'journals.*' => ['numeric', 'belongsToUser:transaction_journals,id'], 'revenue_account' => 'max:255', 'expense_account' => 'max:255', ]; diff --git a/app/Http/Requests/NewUserFormRequest.php b/app/Http/Requests/NewUserFormRequest.php index c0183b01a0..26cf39b46f 100644 --- a/app/Http/Requests/NewUserFormRequest.php +++ b/app/Http/Requests/NewUserFormRequest.php @@ -47,7 +47,7 @@ class NewUserFormRequest extends FormRequest { // fixed return [ - 'bank_name' => 'required|min:1|max:255', + 'bank_name' => ['required', 'min:1', 'max:255'], 'bank_balance' => ['required', new IsValidAmount()], 'savings_balance' => ['nullable', new IsValidAmount()], 'credit_card_limit' => ['nullable', new IsValidAmount()], diff --git a/app/Http/Requests/PiggyBankStoreRequest.php b/app/Http/Requests/PiggyBankStoreRequest.php index 4081483eb1..c0a35f382f 100644 --- a/app/Http/Requests/PiggyBankStoreRequest.php +++ b/app/Http/Requests/PiggyBankStoreRequest.php @@ -75,15 +75,15 @@ class PiggyBankStoreRequest extends FormRequest public function rules(): array { return [ - 'name' => 'required|min:1|max:255|uniquePiggyBankForUser', - 'accounts' => 'required|array', - 'accounts.*' => 'required|belongsToUser:accounts', + 'name' => ['required', 'min:1', 'max:255', 'uniquePiggyBankForUser'], + 'accounts' => ['required', 'array'], + 'accounts.*' => ['required', 'belongsToUser:accounts'], 'target_amount' => ['nullable', new IsValidPositiveAmount()], 'start_date' => 'date', - 'target_date' => 'date|nullable', - 'order' => 'integer|min:1', - 'object_group' => 'min:0|max:255', - 'notes' => 'min:1|max:32768|nullable', + 'target_date' => ['date', 'nullable'], + 'order' => ['integer', 'min:1'], + 'object_group' => ['min:0', 'max:255'], + 'notes' => ['min:1', 'max:32768', 'nullable'], ]; } diff --git a/app/Http/Requests/PiggyBankUpdateRequest.php b/app/Http/Requests/PiggyBankUpdateRequest.php index e4d236aff0..78b5d03693 100644 --- a/app/Http/Requests/PiggyBankUpdateRequest.php +++ b/app/Http/Requests/PiggyBankUpdateRequest.php @@ -80,15 +80,15 @@ class PiggyBankUpdateRequest extends FormRequest return [ 'name' => sprintf('required|min:1|max:255|uniquePiggyBankForUser:%d', $piggy->id), - 'accounts' => 'required|array', - 'accounts.*' => 'required|belongsToUser:accounts', + 'accounts' => ['required', 'array'], + 'accounts.*' => ['required', 'belongsToUser:accounts'], 'target_amount' => ['nullable', new IsValidPositiveAmount()], 'start_date' => 'date', 'transaction_currency_id' => 'exists:transaction_currencies,id', - 'target_date' => 'date|nullable', - 'order' => 'integer|max:32768|min:1', - 'object_group' => 'min:0|max:255', - 'notes' => 'min:1|max:32768|nullable', + 'target_date' => ['date', 'nullable'], + 'order' => ['integer', 'max:32768', 'min:1'], + 'object_group' => ['min:0', 'max:255'], + 'notes' => ['min:1', 'max:32768', 'nullable'], ]; } diff --git a/app/Http/Requests/ProfileFormRequest.php b/app/Http/Requests/ProfileFormRequest.php index f76fa7a302..5fed5db9dc 100644 --- a/app/Http/Requests/ProfileFormRequest.php +++ b/app/Http/Requests/ProfileFormRequest.php @@ -45,7 +45,7 @@ class ProfileFormRequest extends FormRequest // fixed return [ 'current_password' => 'required', - 'new_password' => 'required|confirmed|secure_password|min:16', + 'new_password' => ['required', 'confirmed', 'secure_password', 'min:16'], 'new_password_confirmation' => 'required', ]; } diff --git a/app/Http/Requests/ReconciliationStoreRequest.php b/app/Http/Requests/ReconciliationStoreRequest.php index 1cfae0eab4..91866756b1 100644 --- a/app/Http/Requests/ReconciliationStoreRequest.php +++ b/app/Http/Requests/ReconciliationStoreRequest.php @@ -71,13 +71,13 @@ class ReconciliationStoreRequest extends FormRequest public function rules(): array { return [ - 'start' => 'required|date', - 'end' => 'required|date', + 'start' => ['required', 'date'], + 'end' => ['required', 'date'], 'startBalance' => ['nullable', new IsValidAmount()], 'endBalance' => ['nullable', new IsValidAmount()], 'difference' => ['required', new IsValidAmount()], 'journals' => [new ValidJournals()], - 'reconcile' => 'required|in:create,nothing', + 'reconcile' => ['required', 'in:create,nothing'], ]; } diff --git a/app/Http/Requests/RecurrenceFormRequest.php b/app/Http/Requests/RecurrenceFormRequest.php index 293551a908..b14a6ec2cf 100644 --- a/app/Http/Requests/RecurrenceFormRequest.php +++ b/app/Http/Requests/RecurrenceFormRequest.php @@ -159,35 +159,35 @@ class RecurrenceFormRequest extends FormRequest $before = today(config('app.timezone'))->addYears(25); $rules = [ // mandatory info for recurrence. - 'title' => 'required|min:1|max:255|uniqueObjectForUser:recurrences,title', + 'title' => ['required', 'min:1', 'max:255', 'uniqueObjectForUser:recurrences,title'], 'first_date' => sprintf('required|date|before:%s|after:%s', $before->format('Y-m-d'), $today->format('Y-m-d')), 'repetition_type' => ['required', new ValidRecurrenceRepetitionValue(), new ValidRecurrenceRepetitionType(), 'min:1', 'max:32'], - 'skip' => 'required|numeric|integer|gte:0|lte:31', - 'notes' => 'min:1|max:32768|nullable', + 'skip' => ['required', 'numeric', 'integer', 'gte:0', 'lte:31'], + 'notes' => ['min:1', 'max:32768', 'nullable'], // optional for recurrence: - 'recurring_description' => 'min:0|max:32768', - 'active' => 'numeric|min:0|max:1', - 'apply_rules' => 'numeric|min:0|max:1', + 'recurring_description' => ['min:0', 'max:32768'], + 'active' => ['numeric', 'min:0', 'max:1'], + 'apply_rules' => ['numeric', 'min:0', 'max:1'], // mandatory for transaction: - 'transaction_description' => 'required|min:1|max:255', - 'transaction_type' => 'required|in:withdrawal,deposit,transfer', - 'transaction_currency_id' => 'required|exists:transaction_currencies,id', + 'transaction_description' => ['required', 'min:1', 'max:255'], + 'transaction_type' => ['required', 'in:withdrawal,deposit,transfer'], + 'transaction_currency_id' => ['required', 'exists:transaction_currencies,id'], 'amount' => ['required', new IsValidPositiveAmount()], // mandatory account info: - 'source_id' => 'numeric|belongsToUser:accounts,id|nullable', - 'source_name' => 'min:1|max:255|nullable', - 'destination_id' => 'numeric|belongsToUser:accounts,id|nullable', - 'destination_name' => 'min:1|max:255|nullable', + 'source_id' => ['numeric', 'belongsToUser:accounts,id', 'nullable'], + 'source_name' => ['min:1', 'max:255', 'nullable'], + 'destination_id' => ['numeric', 'belongsToUser:accounts,id', 'nullable'], + 'destination_name' => ['min:1', 'max:255', 'nullable'], // foreign amount data: 'foreign_amount' => ['nullable', new IsValidPositiveAmount()], // optional fields: - 'budget_id' => 'mustExist:budgets,id|belongsToUser:budgets,id|nullable', - 'bill_id' => 'mustExist:bills,id|belongsToUser:bills,id|nullable', - 'category' => 'min:1|max:255|nullable', - 'tags' => 'min:1|max:255|nullable', + 'budget_id' => ['mustExist:budgets,id', 'belongsToUser:budgets,id', 'nullable'], + 'bill_id' => ['mustExist:bills,id', 'belongsToUser:bills,id', 'nullable'], + 'category' => ['min:1', 'max:255', 'nullable'], + 'tags' => ['min:1', 'max:255', 'nullable'], ]; if ($this->convertInteger('foreign_currency_id') > 0) { $rules['foreign_currency_id'] = 'exists:transaction_currencies,id'; diff --git a/app/Http/Requests/RuleFormRequest.php b/app/Http/Requests/RuleFormRequest.php index fa50a0113d..d72130d97e 100644 --- a/app/Http/Requests/RuleFormRequest.php +++ b/app/Http/Requests/RuleFormRequest.php @@ -103,11 +103,11 @@ class RuleFormRequest extends FormRequest // initial set of rules: $rules = [ - 'title' => 'required|min:1|max:255|uniqueObjectForUser:rules,title', - 'description' => 'min:1|max:32768|nullable', + 'title' => ['required', 'min:1', 'max:255', 'uniqueObjectForUser:rules,title'], + 'description' => ['min:1', 'max:32768', 'nullable'], 'stop_processing' => 'boolean', - 'rule_group_id' => 'required|belongsToUser:rule_groups', - 'trigger' => 'required|in:store-journal,update-journal,manual-activation', + 'rule_group_id' => ['required', 'belongsToUser:rule_groups'], + 'trigger' => ['required', 'in:store-journal,update-journal,manual-activation'], 'triggers.*.type' => 'required|in:'.implode(',', $validTriggers), 'triggers.*.value' => sprintf('required_if:triggers.*.type,%s|max:1024|min:1|ruleTriggerValue', $contextTriggers), 'actions.*.type' => 'required|in:'.implode(',', $validActions), diff --git a/app/Http/Requests/RuleGroupFormRequest.php b/app/Http/Requests/RuleGroupFormRequest.php index 307a92f24c..8a0e249e5f 100644 --- a/app/Http/Requests/RuleGroupFormRequest.php +++ b/app/Http/Requests/RuleGroupFormRequest.php @@ -68,7 +68,7 @@ class RuleGroupFormRequest extends FormRequest $titleRule = 'required|min:1|max:255|uniqueObjectForUser:rule_groups,title,'.$ruleGroup->id; } - return ['title' => $titleRule, 'description' => 'min:1|max:32768|nullable', 'active' => [new IsBoolean()]]; + return ['title' => $titleRule, 'description' => ['min:1', 'max:32768', 'nullable'], 'active' => [new IsBoolean()]]; } public function withValidator(Validator $validator): void diff --git a/app/Http/Requests/SelectTransactionsRequest.php b/app/Http/Requests/SelectTransactionsRequest.php index 044fd35d95..9260cb90e2 100644 --- a/app/Http/Requests/SelectTransactionsRequest.php +++ b/app/Http/Requests/SelectTransactionsRequest.php @@ -42,7 +42,7 @@ class SelectTransactionsRequest extends FormRequest */ public function rules(): array { - return ['accounts' => 'required', 'accounts.*' => 'required|exists:accounts,id|belongsToUser:accounts']; + return ['accounts' => 'required', 'accounts.*' => ['required', 'exists:accounts,id', 'belongsToUser:accounts']]; } public function withValidator(Validator $validator): void diff --git a/app/Http/Requests/TagFormRequest.php b/app/Http/Requests/TagFormRequest.php index ef15921da3..a4115e2601 100644 --- a/app/Http/Requests/TagFormRequest.php +++ b/app/Http/Requests/TagFormRequest.php @@ -75,8 +75,8 @@ class TagFormRequest extends FormRequest $rules = [ 'tag' => $tagRule, 'id' => $idRule, - 'description' => 'max:32768|min:1|nullable', - 'date' => 'date|nullable|after:1970-01-02|before:2038-01-17', + 'description' => ['max:32768', 'min:1', 'nullable'], + 'date' => ['date', 'nullable', 'after:1970-01-02', 'before:2038-01-17'], ]; return Location::requestRules($rules); diff --git a/app/Http/Requests/TestRuleFormRequest.php b/app/Http/Requests/TestRuleFormRequest.php index ccf1d7e499..b5c0d596b3 100644 --- a/app/Http/Requests/TestRuleFormRequest.php +++ b/app/Http/Requests/TestRuleFormRequest.php @@ -50,7 +50,7 @@ class TestRuleFormRequest extends FormRequest return [ 'rule-trigger.*' => 'required|max:1024|min:1|in:'.implode(',', $validTriggers), - 'rule-trigger-value.*' => 'required|max:1024|min:1|ruleTriggerValue', + 'rule-trigger-value.*' => ['required', 'max:1024', 'min:1', 'ruleTriggerValue'], ]; } diff --git a/app/Http/Requests/TokenFormRequest.php b/app/Http/Requests/TokenFormRequest.php index 580b787587..3ef10a1554 100644 --- a/app/Http/Requests/TokenFormRequest.php +++ b/app/Http/Requests/TokenFormRequest.php @@ -43,7 +43,7 @@ class TokenFormRequest extends FormRequest public function rules(): array { // fixed - return ['password' => 'required|currentPassword', 'code' => 'required|2faCode']; + return ['password' => ['required', 'currentPassword'], 'code' => ['required', '2faCode']]; } public function withValidator(Validator $validator): void diff --git a/app/Http/Requests/TriggerRecurrenceRequest.php b/app/Http/Requests/TriggerRecurrenceRequest.php index 2f482badeb..3e1690f1d1 100644 --- a/app/Http/Requests/TriggerRecurrenceRequest.php +++ b/app/Http/Requests/TriggerRecurrenceRequest.php @@ -53,7 +53,7 @@ class TriggerRecurrenceRequest extends FormRequest */ public function rules(): array { - return ['date' => 'required|date']; + return ['date' => ['required', 'date']]; } public function withValidator(Validator $validator): void diff --git a/app/Http/Requests/UserFormRequest.php b/app/Http/Requests/UserFormRequest.php index 77321ebe02..243d88b758 100644 --- a/app/Http/Requests/UserFormRequest.php +++ b/app/Http/Requests/UserFormRequest.php @@ -59,12 +59,12 @@ class UserFormRequest extends FormRequest public function rules(): array { return [ - 'id' => 'required|exists:users,id', - 'email' => 'email|required', - 'password' => 'confirmed|secure_password', - 'blocked_code' => 'min:0|max:32|nullable', - 'blocked' => 'min:0|max:1|numeric', - 'is_owner' => 'min:0|max:1|numeric', + 'id' => ['required', 'exists:users,id'], + 'email' => ['email', 'required'], + 'password' => ['confirmed', 'secure_password'], + 'blocked_code' => ['min:0', 'max:32', 'nullable'], + 'blocked' => ['min:0', 'max:1', 'numeric'], + 'is_owner' => ['min:0', 'max:1', 'numeric'], ]; } diff --git a/app/Http/Requests/UserRegistrationRequest.php b/app/Http/Requests/UserRegistrationRequest.php index a4106f84ec..9abe6d8974 100644 --- a/app/Http/Requests/UserRegistrationRequest.php +++ b/app/Http/Requests/UserRegistrationRequest.php @@ -52,7 +52,7 @@ class UserRegistrationRequest extends FormRequest public function rules(): array { // fixed - return ['email' => 'email|required', 'password' => 'confirmed|secure_password']; + return ['email' => ['email', 'required'], 'password' => ['confirmed', 'secure_password']]; } public function withValidator(Validator $validator): void diff --git a/app/Listeners/Model/PiggyBank/CreatesPiggyBankEventForChangedAmount.php b/app/Listeners/Model/PiggyBank/CreatesPiggyBankEventForChangedAmount.php index 15a856af8e..d776b0177d 100644 --- a/app/Listeners/Model/PiggyBank/CreatesPiggyBankEventForChangedAmount.php +++ b/app/Listeners/Model/PiggyBank/CreatesPiggyBankEventForChangedAmount.php @@ -42,7 +42,7 @@ class CreatesPiggyBankEventForChangedAmount implements ShouldQueue $date = $journal->date ?? today(config('app.timezone')); // sanity check: event must not already exist for this journal and piggy bank. if (null !== $journal) { - $exists = PiggyBankEvent::where('piggy_bank_id', $event->piggyBank->id)->where('transaction_journal_id', $journal->id)->exists(); + $exists = PiggyBankEvent::query()->where('piggy_bank_id', $event->piggyBank->id)->where('transaction_journal_id', $journal->id)->exists(); if ($exists) { Log::warning('Already have event for this journal and piggy, will not create another.'); diff --git a/app/Listeners/Model/TransactionGroup/ProcessesUpdatedTransactionGroup.php b/app/Listeners/Model/TransactionGroup/ProcessesUpdatedTransactionGroup.php index e93e2c9af3..4d6fc8a250 100644 --- a/app/Listeners/Model/TransactionGroup/ProcessesUpdatedTransactionGroup.php +++ b/app/Listeners/Model/TransactionGroup/ProcessesUpdatedTransactionGroup.php @@ -128,7 +128,7 @@ class ProcessesUpdatedTransactionGroup $effect = 0; if (TransactionTypeEnum::TRANSFER->value === $type || TransactionTypeEnum::WITHDRAWAL->value === $type) { // set all source transactions to source account: - $effect += Transaction::whereIn('transaction_journal_id', $all) + $effect += Transaction::query()->whereIn('transaction_journal_id', $all) ->where('account_id', '!=', $sourceAccount->id) ->where('amount', '<', 0) ->update(['account_id' => $sourceAccount->id]) @@ -136,7 +136,7 @@ class ProcessesUpdatedTransactionGroup } if (TransactionTypeEnum::TRANSFER->value === $type || TransactionTypeEnum::DEPOSIT->value === $type) { // set all destination transactions to destination account: - $effect += Transaction::whereIn('transaction_journal_id', $all) + $effect += Transaction::query()->whereIn('transaction_journal_id', $all) ->where('account_id', '!=', $destAccount->id) ->where('amount', '>', 0) ->update(['account_id' => $destAccount->id]) diff --git a/app/Listeners/Model/TransactionGroup/SupportsGroupProcessingTrait.php b/app/Listeners/Model/TransactionGroup/SupportsGroupProcessingTrait.php index 0dfec15269..4889e96132 100644 --- a/app/Listeners/Model/TransactionGroup/SupportsGroupProcessingTrait.php +++ b/app/Listeners/Model/TransactionGroup/SupportsGroupProcessingTrait.php @@ -156,7 +156,7 @@ trait SupportsGroupProcessingTrait private function getFromInternalDate(array $ids): Carbon { - $entries = TransactionJournalMeta::whereIn('transaction_journal_id', $ids)->where('name', '_internal_previous_date')->get(['journal_meta.*']); + $entries = TransactionJournalMeta::query()->whereIn('transaction_journal_id', $ids)->where('name', '_internal_previous_date')->get(['journal_meta.*']); $array = $entries->toArray(); $return = today()->subDay(); if (count($array) > 0) { diff --git a/app/Listeners/Model/Webhook/SendsWebhookMessages.php b/app/Listeners/Model/Webhook/SendsWebhookMessages.php index 871593aaee..e7047a1684 100644 --- a/app/Listeners/Model/Webhook/SendsWebhookMessages.php +++ b/app/Listeners/Model/Webhook/SendsWebhookMessages.php @@ -43,7 +43,7 @@ class SendsWebhookMessages implements ShouldQueue } // kick off the job! - $messages = WebhookMessage::where('webhook_messages.sent', false) + $messages = WebhookMessage::query()->where('webhook_messages.sent', false) ->get(['webhook_messages.*']) ->filter(static fn (WebhookMessage $message): bool => $message->webhookAttempts()->count() <= 2) ->splice(0, 5) @@ -65,6 +65,6 @@ class SendsWebhookMessages implements ShouldQueue } // clean up sent messages table: - WebhookMessage::where('webhook_messages.sent', true)->where('webhook_messages.created_at', '<', now()->subDays(14))->delete(); + WebhookMessage::query()->where('webhook_messages.sent', true)->where('webhook_messages.created_at', '<', now()->subDays(14))->delete(); } } diff --git a/app/Listeners/Security/System/HandlesNewUserRegistration.php b/app/Listeners/Security/System/HandlesNewUserRegistration.php index f85201f19d..68e9d49c16 100644 --- a/app/Listeners/Security/System/HandlesNewUserRegistration.php +++ b/app/Listeners/Security/System/HandlesNewUserRegistration.php @@ -87,7 +87,7 @@ class HandlesNewUserRegistration implements ShouldQueue // create a new group. while ($groupExists) { - $groupExists = UserGroup::where('title', $groupTitle)->count() > 0; + $groupExists = UserGroup::query()->where('title', $groupTitle)->count() > 0; if (false === $groupExists) { $group = UserGroup::create(['title' => $groupTitle]); @@ -101,7 +101,7 @@ class HandlesNewUserRegistration implements ShouldQueue } /** @var null|UserRole $role */ - $role = UserRole::where('title', UserRoleEnum::OWNER->value)->first(); + $role = UserRole::query()->where('title', UserRoleEnum::OWNER->value)->first(); if (null === $role) { throw new FireflyException('The user role is unexpectedly empty. Did you run all migrations?'); } diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php index 6ad694e81c..1bde7e2687 100644 --- a/app/Repositories/Account/AccountRepository.php +++ b/app/Repositories/Account/AccountRepository.php @@ -293,7 +293,7 @@ class AccountRepository implements AccountRepositoryInterface, UserGroupInterfac public function getCashAccount(): Account { /** @var AccountType $type */ - $type = AccountType::where('type', AccountTypeEnum::CASH->value)->first(); + $type = AccountType::query()->where('type', AccountTypeEnum::CASH->value)->first(); /** @var AccountFactory $factory */ $factory = app(AccountFactory::class); @@ -432,7 +432,7 @@ class AccountRepository implements AccountRepositoryInterface, UserGroupInterfac $name = trans('firefly.reconciliation_account_name', ['name' => $account->name, 'currency' => $currency->code]); /** @var AccountType $type */ - $type = AccountType::where('type', AccountTypeEnum::RECONCILIATION->value)->first(); + $type = AccountType::query()->where('type', AccountTypeEnum::RECONCILIATION->value)->first(); /** @var null|Account $current */ $current = $this->user->accounts()->where('account_type_id', $type->id)->where('name', $name)->first(); @@ -466,7 +466,7 @@ class AccountRepository implements AccountRepositoryInterface, UserGroupInterfac } $currencyIds = array_unique($currencyIds); - return TransactionCurrency::whereIn('id', $currencyIds)->get(); + return TransactionCurrency::query()->whereIn('id', $currencyIds)->get(); } public function isLiability(Account $account): bool diff --git a/app/Repositories/AuditLogEntry/ALERepository.php b/app/Repositories/AuditLogEntry/ALERepository.php index 139fd075ff..faa0a922d2 100644 --- a/app/Repositories/AuditLogEntry/ALERepository.php +++ b/app/Repositories/AuditLogEntry/ALERepository.php @@ -36,13 +36,13 @@ class ALERepository implements ALERepositoryInterface public function getForId(string $model, int $modelId): Collection { // all Models have an ID. - return AuditLogEntry::where('auditable_id', $modelId)->where('auditable_type', $model)->get(); + return AuditLogEntry::query()->where('auditable_id', $modelId)->where('auditable_type', $model)->get(); } public function getForObject(Model $model): Collection { // all Models have an ID. - return AuditLogEntry::where('auditable_id', $model->id)->where('auditable_type', $model::class)->get(); + return AuditLogEntry::query()->where('auditable_id', $model->id)->where('auditable_type', $model::class)->get(); } public function store(array $data): AuditLogEntry diff --git a/app/Repositories/Bill/BillRepository.php b/app/Repositories/Bill/BillRepository.php index 030fa48c3c..cc33597740 100644 --- a/app/Repositories/Bill/BillRepository.php +++ b/app/Repositories/Bill/BillRepository.php @@ -102,7 +102,7 @@ class BillRepository implements BillRepositoryInterface, UserGroupInterface public function correctTransfers(): void { /** @var null|TransactionType $withdrawal */ - $withdrawal = TransactionType::where('type', TransactionTypeEnum::WITHDRAWAL->value)->first(); + $withdrawal = TransactionType::query()->where('type', TransactionTypeEnum::WITHDRAWAL->value)->first(); if (null === $withdrawal) { return; } diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.php index 091d752d5f..13bd7347fe 100644 --- a/app/Repositories/Budget/BudgetRepository.php +++ b/app/Repositories/Budget/BudgetRepository.php @@ -215,7 +215,7 @@ class BudgetRepository implements BudgetRepositoryInterface, UserGroupInterface public function cleanupBudgets(): bool { // delete limits with amount 0: - BudgetLimit::where('amount', 0)->delete(); + BudgetLimit::query()->where('amount', 0)->delete(); $budgets = $this->getActiveBudgets(); /** @@ -252,11 +252,11 @@ class BudgetRepository implements BudgetRepositoryInterface, UserGroupInterface foreach ($budgets as $budget) { DB::table('budget_transaction')->where('budget_id', $budget->id)->delete(); DB::table('budget_transaction_journal')->where('budget_id', $budget->id)->delete(); - RecurrenceTransactionMeta::where('name', 'budget_id') + RecurrenceTransactionMeta::query()->where('name', 'budget_id') ->where('value', (string) $budget->id) ->delete() ; - RuleAction::where('action_type', 'set_budget') + RuleAction::query()->where('action_type', 'set_budget') ->where('action_value', (string) $budget->id) ->delete() ; diff --git a/app/Repositories/Category/CategoryRepository.php b/app/Repositories/Category/CategoryRepository.php index 6e6443fd14..70f9ed0d23 100644 --- a/app/Repositories/Category/CategoryRepository.php +++ b/app/Repositories/Category/CategoryRepository.php @@ -89,8 +89,8 @@ class CategoryRepository implements CategoryRepositoryInterface, UserGroupInterf foreach ($categories as $category) { DB::table('category_transaction')->where('category_id', $category->id)->delete(); DB::table('category_transaction_journal')->where('category_id', $category->id)->delete(); - RecurrenceTransactionMeta::where('name', 'category_id')->where('value', $category->id)->delete(); - RuleAction::where('action_type', 'set_category')->where('action_value', $category->name)->delete(); + RecurrenceTransactionMeta::query()->where('name', 'category_id')->where('value', $category->id)->delete(); + RuleAction::query()->where('action_type', 'set_category')->where('action_value', $category->name)->delete(); $category->delete(); } Log::channel('audit')->info('Delete all categories through destroyAll'); diff --git a/app/Repositories/Currency/CurrencyRepository.php b/app/Repositories/Currency/CurrencyRepository.php index fc7857a22b..0f23730a26 100644 --- a/app/Repositories/Currency/CurrencyRepository.php +++ b/app/Repositories/Currency/CurrencyRepository.php @@ -86,7 +86,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf } // is being used in accounts: - $meta = AccountMeta::where('name', 'currency_id') + $meta = AccountMeta::query()->where('name', 'currency_id') ->where('data', json_encode((string) $currency->id)) ->count() ; @@ -97,7 +97,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf } // second search using integer check. - $meta = AccountMeta::where('name', 'currency_id') + $meta = AccountMeta::query()->where('name', 'currency_id') ->where('data', json_encode((int) $currency->id)) ->count() ; @@ -108,7 +108,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf } // is being used in bills: - $bills = Bill::where('transaction_currency_id', $currency->id)->count(); + $bills = Bill::query()->where('transaction_currency_id', $currency->id)->count(); if ($bills > 0) { Log::info(sprintf('Used in %d bills as currency, return true. ', $bills)); @@ -116,8 +116,8 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf } // is being used in recurring transactions - $recurringAmount = RecurrenceTransaction::where('transaction_currency_id', $currency->id)->count(); - $recurringForeign = RecurrenceTransaction::where('foreign_currency_id', $currency->id)->count(); + $recurringAmount = RecurrenceTransaction::query()->where('transaction_currency_id', $currency->id)->count(); + $recurringForeign = RecurrenceTransaction::query()->where('foreign_currency_id', $currency->id)->count(); if ($recurringAmount > 0 || $recurringForeign > 0) { Log::info(sprintf('Used in %d recurring transactions as (foreign) currency id, return true. ', $recurringAmount + $recurringForeign)); @@ -139,7 +139,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf } // is being used in available budgets - $availableBudgets = AvailableBudget::where('transaction_currency_id', $currency->id)->count(); + $availableBudgets = AvailableBudget::query()->where('transaction_currency_id', $currency->id)->count(); if ($availableBudgets > 0) { Log::info(sprintf('Used in %d available budgets as currency, return true. ', $availableBudgets)); @@ -147,7 +147,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf } // is being used in budget limits - $budgetLimit = BudgetLimit::where('transaction_currency_id', $currency->id)->count(); + $budgetLimit = BudgetLimit::query()->where('transaction_currency_id', $currency->id)->count(); if ($budgetLimit > 0) { Log::info(sprintf('Used in %d budget limits as currency, return true. ', $budgetLimit)); @@ -230,7 +230,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf public function findByName(string $name): ?TransactionCurrency { - return TransactionCurrency::where('name', $name)->first(); + return TransactionCurrency::query()->where('name', $name)->first(); } /** @@ -305,7 +305,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf */ public function getAll(): Collection { - $all = TransactionCurrency::orderBy('code', 'ASC')->get(); + $all = TransactionCurrency::query()->orderBy('code', 'ASC')->get(); $local = $this->get(); return $all->map(static function (TransactionCurrency $current) use ($local): TransactionCurrency { @@ -326,7 +326,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf */ public function getCompleteSet(): Collection { - return TransactionCurrency::where('enabled', true)->orderBy('code', 'ASC')->get(); + return TransactionCurrency::query()->where('enabled', true)->orderBy('code', 'ASC')->get(); } /** @@ -382,7 +382,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf public function searchCurrency(string $search, int $limit): Collection { - $query = TransactionCurrency::where('enabled', true)->orderBy('code', 'ASC'); + $query = TransactionCurrency::query()->where('enabled', true)->orderBy('code', 'ASC'); if ('' !== $search) { $query->whereLike('name', sprintf('%%%s%%', $search)); } @@ -466,6 +466,6 @@ class CurrencyRepository implements CurrencyRepositoryInterface, UserGroupInterf $count = $currency->transactions()->whereNull('deleted_at')->count() + $currency->transactionJournals()->whereNull('deleted_at')->count(); // also count foreign: - return $count + Transaction::where('foreign_currency_id', $currency->id)->count(); + return $count + Transaction::query()->where('foreign_currency_id', $currency->id)->count(); } } diff --git a/app/Repositories/Journal/JournalAPIRepository.php b/app/Repositories/Journal/JournalAPIRepository.php index 4d880039d7..7728fcaa81 100644 --- a/app/Repositories/Journal/JournalAPIRepository.php +++ b/app/Repositories/Journal/JournalAPIRepository.php @@ -87,7 +87,7 @@ class JournalAPIRepository implements JournalAPIRepositoryInterface, UserGroupIn { $events = $journal->piggyBankEvents()->get(); $events->each(static function (PiggyBankEvent $event): void { - $event->piggyBank = PiggyBank::withTrashed()->find($event->piggy_bank_id); + $event->piggyBank = PiggyBank::query()->withTrashed()->find($event->piggy_bank_id); }); return $events; diff --git a/app/Repositories/Journal/JournalCLIRepository.php b/app/Repositories/Journal/JournalCLIRepository.php index 9bc201c11f..82e684daac 100644 --- a/app/Repositories/Journal/JournalCLIRepository.php +++ b/app/Repositories/Journal/JournalCLIRepository.php @@ -98,7 +98,7 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface, UserGroupIn */ public function getJournalsWithoutGroup(): array { - return TransactionJournal::whereNull('transaction_group_id')->get(['id', 'user_id'])->toArray(); + return TransactionJournal::query()->whereNull('transaction_group_id')->get(['id', 'user_id'])->toArray(); } /** @@ -190,7 +190,7 @@ class JournalCLIRepository implements JournalCLIRepositoryInterface, UserGroupIn } $journalIds = array_unique($journalIds); - return TransactionJournal::with(['transactions'])->whereIn('id', $journalIds)->get(); + return TransactionJournal::query()->with(['transactions'])->whereIn('id', $journalIds)->get(); } /** diff --git a/app/Repositories/Journal/JournalRepository.php b/app/Repositories/Journal/JournalRepository.php index 2f68552902..3ff98d3898 100644 --- a/app/Repositories/Journal/JournalRepository.php +++ b/app/Repositories/Journal/JournalRepository.php @@ -79,7 +79,7 @@ class JournalRepository implements JournalRepositoryInterface, UserGroupInterfac #[Override] public function countByNotes(string $value, bool $includeDeleted): int { - $search = Note::where('noteable_type', TransactionJournal::class) + $search = Note::query()->where('noteable_type', TransactionJournal::class) ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'notes.noteable_id') ->where('transaction_journals.user_id', $this->user->id) ->where('text', 'LIKE', sprintf('%%%s%%', $value)) @@ -136,7 +136,7 @@ class JournalRepository implements JournalRepositoryInterface, UserGroupInterfac #[Override] public function getAllUncompletedJournals(): Collection { - return TransactionJournal::where('completed', false)->get(['transaction_journals.*']); + return TransactionJournal::query()->where('completed', false)->get(['transaction_journals.*']); } public function getDestinationAccount(TransactionJournal $journal): Account @@ -203,7 +203,7 @@ class JournalRepository implements JournalRepositoryInterface, UserGroupInterfac if ($cache->has()) { return new Carbon($cache->get()); } - $entry = TransactionJournalMeta::where('transaction_journal_id', $journalId)->where('name', $field)->first(); + $entry = TransactionJournalMeta::query()->where('transaction_journal_id', $journalId)->where('name', $field)->first(); if (null === $entry) { return null; } @@ -239,7 +239,7 @@ class JournalRepository implements JournalRepositoryInterface, UserGroupInterfac #[Override] public function markAsCompleted(Collection $set): void { - TransactionJournal::whereIn('id', $set->pluck('id')->toArray())->update(['completed' => true]); + TransactionJournal::query()->whereIn('id', $set->pluck('id')->toArray())->update(['completed' => true]); } public function reconcileById(int $journalId): void diff --git a/app/Repositories/LinkType/LinkTypeRepository.php b/app/Repositories/LinkType/LinkTypeRepository.php index 4ec09ae643..662fb9bb12 100644 --- a/app/Repositories/LinkType/LinkTypeRepository.php +++ b/app/Repositories/LinkType/LinkTypeRepository.php @@ -48,7 +48,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface, UserGroupInterf public function destroy(LinkType $linkType, ?LinkType $moveTo = null): bool { if ($moveTo instanceof LinkType) { - TransactionJournalLink::where('link_type_id', $linkType->id)->update(['link_type_id' => $moveTo->id]); + TransactionJournalLink::query()->where('link_type_id', $linkType->id)->update(['link_type_id' => $moveTo->id]); } $linkType->delete(); @@ -76,7 +76,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface, UserGroupInterf return null; } - return LinkType::where('name', $name)->first(); + return LinkType::query()->where('name', $name)->first(); } /** @@ -96,12 +96,12 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface, UserGroupInterf */ public function findSpecificLink(LinkType $linkType, TransactionJournal $inward, TransactionJournal $outward): ?TransactionJournalLink { - return TransactionJournalLink::where('link_type_id', $linkType->id)->where('source_id', $inward->id)->where('destination_id', $outward->id)->first(); + return TransactionJournalLink::query()->where('link_type_id', $linkType->id)->where('source_id', $inward->id)->where('destination_id', $outward->id)->first(); } public function get(): Collection { - return LinkType::orderBy('name', 'ASC')->get(); + return LinkType::query()->orderBy('name', 'ASC')->get(); } /** @@ -128,7 +128,7 @@ class LinkTypeRepository implements LinkTypeRepositoryInterface, UserGroupInterf */ public function getJournalLinks(?LinkType $linkType = null): Collection { - $query = TransactionJournalLink::with(['source', 'destination']) + $query = TransactionJournalLink::query()->with(['source', 'destination']) ->leftJoin('transaction_journals as source_journals', 'journal_links.source_id', '=', 'source_journals.id') ->leftJoin('transaction_journals as dest_journals', 'journal_links.destination_id', '=', 'dest_journals.id') ->where('source_journals.user_id', $this->user->id) diff --git a/app/Repositories/PeriodStatistic/PeriodStatisticRepository.php b/app/Repositories/PeriodStatistic/PeriodStatisticRepository.php index 2d9c0109a7..90bad72ede 100644 --- a/app/Repositories/PeriodStatistic/PeriodStatisticRepository.php +++ b/app/Repositories/PeriodStatistic/PeriodStatisticRepository.php @@ -125,7 +125,7 @@ class PeriodStatisticRepository implements PeriodStatisticRepositoryInterface, U return; } - $count = PeriodStatistic::where('primary_statable_type', $class) + $count = PeriodStatistic::query()->where('primary_statable_type', $class) ->whereIn('primary_statable_id', $objects->pluck('id')->toArray()) ->where(function (Builder $q) use ($dates): void { foreach ($dates as $date) { diff --git a/app/Repositories/PiggyBank/PiggyBankRepository.php b/app/Repositories/PiggyBank/PiggyBankRepository.php index 2514d06ca7..7246f8de51 100644 --- a/app/Repositories/PiggyBank/PiggyBankRepository.php +++ b/app/Repositories/PiggyBank/PiggyBankRepository.php @@ -372,7 +372,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface, UserGroupInte #[Override] public function purgeAll(): void { - PiggyBank::withTrashed() + PiggyBank::query()->withTrashed() ->whereNotNull('piggy_banks.deleted_at') ->leftJoin('account_piggy_bank', 'account_piggy_bank.piggy_bank_id', '=', 'piggy_banks.id') ->leftJoin('accounts', 'accounts.id', '=', 'account_piggy_bank.account_id') diff --git a/app/Repositories/Recurring/RecurringRepository.php b/app/Repositories/Recurring/RecurringRepository.php index c1e7af2cc8..69b264b76a 100644 --- a/app/Repositories/Recurring/RecurringRepository.php +++ b/app/Repositories/Recurring/RecurringRepository.php @@ -71,14 +71,14 @@ class RecurringRepository implements RecurringRepositoryInterface, UserGroupInte public function createdPreviously(Recurrence $recurrence, Carbon $date): bool { // if not, loop set and try to read the recurrence_date. If it matches start or end, return it as well. - $set = TransactionJournalMeta::where(static function (Builder $q1) use ($recurrence): void { + $set = TransactionJournalMeta::query()->where(static function (Builder $q1) use ($recurrence): void { $q1->where('name', 'recurrence_id'); $q1->where('data', json_encode((string) $recurrence->id)); })->get(['journal_meta.transaction_journal_id']); // there are X journals made for this recurrence. Any of them meant for today? foreach ($set as $journalMeta) { - $count = TransactionJournalMeta::where(static function (Builder $q2) use ($date): void { + $count = TransactionJournalMeta::query()->where(static function (Builder $q2) use ($date): void { $string = (string) $date; Log::debug(sprintf('Search for date: %s', json_encode($string))); $q2->where('name', 'recurrence_date'); @@ -131,7 +131,7 @@ class RecurringRepository implements RecurringRepositoryInterface, UserGroupInte public function getAll(): Collection { // grab ALL recurring transactions: - return Recurrence::with(['TransactionCurrency', 'TransactionType', 'RecurrenceRepetitions', 'RecurrenceTransactions']) + return Recurrence::query()->with(['TransactionCurrency', 'TransactionType', 'RecurrenceRepetitions', 'RecurrenceTransactions']) ->orderBy('active', 'DESC') ->orderBy('title', 'ASC') ->get() diff --git a/app/Repositories/TransactionGroup/TransactionGroupRepository.php b/app/Repositories/TransactionGroup/TransactionGroupRepository.php index 79ed510e17..35fab0e5ff 100644 --- a/app/Repositories/TransactionGroup/TransactionGroupRepository.php +++ b/app/Repositories/TransactionGroup/TransactionGroupRepository.php @@ -111,7 +111,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface, $repository = app(AttachmentRepositoryInterface::class); $repository->setUser($this->user); $journals = $group->transactionJournals->pluck('id')->toArray(); - $set = Attachment::whereIn('attachable_id', $journals) + $set = Attachment::query()->whereIn('attachable_id', $journals) ->where('attachable_type', TransactionJournal::class) ->where('uploaded', true) ->whereNull('deleted_at') @@ -163,7 +163,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface, { $return = []; $journals = $group->transactionJournals->pluck('id')->toArray(); - $set = TransactionJournalLink::where(static function (Builder $q) use ($journals): void { + $set = TransactionJournalLink::query()->where(static function (Builder $q) use ($journals): void { $q->whereIn('source_id', $journals); $q->orWhereIn('destination_id', $journals); })->with(['source', 'notes', 'destination', 'source.transactions'])->leftJoin('link_types', 'link_types.id', '=', 'journal_links.link_type_id')->get([ @@ -270,7 +270,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface, public function getNoteText(int $journalId): ?string { /** @var null|Note $note */ - $note = Note::where('noteable_id', $journalId)->where('noteable_type', TransactionJournal::class)->first(); + $note = Note::query()->where('noteable_id', $journalId)->where('noteable_type', TransactionJournal::class)->first(); return $note?->text; } @@ -285,7 +285,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface, $return = []; $journals = $group->transactionJournals->pluck('id')->toArray(); $currency = Amount::getPrimaryCurrencyByUserGroup($this->user->userGroup); - $data = PiggyBankEvent::whereIn('transaction_journal_id', $journals)->with('piggyBank', 'piggyBank.account')->get(['piggy_bank_events.*']); + $data = PiggyBankEvent::query()->whereIn('transaction_journal_id', $journals)->with('piggyBank', 'piggyBank.account')->get(['piggy_bank_events.*']); /** @var PiggyBankEvent $row */ foreach ($data as $row) { @@ -293,7 +293,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface, continue; } // get currency preference. - $currencyPreference = AccountMeta::where('account_id', $row->piggyBank->account_id)->where('name', 'currency_id')->first(); + $currencyPreference = AccountMeta::query()->where('account_id', $row->piggyBank->account_id)->where('name', 'currency_id')->first(); if (null !== $currencyPreference) { $currency = Amount::getTransactionCurrencyById((int) $currencyPreference->data); } diff --git a/app/Repositories/User/UserRepository.php b/app/Repositories/User/UserRepository.php index 8f37a55528..034dde02da 100644 --- a/app/Repositories/User/UserRepository.php +++ b/app/Repositories/User/UserRepository.php @@ -48,12 +48,12 @@ class UserRepository implements UserRepositoryInterface { public function all(): Collection { - return User::orderBy('id', 'DESC')->get(['users.*']); + return User::query()->orderBy('id', 'DESC')->get(['users.*']); } public function attachRole(User $user, string $role): bool { - $roleObject = Role::where('name', $role)->first(); + $roleObject = Role::query()->where('name', $role)->first(); if (null === $roleObject) { Log::error(sprintf('Could not find role "%s" in attachRole()', $role)); @@ -168,7 +168,7 @@ class UserRepository implements UserRepositoryInterface public function findByEmail(string $email): ?User { - return User::where('email', $email)->first(); + return User::query()->where('email', $email)->first(); } /** @@ -176,17 +176,17 @@ class UserRepository implements UserRepositoryInterface */ public function first(): ?User { - return User::orderBy('id', 'ASC')->first(); + return User::query()->orderBy('id', 'ASC')->first(); } public function getInvitedUsers(): Collection { - return InvitedUser::with('user')->get(); + return InvitedUser::query()->with('user')->get(); } public function getRole(string $role): ?Role { - return Role::where('name', $role)->first(); + return Role::query()->where('name', $role)->first(); } public function getRoleByUser(User $user): ?string @@ -237,7 +237,7 @@ class UserRepository implements UserRepositoryInterface 'bills' => $user->bills()->count(), 'categories' => $user->categories()->count(), 'budgets' => $user->budgets()->count(), - 'budgets_with_limits' => BudgetLimit::distinct() + 'budgets_with_limits' => BudgetLimit::query()->distinct() ->leftJoin('budgets', 'budgets.id', '=', 'budget_limits.budget_id') ->where('amount', '>', 0) ->whereNull('budgets.deleted_at') @@ -311,7 +311,7 @@ class UserRepository implements UserRepositoryInterface public function redeemCode(string $code): void { - $obj = InvitedUser::where('invite_code', $code)->where('redeemed', 0)->first(); + $obj = InvitedUser::query()->where('invite_code', $code)->where('redeemed', 0)->first(); if (null !== $obj) { $obj->redeemed = true; $obj->save(); @@ -412,7 +412,7 @@ class UserRepository implements UserRepositoryInterface public function validateInviteCode(string $code): bool { $now = today(config('app.timezone')); - $invitee = InvitedUser::where('invite_code', $code)->where('expires', '>', $now->format('Y-m-d H:i:s'))->where('redeemed', 0)->first(); + $invitee = InvitedUser::query()->where('invite_code', $code)->where('expires', '>', $now->format('Y-m-d H:i:s'))->where('redeemed', 0)->first(); return null !== $invitee; } diff --git a/app/Repositories/Webhook/WebhookRepository.php b/app/Repositories/Webhook/WebhookRepository.php index 356a1716f6..7ac0f0c4bd 100644 --- a/app/Repositories/Webhook/WebhookRepository.php +++ b/app/Repositories/Webhook/WebhookRepository.php @@ -121,7 +121,7 @@ class WebhookRepository implements WebhookRepositoryInterface, UserGroupInterfac foreach ($data['triggers'] as $trigger) { // get the relevant ID: - $object = WebhookTrigger::where('title', $trigger)->first(); + $object = WebhookTrigger::query()->where('title', $trigger)->first(); if (null === $object) { throw new FireflyException(sprintf('Could not find webhook trigger with title "%s".', $trigger)); } @@ -131,7 +131,7 @@ class WebhookRepository implements WebhookRepositoryInterface, UserGroupInterfac foreach ($data['responses'] as $response) { // get the relevant ID: - $object = WebhookResponse::where('title', $response)->first(); + $object = WebhookResponse::query()->where('title', $response)->first(); if (null === $object) { throw new FireflyException(sprintf('Could not find webhook response with title "%s".', $response)); } @@ -141,7 +141,7 @@ class WebhookRepository implements WebhookRepositoryInterface, UserGroupInterfac foreach ($data['deliveries'] as $delivery) { // get the relevant ID: - $object = WebhookDelivery::where('title', $delivery)->first(); + $object = WebhookDelivery::query()->where('title', $delivery)->first(); if (null === $object) { throw new FireflyException(sprintf('Could not find webhook delivery with title "%s".', $delivery)); } @@ -171,7 +171,7 @@ class WebhookRepository implements WebhookRepositoryInterface, UserGroupInterfac foreach ($data['triggers'] as $trigger) { // get the relevant ID: - $object = WebhookTrigger::where('title', $trigger)->first(); + $object = WebhookTrigger::query()->where('title', $trigger)->first(); if (null === $object) { throw new FireflyException(sprintf('Could not find webhook trigger with title "%s".', $trigger)); } @@ -181,7 +181,7 @@ class WebhookRepository implements WebhookRepositoryInterface, UserGroupInterfac foreach ($data['responses'] as $response) { // get the relevant ID: - $object = WebhookResponse::where('title', $response)->first(); + $object = WebhookResponse::query()->where('title', $response)->first(); if (null === $object) { throw new FireflyException(sprintf('Could not find webhook response with title "%s".', $response)); } @@ -191,7 +191,7 @@ class WebhookRepository implements WebhookRepositoryInterface, UserGroupInterfac foreach ($data['deliveries'] as $delivery) { // get the relevant ID: - $object = WebhookDelivery::where('title', $delivery)->first(); + $object = WebhookDelivery::query()->where('title', $delivery)->first(); if (null === $object) { throw new FireflyException(sprintf('Could not find webhook delivery with title "%s".', $delivery)); } diff --git a/app/Rules/BelongsUser.php b/app/Rules/BelongsUser.php index 16806cd0fe..7c3b9f549d 100644 --- a/app/Rules/BelongsUser.php +++ b/app/Rules/BelongsUser.php @@ -115,7 +115,7 @@ class BelongsUser implements ValidationRule // its ok to submit 0. other checks will fail. return true; } - $count = Account::where('id', '=', $value)->where('user_id', '=', auth()->user()->id)->count(); + $count = Account::query()->where('id', '=', $value)->where('user_id', '=', auth()->user()->id)->count(); return 1 === $count; } @@ -125,7 +125,7 @@ class BelongsUser implements ValidationRule if (0 === $value) { return true; } - $count = Bill::where('id', '=', $value)->where('user_id', '=', auth()->user()->id)->count(); + $count = Bill::query()->where('id', '=', $value)->where('user_id', '=', auth()->user()->id)->count(); return 1 === $count; } @@ -143,7 +143,7 @@ class BelongsUser implements ValidationRule if (0 === $value) { return true; } - $count = Budget::where('id', '=', $value)->where('user_id', '=', auth()->user()->id)->count(); + $count = Budget::query()->where('id', '=', $value)->where('user_id', '=', auth()->user()->id)->count(); return 1 === $count; } @@ -157,7 +157,7 @@ class BelongsUser implements ValidationRule private function validateCategoryId(int $value): bool { - $count = Category::where('id', '=', $value)->where('user_id', '=', auth()->user()->id)->count(); + $count = Category::query()->where('id', '=', $value)->where('user_id', '=', auth()->user()->id)->count(); return 1 === $count; } @@ -167,7 +167,7 @@ class BelongsUser implements ValidationRule if (0 === $value) { return true; } - $count = TransactionJournal::where('id', '=', $value)->where('user_id', '=', auth()->user()->id)->count(); + $count = TransactionJournal::query()->where('id', '=', $value)->where('user_id', '=', auth()->user()->id)->count(); return 1 === $count; } diff --git a/app/Rules/BelongsUserGroup.php b/app/Rules/BelongsUserGroup.php index 1dd3ae9315..adb2061e98 100644 --- a/app/Rules/BelongsUserGroup.php +++ b/app/Rules/BelongsUserGroup.php @@ -128,7 +128,7 @@ class BelongsUserGroup implements ValidationRule // it's ok to submit 0. other checks will fail. return true; } - $count = Account::where('id', '=', $value)->where('user_group_id', '=', $this->userGroup->id)->count(); + $count = Account::query()->where('id', '=', $value)->where('user_group_id', '=', $this->userGroup->id)->count(); return 1 === $count; } @@ -138,7 +138,7 @@ class BelongsUserGroup implements ValidationRule if (0 === $value) { return true; } - $count = Bill::where('id', '=', $value)->where('user_group_id', '=', $this->userGroup->id)->count(); + $count = Bill::query()->where('id', '=', $value)->where('user_group_id', '=', $this->userGroup->id)->count(); return 1 === $count; } @@ -156,7 +156,7 @@ class BelongsUserGroup implements ValidationRule if (0 === $value) { return true; } - $count = Budget::where('id', '=', $value)->where('user_group_id', '=', $this->userGroup->id)->count(); + $count = Budget::query()->where('id', '=', $value)->where('user_group_id', '=', $this->userGroup->id)->count(); return 1 === $count; } @@ -170,7 +170,7 @@ class BelongsUserGroup implements ValidationRule private function validateCategoryId(int $value): bool { - $count = Category::where('id', '=', $value)->where('user_group_id', '=', $this->userGroup->id)->count(); + $count = Category::query()->where('id', '=', $value)->where('user_group_id', '=', $this->userGroup->id)->count(); return 1 === $count; } @@ -180,7 +180,7 @@ class BelongsUserGroup implements ValidationRule if (0 === $value) { return true; } - $count = TransactionJournal::where('id', '=', $value)->where('user_group_id', '=', $this->userGroup->id)->count(); + $count = TransactionJournal::query()->where('id', '=', $value)->where('user_group_id', '=', $this->userGroup->id)->count(); return 1 === $count; } diff --git a/app/Rules/IsAssetAccountId.php b/app/Rules/IsAssetAccountId.php index eadc485442..87cbb0e846 100644 --- a/app/Rules/IsAssetAccountId.php +++ b/app/Rules/IsAssetAccountId.php @@ -41,7 +41,7 @@ class IsAssetAccountId implements ValidationRule $accountId = (int) $value; /** @var null|Account $account */ - $account = Account::with('accountType')->find($accountId); + $account = Account::query()->with('accountType')->find($accountId); if (null === $account) { $fail('validation.no_asset_account')->translate(); diff --git a/app/Rules/ValidJournals.php b/app/Rules/ValidJournals.php index f7f462360b..30a298d024 100644 --- a/app/Rules/ValidJournals.php +++ b/app/Rules/ValidJournals.php @@ -45,7 +45,7 @@ class ValidJournals implements ValidationRule } $userId = auth()->user()->id; foreach ($value as $journalId) { - $count = TransactionJournal::where('id', $journalId)->where('user_id', $userId)->count(); + $count = TransactionJournal::query()->where('id', $journalId)->where('user_id', $userId)->count(); if (0 === $count) { Log::debug(sprintf('Count for transaction #%d and user #%d is zero! Return FALSE', $journalId, $userId)); diff --git a/app/Services/Internal/Destroy/AccountDestroyService.php b/app/Services/Internal/Destroy/AccountDestroyService.php index cc23533d12..74b8779aa7 100644 --- a/app/Services/Internal/Destroy/AccountDestroyService.php +++ b/app/Services/Internal/Destroy/AccountDestroyService.php @@ -55,7 +55,7 @@ class AccountDestroyService } // delete piggy banks: - PiggyBank::where('account_id', $account->id)->delete(); + PiggyBank::query()->where('account_id', $account->id)->delete(); // delete account meta: $account->accountMeta()->delete(); @@ -69,7 +69,7 @@ class AccountDestroyService Log::debug(sprintf('Move from account #%d to #%d', $account->id, $moveTo->id)); DB::table('transactions')->where('account_id', $account->id)->update(['account_id' => $moveTo->id]); - $collection = Transaction::groupBy('transaction_journal_id', 'account_id')->where('account_id', $moveTo->id)->get([ + $collection = Transaction::query()->groupBy('transaction_journal_id', 'account_id')->where('account_id', $moveTo->id)->get([ 'transaction_journal_id', 'account_id', DB::raw('count(*) as the_count'), @@ -112,7 +112,7 @@ class AccountDestroyService Log::debug(sprintf('Found opening balance journal with ID #%d', $journalId)); // get transactions with this journal (should be just one): - $transactions = Transaction::where('transaction_journal_id', $journalId)->where('account_id', '!=', $account->id)->get(); + $transactions = Transaction::query()->where('transaction_journal_id', $journalId)->where('account_id', '!=', $account->id)->get(); /** @var Transaction $transaction */ foreach ($transactions as $transaction) { @@ -137,7 +137,7 @@ class AccountDestroyService private function destroyRecurrences(Account $account): void { - $recurrences = RecurrenceTransaction::where(static function (Builder $q) use ($account): void { + $recurrences = RecurrenceTransaction::query()->where(static function (Builder $q) use ($account): void { $q->where('source_id', $account->id); $q->orWhere('destination_id', $account->id); })->get(['recurrence_id'])->pluck('recurrence_id')->toArray(); diff --git a/app/Services/Internal/Support/BillServiceTrait.php b/app/Services/Internal/Support/BillServiceTrait.php index c2c2506b44..9816d4f059 100644 --- a/app/Services/Internal/Support/BillServiceTrait.php +++ b/app/Services/Internal/Support/BillServiceTrait.php @@ -40,7 +40,7 @@ trait BillServiceTrait return; } $ruleIds = $bill->user->rules()->get(['id'])->pluck('id')->toArray(); - $set = RuleAction::whereIn('rule_id', $ruleIds)->where('action_type', 'link_to_bill')->where('action_value', $oldName)->get(); + $set = RuleAction::query()->whereIn('rule_id', $ruleIds)->where('action_type', 'link_to_bill')->where('action_value', $oldName)->get(); /** @var RuleAction $ruleAction */ foreach ($set as $ruleAction) { diff --git a/app/Support/Amount.php b/app/Support/Amount.php index f1b732d852..e9127b913b 100644 --- a/app/Support/Amount.php +++ b/app/Support/Amount.php @@ -195,7 +195,7 @@ class Amount public function getAllCurrencies(): Collection { - return TransactionCurrency::orderBy('code', 'ASC')->get(); + return TransactionCurrency::query()->orderBy('code', 'ASC')->get(); } /** @@ -314,7 +314,7 @@ class Amount public function getSystemCurrency(): TransactionCurrency { - return TransactionCurrency::whereNull('deleted_at')->where('code', 'EUR')->first(); + return TransactionCurrency::query()->whereNull('deleted_at')->where('code', 'EUR')->first(); } public function getTransactionCurrencyByCode(string $code): TransactionCurrency diff --git a/app/Support/Authentication/RemoteUserProvider.php b/app/Support/Authentication/RemoteUserProvider.php index 06785b6d94..8f48453e21 100644 --- a/app/Support/Authentication/RemoteUserProvider.php +++ b/app/Support/Authentication/RemoteUserProvider.php @@ -68,13 +68,13 @@ class RemoteUserProvider implements UserProvider public function retrieveById($identifier): User { Log::debug(sprintf('Now at %s(%s)', __METHOD__, $identifier)); - $user = User::where('email', $identifier)->first(); + $user = User::query()->where('email', $identifier)->first(); if (null === $user) { Log::debug(sprintf('User with email "%s" not found. Will be created.', $identifier)); $user = User::create(['blocked' => false, 'blocked_code' => null, 'email' => $identifier, 'password' => bcrypt(Str::random(64))]); // if this is the first user, give them admin as well. if (1 === User::count()) { - $roleObject = Role::where('name', 'owner')->first(); + $roleObject = Role::query()->where('name', 'owner')->first(); $user->roles()->attach($roleObject); } } diff --git a/app/Support/Balance.php b/app/Support/Balance.php index 9d15f5ff8e..9ae518e6a5 100644 --- a/app/Support/Balance.php +++ b/app/Support/Balance.php @@ -50,7 +50,7 @@ class Balance return $cache->get(); } - $query = Transaction::whereIn('transactions.account_id', $accounts->pluck('id')->toArray()) + $query = Transaction::query()->whereIn('transactions.account_id', $accounts->pluck('id')->toArray()) ->leftJoin('transaction_journals', 'transactions.transaction_journal_id', '=', 'transaction_journals.id') ->orderBy('transaction_journals.date', 'desc') ->orderBy('transaction_journals.order', 'asc') diff --git a/app/Support/Binder/UserGroupAccount.php b/app/Support/Binder/UserGroupAccount.php index 12d7eff4a2..f649a9eeb5 100644 --- a/app/Support/Binder/UserGroupAccount.php +++ b/app/Support/Binder/UserGroupAccount.php @@ -41,7 +41,7 @@ class UserGroupAccount implements BinderInterface if (auth()->check()) { /** @var User $user */ $user = auth()->user(); - $account = Account::where('id', (int) $value) + $account = Account::query()->where('id', (int) $value) ->where('user_group_id', $user->user_group_id) ->first() ; diff --git a/app/Support/Binder/UserGroupBill.php b/app/Support/Binder/UserGroupBill.php index 551846d693..e9bbcb26fa 100644 --- a/app/Support/Binder/UserGroupBill.php +++ b/app/Support/Binder/UserGroupBill.php @@ -41,7 +41,7 @@ class UserGroupBill implements BinderInterface if (auth()->check()) { /** @var User $user */ $user = auth()->user(); - $currency = Bill::where('id', (int) $value) + $currency = Bill::query()->where('id', (int) $value) ->where('user_group_id', $user->user_group_id) ->first() ; diff --git a/app/Support/Binder/UserGroupExchangeRate.php b/app/Support/Binder/UserGroupExchangeRate.php index 74a65c9348..0b2eee832d 100644 --- a/app/Support/Binder/UserGroupExchangeRate.php +++ b/app/Support/Binder/UserGroupExchangeRate.php @@ -38,7 +38,7 @@ class UserGroupExchangeRate implements BinderInterface if (auth()->check()) { /** @var User $user */ $user = auth()->user(); - $rate = CurrencyExchangeRate::where('id', (int) $value) + $rate = CurrencyExchangeRate::query()->where('id', (int) $value) ->where('user_group_id', $user->user_group_id) ->first() ; diff --git a/app/Support/Binder/UserGroupTransaction.php b/app/Support/Binder/UserGroupTransaction.php index d9131400f3..1a7a1c199f 100644 --- a/app/Support/Binder/UserGroupTransaction.php +++ b/app/Support/Binder/UserGroupTransaction.php @@ -38,7 +38,7 @@ class UserGroupTransaction implements BinderInterface if (auth()->check()) { /** @var User $user */ $user = auth()->user(); - $group = TransactionGroup::where('id', (int) $value) + $group = TransactionGroup::query()->where('id', (int) $value) ->where('user_group_id', $user->user_group_id) ->first() ; diff --git a/app/Support/FireflyConfig.php b/app/Support/FireflyConfig.php index 94f004ab5c..bb88c7e468 100644 --- a/app/Support/FireflyConfig.php +++ b/app/Support/FireflyConfig.php @@ -43,7 +43,7 @@ class FireflyConfig if (Cache::has($fullName)) { Cache::forget($fullName); } - Configuration::where('name', $name)->forceDelete(); + Configuration::query()->where('name', $name)->forceDelete(); } /** @@ -60,7 +60,7 @@ class FireflyConfig try { /** @var null|Configuration $config */ - $config = Configuration::where('name', $name)->first(['id', 'name', 'data']); + $config = Configuration::query()->where('name', $name)->first(['id', 'name', 'data']); } catch (Exception|QueryException $e) { throw new FireflyException(sprintf('Could not poll the database: %s', $e->getMessage()), 0, $e); } @@ -103,7 +103,7 @@ class FireflyConfig public function getFresh(string $name, mixed $default = null): ?Configuration { - $config = Configuration::where('name', $name)->first(['id', 'name', 'data']); + $config = Configuration::query()->where('name', $name)->first(['id', 'name', 'data']); if (null !== $config) { return $config; } @@ -117,7 +117,7 @@ class FireflyConfig public function has(string $name): bool { - return 1 === Configuration::where('name', $name)->count(); + return 1 === Configuration::query()->where('name', $name)->count(); } /** diff --git a/app/Support/JsonApi/Enrichments/AccountEnrichment.php b/app/Support/JsonApi/Enrichments/AccountEnrichment.php index 48c65a52c3..d2cf445ef6 100644 --- a/app/Support/JsonApi/Enrichments/AccountEnrichment.php +++ b/app/Support/JsonApi/Enrichments/AccountEnrichment.php @@ -332,7 +332,7 @@ class AccountEnrichment implements EnrichmentInterface private function collectMetaData(): void { - $set = AccountMeta::whereIn('name', [ + $set = AccountMeta::query()->whereIn('name', [ 'is_multi_currency', 'include_net_worth', 'currency_id', @@ -357,7 +357,7 @@ class AccountEnrichment implements EnrichmentInterface } } if (count($this->currencies) > 0) { - $currencies = TransactionCurrency::whereIn('id', array_keys($this->currencies))->get(); + $currencies = TransactionCurrency::query()->whereIn('id', array_keys($this->currencies))->get(); foreach ($currencies as $currency) { $this->currencies[(int) $currency->id] = $currency; } @@ -401,7 +401,7 @@ class AccountEnrichment implements EnrichmentInterface $this->mappedObjects[(int) $entry->object_groupable_id] = (int) $entry->object_group_id; } - $groups = ObjectGroup::whereIn('id', $ids)->get(['id', 'title', 'order'])->toArray(); + $groups = ObjectGroup::query()->whereIn('id', $ids)->get(['id', 'title', 'order'])->toArray(); foreach ($groups as $group) { $group['id'] = (int) $group['id']; $group['order'] = (int) $group['order']; @@ -430,7 +430,7 @@ class AccountEnrichment implements EnrichmentInterface private function getAccountTypes(): void { - $types = AccountType::whereIn('id', $this->accountTypeIds)->get(); + $types = AccountType::query()->whereIn('id', $this->accountTypeIds)->get(); /** @var AccountType $type */ foreach ($types as $type) { diff --git a/app/Support/JsonApi/Enrichments/AvailableBudgetEnrichment.php b/app/Support/JsonApi/Enrichments/AvailableBudgetEnrichment.php index 3975c080fd..c80731db13 100644 --- a/app/Support/JsonApi/Enrichments/AvailableBudgetEnrichment.php +++ b/app/Support/JsonApi/Enrichments/AvailableBudgetEnrichment.php @@ -122,7 +122,7 @@ class AvailableBudgetEnrichment implements EnrichmentInterface private function collectCurrencies(): void { $ids = array_unique(array_values($this->currencyIds)); - $set = TransactionCurrency::whereIn('id', $ids)->get(); + $set = TransactionCurrency::query()->whereIn('id', $ids)->get(); foreach ($set as $currency) { $this->currencies[(int) $currency->id] = $currency; } diff --git a/app/Support/JsonApi/Enrichments/BudgetEnrichment.php b/app/Support/JsonApi/Enrichments/BudgetEnrichment.php index f32f10d1e2..d07e76a509 100644 --- a/app/Support/JsonApi/Enrichments/BudgetEnrichment.php +++ b/app/Support/JsonApi/Enrichments/BudgetEnrichment.php @@ -128,7 +128,7 @@ class BudgetEnrichment implements EnrichmentInterface private function collectAutoBudgets(): void { - $set = AutoBudget::whereIn('budget_id', $this->ids)->with(['transactionCurrency'])->get(); + $set = AutoBudget::query()->whereIn('budget_id', $this->ids)->with(['transactionCurrency'])->get(); /** @var AutoBudget $autoBudget */ foreach ($set as $autoBudget) { @@ -201,7 +201,7 @@ class BudgetEnrichment implements EnrichmentInterface $this->mappedObjects[(int) $entry->object_groupable_id] = (int) $entry->object_group_id; } - $groups = ObjectGroup::whereIn('id', $ids)->get(['id', 'title', 'order'])->toArray(); + $groups = ObjectGroup::query()->whereIn('id', $ids)->get(['id', 'title', 'order'])->toArray(); foreach ($groups as $group) { $group['id'] = (int) $group['id']; $group['order'] = (int) $group['order']; diff --git a/app/Support/JsonApi/Enrichments/BudgetLimitEnrichment.php b/app/Support/JsonApi/Enrichments/BudgetLimitEnrichment.php index 644063ff8a..77efb09286 100644 --- a/app/Support/JsonApi/Enrichments/BudgetLimitEnrichment.php +++ b/app/Support/JsonApi/Enrichments/BudgetLimitEnrichment.php @@ -110,7 +110,7 @@ class BudgetLimitEnrichment implements EnrichmentInterface private function collectBudgets(): void { $budgetIds = $this->collection->pluck('budget_id')->unique()->toArray(); - $budgets = Budget::whereIn('id', $budgetIds)->get(); + $budgets = Budget::query()->whereIn('id', $budgetIds)->get(); $repository = app(OperationsRepository::class); $repository->setUser($this->user); @@ -148,7 +148,7 @@ class BudgetLimitEnrichment implements EnrichmentInterface private function collectCurrencies(): void { $this->currencies[$this->primaryCurrency->id] = $this->primaryCurrency; - $currencies = TransactionCurrency::whereIn('id', $this->currencyIds)->whereNot( + $currencies = TransactionCurrency::query()->whereIn('id', $this->currencyIds)->whereNot( 'id', $this->primaryCurrency->id )->get(); diff --git a/app/Support/JsonApi/Enrichments/PiggyBankEnrichment.php b/app/Support/JsonApi/Enrichments/PiggyBankEnrichment.php index e1bbd05ad1..4f92978199 100644 --- a/app/Support/JsonApi/Enrichments/PiggyBankEnrichment.php +++ b/app/Support/JsonApi/Enrichments/PiggyBankEnrichment.php @@ -192,7 +192,7 @@ class PiggyBankEnrichment implements EnrichmentInterface $this->ids = array_unique($this->ids); // collect currencies. - $currencies = TransactionCurrency::whereIn('id', $this->currencyIds)->get(); + $currencies = TransactionCurrency::query()->whereIn('id', $this->currencyIds)->get(); foreach ($currencies as $currency) { $this->currencies[(int) $currency->id] = $currency; } @@ -233,7 +233,7 @@ class PiggyBankEnrichment implements EnrichmentInterface } // get account currency preference for ALL. - $set = AccountMeta::whereIn('account_id', $allAccountIds)->where('name', 'currency_id')->get(); + $set = AccountMeta::query()->whereIn('account_id', $allAccountIds)->where('name', 'currency_id')->get(); /** @var AccountMeta $item */ foreach ($set as $item) { @@ -246,7 +246,7 @@ class PiggyBankEnrichment implements EnrichmentInterface // $this->accountCurrencies[$accountId] = $this->currencies[$currencyId]; } - $set = Account::whereIn('id', $allAccountIds)->get(); + $set = Account::query()->whereIn('id', $allAccountIds)->get(); /** @var Account $item */ foreach ($set as $item) { @@ -286,7 +286,7 @@ class PiggyBankEnrichment implements EnrichmentInterface $this->mappedObjects[(int) $entry->object_groupable_id] = (int) $entry->object_group_id; } - $groups = ObjectGroup::whereIn('id', $ids)->get(['id', 'title', 'order'])->toArray(); + $groups = ObjectGroup::query()->whereIn('id', $ids)->get(['id', 'title', 'order'])->toArray(); foreach ($groups as $group) { $group['id'] = (int) $group['id']; $group['order'] = (int) $group['order']; diff --git a/app/Support/JsonApi/Enrichments/PiggyBankEventEnrichment.php b/app/Support/JsonApi/Enrichments/PiggyBankEventEnrichment.php index 62d3c7fe67..c4ee4439ec 100644 --- a/app/Support/JsonApi/Enrichments/PiggyBankEventEnrichment.php +++ b/app/Support/JsonApi/Enrichments/PiggyBankEventEnrichment.php @@ -113,7 +113,7 @@ class PiggyBankEventEnrichment implements EnrichmentInterface } $this->ids = array_unique($this->ids); // collect groups with journal info. - $set = TransactionJournal::whereIn('id', $this->journalIds)->get(['id', 'transaction_group_id']); + $set = TransactionJournal::query()->whereIn('id', $this->journalIds)->get(['id', 'transaction_group_id']); /** @var TransactionJournal $item */ foreach ($set as $item) { @@ -130,7 +130,7 @@ class PiggyBankEventEnrichment implements EnrichmentInterface } // get account currency preference for ALL. - $set = AccountMeta::whereIn('account_id', array_values($this->accountIds))->where('name', 'currency_id')->get(); + $set = AccountMeta::query()->whereIn('account_id', array_values($this->accountIds))->where('name', 'currency_id')->get(); /** @var AccountMeta $item */ foreach ($set as $item) { diff --git a/app/Support/JsonApi/Enrichments/RecurringEnrichment.php b/app/Support/JsonApi/Enrichments/RecurringEnrichment.php index 8d7c840315..672bdb2f90 100644 --- a/app/Support/JsonApi/Enrichments/RecurringEnrichment.php +++ b/app/Support/JsonApi/Enrichments/RecurringEnrichment.php @@ -200,7 +200,7 @@ class RecurringEnrichment implements EnrichmentInterface private function collectAccounts(): void { $all = array_merge(array_unique($this->sourceAccountIds), array_unique($this->destinationAccountIds)); - $accounts = Account::with(['accountType'])->whereIn('id', array_unique($all))->get(); + $accounts = Account::query()->with(['accountType'])->whereIn('id', array_unique($all))->get(); /** @var Account $account */ foreach ($accounts as $account) { @@ -216,7 +216,7 @@ class RecurringEnrichment implements EnrichmentInterface return; } $ids = Arr::pluck($billIds, 'bill_id'); - $bills = Bill::whereIn('id', $ids)->get(); + $bills = Bill::query()->whereIn('id', $ids)->get(); $mapped = []; foreach ($bills as $bill) { $mapped[(int) $bill->id] = $bill; @@ -234,7 +234,7 @@ class RecurringEnrichment implements EnrichmentInterface return; } $ids = Arr::pluck($budgetIds, 'budget_id'); - $categories = Budget::whereIn('id', $ids)->get(); + $categories = Budget::query()->whereIn('id', $ids)->get(); $mapped = []; foreach ($categories as $category) { $mapped[(int) $category->id] = $category; @@ -252,7 +252,7 @@ class RecurringEnrichment implements EnrichmentInterface return; } $ids = Arr::pluck($categoryIds, 'category_id'); - $categories = Category::whereIn('id', $ids)->get(); + $categories = Category::query()->whereIn('id', $ids)->get(); $mapped = []; foreach ($categories as $category) { $mapped[(int) $category->id] = $category; @@ -288,7 +288,7 @@ class RecurringEnrichment implements EnrichmentInterface private function collectCurrencies(): void { $all = array_merge(array_unique($this->currencyIds), array_unique($this->foreignCurrencyIds)); - $currencies = TransactionCurrency::whereIn('id', array_unique($all))->get(); + $currencies = TransactionCurrency::query()->whereIn('id', array_unique($all))->get(); foreach ($currencies as $currency) { $id = (int) $currency->id; $this->currencies[$id] = $currency; @@ -333,7 +333,7 @@ class RecurringEnrichment implements EnrichmentInterface return; } $ids = Arr::pluck($piggyBankIds, 'piggy_bank_id'); - $piggyBanks = PiggyBank::whereIn('id', $ids)->get(); + $piggyBanks = PiggyBank::query()->whereIn('id', $ids)->get(); $mapped = []; foreach ($piggyBanks as $piggyBank) { $mapped[(int) $piggyBank->id] = $piggyBank; @@ -350,7 +350,7 @@ class RecurringEnrichment implements EnrichmentInterface Log::debug('Start of enrichment: collectRepetitions()'); $repository = app(RecurringRepositoryInterface::class); $repository->setUserGroup($this->userGroup); - $set = RecurrenceRepetition::whereIn('recurrence_id', $this->ids)->get(); + $set = RecurrenceRepetition::query()->whereIn('recurrence_id', $this->ids)->get(); /** @var RecurrenceRepetition $repetition */ foreach ($set as $repetition) { @@ -394,7 +394,7 @@ class RecurringEnrichment implements EnrichmentInterface foreach ($this->ids as $recurrenceId) { $rtIds = array_merge($rtIds, array_keys($this->transactions[$recurrenceId])); } - $meta = RecurrenceTransactionMeta::whereNull('deleted_at')->whereIn('rt_id', $rtIds)->get(); + $meta = RecurrenceTransactionMeta::query()->whereNull('deleted_at')->whereIn('rt_id', $rtIds)->get(); // other meta-data to be collected: $billIds = []; $piggyBankIds = []; @@ -492,7 +492,7 @@ class RecurringEnrichment implements EnrichmentInterface private function collectTransactions(): void { - $set = RecurrenceTransaction::whereIn('recurrence_id', $this->ids)->get(); + $set = RecurrenceTransaction::query()->whereIn('recurrence_id', $this->ids)->get(); /** @var RecurrenceTransaction $transaction */ foreach ($set as $transaction) { diff --git a/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php b/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php index 27adf3cad4..c6673f71e3 100644 --- a/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php +++ b/app/Support/JsonApi/Enrichments/SubscriptionEnrichment.php @@ -223,7 +223,7 @@ class SubscriptionEnrichment implements EnrichmentInterface $this->mappedObjects[(int) $entry->object_groupable_id] = (int) $entry->object_group_id; } - $groups = ObjectGroup::whereIn('id', $ids)->get(['id', 'title', 'order'])->toArray(); + $groups = ObjectGroup::query()->whereIn('id', $ids)->get(['id', 'title', 'order'])->toArray(); foreach ($groups as $group) { $group['id'] = (int) $group['id']; $group['order'] = (int) $group['order']; diff --git a/app/Support/JsonApi/Enrichments/TransactionGroupEnrichment.php b/app/Support/JsonApi/Enrichments/TransactionGroupEnrichment.php index 7679f8be42..9b9c1aa106 100644 --- a/app/Support/JsonApi/Enrichments/TransactionGroupEnrichment.php +++ b/app/Support/JsonApi/Enrichments/TransactionGroupEnrichment.php @@ -212,7 +212,7 @@ class TransactionGroupEnrichment implements EnrichmentInterface private function collectMetaData(): void { - $set = TransactionJournalMeta::whereIn('transaction_journal_id', $this->journalIds)->get(['transaction_journal_id', 'name', 'data'])->toArray(); + $set = TransactionJournalMeta::query()->whereIn('transaction_journal_id', $this->journalIds)->get(['transaction_journal_id', 'name', 'data'])->toArray(); foreach ($set as $entry) { $name = $entry['name']; $data = (string) $entry['data']; diff --git a/app/Support/Models/AccountBalanceCalculator.php b/app/Support/Models/AccountBalanceCalculator.php index 54c8590171..6b5a2c1606 100644 --- a/app/Support/Models/AccountBalanceCalculator.php +++ b/app/Support/Models/AccountBalanceCalculator.php @@ -181,7 +181,7 @@ class AccountBalanceCalculator public static function recalculateAll(bool $forced): void { if ($forced) { - Transaction::whereNull('deleted_at')->update(['balance_dirty' => true]); + Transaction::query()->whereNull('deleted_at')->update(['balance_dirty' => true]); // also delete account balances. // AccountBalance::whereNotNull('created_at')->delete(); diff --git a/app/Support/Preferences.php b/app/Support/Preferences.php index 062b15f490..2819fc5255 100644 --- a/app/Support/Preferences.php +++ b/app/Support/Preferences.php @@ -47,7 +47,7 @@ class Preferences return new Collection(); } - return Preference::where('user_id', $user->id) + return Preference::query()->where('user_id', $user->id) ->where('name', '!=', 'currencyPreference') ->where(static function (Builder $q) use ($user): void { $q->whereNull('user_group_id'); @@ -61,7 +61,7 @@ class Preferences { $value = sprintf('%s%%', $search); - return Preference::where('user_id', $user->id)->whereLike('name', $value)->get(); + return Preference::query()->where('user_id', $user->id)->whereLike('name', $value)->get(); } public function delete(string $name): bool @@ -70,7 +70,7 @@ class Preferences if (Cache::has($fullName)) { Cache::forget($fullName); } - Preference::where('user_id', auth()->user()->id)->where('name', $name)->delete(); + Preference::query()->where('user_id', auth()->user()->id)->where('name', $name)->delete(); return true; } @@ -81,7 +81,7 @@ class Preferences if (Cache::has($fullName)) { Cache::forget($fullName); } - Preference::where('user_id', $user->id)->where('name', $name)->delete(); + Preference::query()->where('user_id', $user->id)->where('name', $name)->delete(); return true; } @@ -91,7 +91,7 @@ class Preferences */ public function findByName(string $name): Collection { - return Preference::where('name', $name)->get(); + return Preference::query()->where('name', $name)->get(); } public function forget(User $user, string $name): void @@ -118,7 +118,7 @@ class Preferences public function getArrayForUser(User $user, array $list): array { $result = []; - $preferences = Preference::where('user_id', $user->id) + $preferences = Preference::query()->where('user_id', $user->id) ->where(static function (Builder $q) use ($user): void { $q->whereNull('user_group_id'); $q->orWhere('user_group_id', $user->user_group_id); @@ -196,7 +196,7 @@ class Preferences // Log::debug(sprintf('getForUser(#%d, "%s")', $user->id, $name)); // don't care about user group ID, except for some specific preferences. $userGroupId = $this->getUserGroupId($user, $name); - $query = Preference::where('user_id', $user->id)->where('name', $name); + $query = Preference::query()->where('user_id', $user->id)->where('name', $name); if (null !== $userGroupId) { Log::debug('Include user group ID in query'); $query->where('user_group_id', $userGroupId); @@ -308,7 +308,7 @@ class Preferences Cache::forget($fullName); - $query = Preference::where('user_id', $user->id)->where('name', $name); + $query = Preference::query()->where('user_id', $user->id)->where('name', $name); if (null !== $userGroupId) { Log::debug('Include user group ID in query'); $query->where('user_group_id', $userGroupId); diff --git a/app/Support/Repositories/UserGroup/UserGroupTrait.php b/app/Support/Repositories/UserGroup/UserGroupTrait.php index dcc2dcbd8a..33fa7e2294 100644 --- a/app/Support/Repositories/UserGroup/UserGroupTrait.php +++ b/app/Support/Repositories/UserGroup/UserGroupTrait.php @@ -98,7 +98,7 @@ trait UserGroupTrait */ public function setUserGroupById(int $userGroupId): void { - $memberships = GroupMembership::where('user_id', $this->user->id)->where('user_group_id', $userGroupId)->count(); + $memberships = GroupMembership::query()->where('user_id', $this->user->id)->where('user_group_id', $userGroupId)->count(); if (0 === $memberships) { throw new FireflyException(sprintf('User #%d has no access to administration #%d', $this->user->id, $userGroupId)); } diff --git a/app/Support/Steam.php b/app/Support/Steam.php index f36957abd0..97c55dd3f8 100644 --- a/app/Support/Steam.php +++ b/app/Support/Steam.php @@ -83,7 +83,7 @@ class Steam $currencies = $this->getCurrencies($accounts); // balance(s) in all currencies for ALL accounts. - $arrayOfSums = Transaction::whereIn('account_id', $accounts->pluck('id')->toArray()) + $arrayOfSums = Transaction::query()->whereIn('account_id', $accounts->pluck('id')->toArray()) ->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id') ->leftJoin('transaction_currencies', 'transaction_currencies.id', '=', 'transactions.transaction_currency_id') ->where('transaction_journals.date', $inclusive ? '<=' : '<', $date->format('Y-m-d H:i:s')) @@ -828,7 +828,7 @@ class Steam $currencies[$primary->id] = $primary; $ids = $accounts->pluck('id')->toArray(); - $result = AccountMeta::whereIn('account_id', $ids)->where('name', 'currency_id')->get(); + $result = AccountMeta::query()->whereIn('account_id', $ids)->where('name', 'currency_id')->get(); /** @var AccountMeta $item */ foreach ($result as $item) { @@ -838,7 +838,7 @@ class Steam } } // collect those currencies, skip primary because we already have it. - $set = TransactionCurrency::whereIn('id', $accountPreferences)->where('id', '!=', $primary->id)->get(); + $set = TransactionCurrency::query()->whereIn('id', $accountPreferences)->where('id', '!=', $primary->id)->get(); foreach ($set as $item) { $currencies[$item->id] = $item; } diff --git a/app/Support/System/OAuthKeys.php b/app/Support/System/OAuthKeys.php index 22ca659ec8..764e04c32c 100644 --- a/app/Support/System/OAuthKeys.php +++ b/app/Support/System/OAuthKeys.php @@ -78,8 +78,8 @@ class OAuthKeys $privateKey = ''; $publicKey = ''; // better check if keys are in the database: - $hasPrivate = FireflyConfig::has(self::PRIVATE_KEY); - $hasPublic = FireflyConfig::has(self::PUBLIC_KEY); + $hasPrivate = FireflyConfig::query()->has(self::PRIVATE_KEY); + $hasPublic = FireflyConfig::query()->has(self::PUBLIC_KEY); Log::debug(sprintf('keysInDatabase: hasPrivate:%s, hasPublic:%s', var_export($hasPrivate, true), var_export($hasPublic, true))); diff --git a/app/TransactionRules/Actions/AppendDescription.php b/app/TransactionRules/Actions/AppendDescription.php index 8b4ebfbf9b..07774a7410 100644 --- a/app/TransactionRules/Actions/AppendDescription.php +++ b/app/TransactionRules/Actions/AppendDescription.php @@ -53,7 +53,7 @@ class AppendDescription implements ActionInterface // event for audit log entry /** @var TransactionJournal $object */ - $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); + $object = TransactionJournal::query()->where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); event(new TransactionGroupRequestsAuditLogEntry($this->action->rule, $object, 'update_description', $journal['description'], $description)); return true; diff --git a/app/TransactionRules/Actions/AppendDescriptionToNotes.php b/app/TransactionRules/Actions/AppendDescriptionToNotes.php index 58e164a199..323e68bedf 100644 --- a/app/TransactionRules/Actions/AppendDescriptionToNotes.php +++ b/app/TransactionRules/Actions/AppendDescriptionToNotes.php @@ -52,7 +52,7 @@ class AppendDescriptionToNotes implements ActionInterface $this->refreshNotes($journal); /** @var null|TransactionJournal $object */ - $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); + $object = TransactionJournal::query()->where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); if (null === $object) { Log::error(sprintf('No journal #%d belongs to user #%d.', $journal['transaction_journal_id'], $journal['user_id'])); event(new RuleActionFailedOnArray($this->action, $journal, (string) trans('rules.journal_other_user'))); diff --git a/app/TransactionRules/Actions/AppendNotes.php b/app/TransactionRules/Actions/AppendNotes.php index 99c2405289..cd4373dec4 100644 --- a/app/TransactionRules/Actions/AppendNotes.php +++ b/app/TransactionRules/Actions/AppendNotes.php @@ -48,7 +48,7 @@ class AppendNotes implements ActionInterface public function actOnArray(array $journal): bool { $this->refreshNotes($journal); - $dbNote = Note::where('noteable_id', (int) $journal['transaction_journal_id']) + $dbNote = Note::query()->where('noteable_id', (int) $journal['transaction_journal_id']) ->where('noteable_type', TransactionJournal::class) ->first(['notes.*']) ; @@ -65,7 +65,7 @@ class AppendNotes implements ActionInterface $dbNote->save(); /** @var TransactionJournal $object */ - $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); + $object = TransactionJournal::query()->where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); Log::debug(sprintf('RuleAction AppendNotes appended "%s" to "%s".', $append, $before)); event(new TransactionGroupRequestsAuditLogEntry($this->action->rule, $object, 'update_notes', $before, $text)); diff --git a/app/TransactionRules/Actions/AppendNotesToDescription.php b/app/TransactionRules/Actions/AppendNotesToDescription.php index 9c3f6e1d63..7595ef7de4 100644 --- a/app/TransactionRules/Actions/AppendNotesToDescription.php +++ b/app/TransactionRules/Actions/AppendNotesToDescription.php @@ -55,7 +55,7 @@ class AppendNotesToDescription implements ActionInterface $this->refreshNotes($journal); /** @var null|TransactionJournal $object */ - $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); + $object = TransactionJournal::query()->where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); if (null === $object) { Log::error(sprintf('No journal #%d belongs to user #%d.', $journal['transaction_journal_id'], $journal['user_id'])); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.journal_other_user'))); diff --git a/app/TransactionRules/Actions/ClearBudget.php b/app/TransactionRules/Actions/ClearBudget.php index 56ea7093a6..b0725b39f2 100644 --- a/app/TransactionRules/Actions/ClearBudget.php +++ b/app/TransactionRules/Actions/ClearBudget.php @@ -45,7 +45,7 @@ class ClearBudget implements ActionInterface public function actOnArray(array $journal): bool { /** @var TransactionJournal $object */ - $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); + $object = TransactionJournal::query()->where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); $budget = $object->budgets()->first(); if (null === $budget) { Log::debug(sprintf('RuleAction ClearBudget, no budget in journal #%d.', $journal['transaction_journal_id'])); diff --git a/app/TransactionRules/Actions/ClearCategory.php b/app/TransactionRules/Actions/ClearCategory.php index 72ca9b16ad..18b75475bc 100644 --- a/app/TransactionRules/Actions/ClearCategory.php +++ b/app/TransactionRules/Actions/ClearCategory.php @@ -45,7 +45,7 @@ class ClearCategory implements ActionInterface public function actOnArray(array $journal): bool { /** @var TransactionJournal $object */ - $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); + $object = TransactionJournal::query()->where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); $category = $object->categories()->first(); if (null === $category) { Log::debug(sprintf('RuleAction ClearCategory, no category in journal #%d.', $journal['transaction_journal_id'])); diff --git a/app/TransactionRules/Actions/ClearNotes.php b/app/TransactionRules/Actions/ClearNotes.php index 22e1d34117..c8dd978e09 100644 --- a/app/TransactionRules/Actions/ClearNotes.php +++ b/app/TransactionRules/Actions/ClearNotes.php @@ -46,7 +46,7 @@ class ClearNotes implements ActionInterface public function actOnArray(array $journal): bool { /** @var TransactionJournal $object */ - $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); + $object = TransactionJournal::query()->where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); /** @var null|Note $notes */ $notes = $object->notes()->first(); diff --git a/app/TransactionRules/Actions/ConvertToDeposit.php b/app/TransactionRules/Actions/ConvertToDeposit.php index 41378da788..19e47f69e6 100644 --- a/app/TransactionRules/Actions/ConvertToDeposit.php +++ b/app/TransactionRules/Actions/ConvertToDeposit.php @@ -57,14 +57,14 @@ class ConvertToDeposit implements ActionInterface // make object from array (so the data is fresh). /** @var null|TransactionJournal $object */ - $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); + $object = TransactionJournal::query()->where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); if (null === $object) { Log::error(sprintf('Cannot find journal #%d, cannot convert to deposit.', $journal['transaction_journal_id'])); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.journal_not_found'))); return false; } - $groupCount = TransactionJournal::where('transaction_group_id', $journal['transaction_group_id'])->count(); + $groupCount = TransactionJournal::query()->where('transaction_group_id', $journal['transaction_group_id'])->count(); if ($groupCount > 1) { Log::error(sprintf('Group #%d has more than one transaction in it, cannot convert to deposit.', $journal['transaction_group_id'])); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.split_group'))); diff --git a/app/TransactionRules/Actions/ConvertToTransfer.php b/app/TransactionRules/Actions/ConvertToTransfer.php index 43fb44794a..7400129280 100644 --- a/app/TransactionRules/Actions/ConvertToTransfer.php +++ b/app/TransactionRules/Actions/ConvertToTransfer.php @@ -62,14 +62,14 @@ class ConvertToTransfer implements ActionInterface // make object from array (so the data is fresh). /** @var null|TransactionJournal $object */ - $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); + $object = TransactionJournal::query()->where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); if (null === $object) { Log::error(sprintf('Cannot find journal #%d, cannot convert to transfer.', $journal['transaction_journal_id'])); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.journal_not_found'))); return false; } - $groupCount = TransactionJournal::where('transaction_group_id', $journal['transaction_group_id'])->count(); + $groupCount = TransactionJournal::query()->where('transaction_group_id', $journal['transaction_group_id'])->count(); if ($groupCount > 1) { Log::error(sprintf('Group #%d has more than one transaction in it, cannot convert to transfer.', $journal['transaction_group_id'])); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.split_group'))); @@ -232,10 +232,10 @@ class ConvertToTransfer implements ActionInterface } /** @var Transaction $sourceTransaction */ - $sourceTransaction = Transaction::where('transaction_journal_id', '=', $journal->id)->where('amount', '<', 0)->first(); + $sourceTransaction = Transaction::query()->where('transaction_journal_id', '=', $journal->id)->where('amount', '<', 0)->first(); /** @var Transaction $destTransaction */ - $destTransaction = Transaction::where('transaction_journal_id', '=', $journal->id)->where('amount', '>', 0)->first(); + $destTransaction = Transaction::query()->where('transaction_journal_id', '=', $journal->id)->where('amount', '>', 0)->first(); // update destination transaction: $destTransaction->account_id = $opposing->id; $destTransaction->save(); diff --git a/app/TransactionRules/Actions/ConvertToWithdrawal.php b/app/TransactionRules/Actions/ConvertToWithdrawal.php index 7cce44767d..513ae6ae67 100644 --- a/app/TransactionRules/Actions/ConvertToWithdrawal.php +++ b/app/TransactionRules/Actions/ConvertToWithdrawal.php @@ -57,14 +57,14 @@ class ConvertToWithdrawal implements ActionInterface // make object from array (so the data is fresh). /** @var null|TransactionJournal $object */ - $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); + $object = TransactionJournal::query()->where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); if (null === $object) { Log::error(sprintf('Cannot find journal #%d, cannot convert to withdrawal.', $journal['transaction_journal_id'])); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.journal_not_found'))); return false; } - $groupCount = TransactionJournal::where('transaction_group_id', $journal['transaction_group_id'])->count(); + $groupCount = TransactionJournal::query()->where('transaction_group_id', $journal['transaction_group_id'])->count(); if ($groupCount > 1) { Log::error(sprintf('Group #%d has more than one transaction in it, cannot convert to withdrawal.', $journal['transaction_group_id'])); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.split_group'))); diff --git a/app/TransactionRules/Actions/DeleteTransaction.php b/app/TransactionRules/Actions/DeleteTransaction.php index 1f304e4b08..7a1ef76f8e 100644 --- a/app/TransactionRules/Actions/DeleteTransaction.php +++ b/app/TransactionRules/Actions/DeleteTransaction.php @@ -45,7 +45,7 @@ class DeleteTransaction implements ActionInterface public function actOnArray(array $journal): bool { - $count = TransactionJournal::where('transaction_group_id', $journal['transaction_group_id'])->count(); + $count = TransactionJournal::query()->where('transaction_group_id', $journal['transaction_group_id'])->count(); // destroy entire group. if (1 === $count) { diff --git a/app/TransactionRules/Actions/LinkToBill.php b/app/TransactionRules/Actions/LinkToBill.php index 0f2cc0c4f8..b1b74ed43d 100644 --- a/app/TransactionRules/Actions/LinkToBill.php +++ b/app/TransactionRules/Actions/LinkToBill.php @@ -57,7 +57,7 @@ class LinkToBill implements ActionInterface $bill = $repository->findByName($billName); /** @var TransactionJournal $object */ - $object = TransactionJournal::with('transactionType')->find($journal['transaction_journal_id']); + $object = TransactionJournal::query()->with('transactionType')->find($journal['transaction_journal_id']); $type = $object->transactionType->type; if (null !== $bill && TransactionTypeEnum::WITHDRAWAL->value === $type) { @@ -82,7 +82,7 @@ class LinkToBill implements ActionInterface )); /** @var TransactionJournal $object */ - $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); + $object = TransactionJournal::query()->where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); event(new TransactionGroupRequestsAuditLogEntry($this->action->rule, $object, 'set_bill', null, $bill->name)); return true; diff --git a/app/TransactionRules/Actions/MoveDescriptionToNotes.php b/app/TransactionRules/Actions/MoveDescriptionToNotes.php index d88d0f34cd..a741fdf1bc 100644 --- a/app/TransactionRules/Actions/MoveDescriptionToNotes.php +++ b/app/TransactionRules/Actions/MoveDescriptionToNotes.php @@ -47,7 +47,7 @@ class MoveDescriptionToNotes implements ActionInterface public function actOnArray(array $journal): bool { /** @var null|TransactionJournal $object */ - $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); + $object = TransactionJournal::query()->where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); if (null === $object) { Log::error(sprintf('No journal #%d belongs to user #%d.', $journal['transaction_journal_id'], $journal['user_id'])); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.journal_other_user'))); diff --git a/app/TransactionRules/Actions/MoveNotesToDescription.php b/app/TransactionRules/Actions/MoveNotesToDescription.php index a7e51c8f00..340d5db08b 100644 --- a/app/TransactionRules/Actions/MoveNotesToDescription.php +++ b/app/TransactionRules/Actions/MoveNotesToDescription.php @@ -53,7 +53,7 @@ class MoveNotesToDescription implements ActionInterface public function actOnArray(array $journal): bool { /** @var null|TransactionJournal $object */ - $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); + $object = TransactionJournal::query()->where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); if (null === $object) { Log::error(sprintf('No journal #%d belongs to user #%d.', $journal['transaction_journal_id'], $journal['user_id'])); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.journal_other_user'))); diff --git a/app/TransactionRules/Actions/PrependDescription.php b/app/TransactionRules/Actions/PrependDescription.php index 3971caa08f..5c82e30e25 100644 --- a/app/TransactionRules/Actions/PrependDescription.php +++ b/app/TransactionRules/Actions/PrependDescription.php @@ -49,7 +49,7 @@ class PrependDescription implements ActionInterface // journal /** @var TransactionJournal $object */ - $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); + $object = TransactionJournal::query()->where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); // audit log event(new TransactionGroupRequestsAuditLogEntry($this->action->rule, $object, 'update_description', $before, $after)); diff --git a/app/TransactionRules/Actions/PrependNotes.php b/app/TransactionRules/Actions/PrependNotes.php index 4afe1fb19e..43bb600c74 100644 --- a/app/TransactionRules/Actions/PrependNotes.php +++ b/app/TransactionRules/Actions/PrependNotes.php @@ -44,7 +44,7 @@ class PrependNotes implements ActionInterface public function actOnArray(array $journal): bool { - $dbNote = Note::where('noteable_id', (int) $journal['transaction_journal_id']) + $dbNote = Note::query()->where('noteable_id', (int) $journal['transaction_journal_id']) ->where('noteable_type', TransactionJournal::class) ->first(['notes.*']) ; @@ -63,7 +63,7 @@ class PrependNotes implements ActionInterface // journal /** @var TransactionJournal $object */ - $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); + $object = TransactionJournal::query()->where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); // audit log event(new TransactionGroupRequestsAuditLogEntry($this->action->rule, $object, 'update_notes', $before, $text)); diff --git a/app/TransactionRules/Actions/RemoveAllTags.php b/app/TransactionRules/Actions/RemoveAllTags.php index 2e1ea0457d..a675bee0b8 100644 --- a/app/TransactionRules/Actions/RemoveAllTags.php +++ b/app/TransactionRules/Actions/RemoveAllTags.php @@ -55,7 +55,7 @@ class RemoveAllTags implements ActionInterface Log::debug(sprintf('RuleAction RemoveAllTags removed all tags from journal %d.', $journal['transaction_journal_id'])); /** @var TransactionJournal $object */ - $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); + $object = TransactionJournal::query()->where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); // audit log event(new TransactionGroupRequestsAuditLogEntry($this->action->rule, $object, 'clear_all_tags', null, null)); diff --git a/app/TransactionRules/Actions/RemoveTag.php b/app/TransactionRules/Actions/RemoveTag.php index 6d0ea05907..82956518e8 100644 --- a/app/TransactionRules/Actions/RemoveTag.php +++ b/app/TransactionRules/Actions/RemoveTag.php @@ -78,7 +78,7 @@ class RemoveTag implements ActionInterface DB::table('tag_transaction_journal')->where('transaction_journal_id', $journal['transaction_journal_id'])->where('tag_id', $tag->id)->delete(); /** @var TransactionJournal $object */ - $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); + $object = TransactionJournal::query()->where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); event(new TransactionGroupRequestsAuditLogEntry($this->action->rule, $object, 'clear_tag', $tag->tag, null)); return true; diff --git a/app/TransactionRules/Actions/SetAmount.php b/app/TransactionRules/Actions/SetAmount.php index 69e2a071ea..b4512d26dc 100644 --- a/app/TransactionRules/Actions/SetAmount.php +++ b/app/TransactionRules/Actions/SetAmount.php @@ -49,7 +49,7 @@ class SetAmount implements ActionInterface $this->refreshNotes($journal); // not on slpit transactions - $groupCount = TransactionJournal::where('transaction_group_id', $journal['transaction_group_id'])->count(); + $groupCount = TransactionJournal::query()->where('transaction_group_id', $journal['transaction_group_id'])->count(); if ($groupCount > 1) { Log::error(sprintf('Group #%d has more than one transaction in it, cannot convert to transfer.', $journal['transaction_group_id'])); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.split_group'))); @@ -67,7 +67,7 @@ class SetAmount implements ActionInterface } /** @var TransactionJournal $object */ - $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); + $object = TransactionJournal::query()->where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); $positive = Steam::positive($value); $negative = Steam::negative($value); diff --git a/app/TransactionRules/Actions/SetBudget.php b/app/TransactionRules/Actions/SetBudget.php index c93ba181eb..a9156e5c8d 100644 --- a/app/TransactionRules/Actions/SetBudget.php +++ b/app/TransactionRules/Actions/SetBudget.php @@ -102,7 +102,7 @@ class SetBudget implements ActionInterface ]); /** @var TransactionJournal $object */ - $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); + $object = TransactionJournal::query()->where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); event(new TransactionGroupRequestsAuditLogEntry($this->action->rule, $object, 'set_budget', $oldBudgetName, $budget->name)); return true; diff --git a/app/TransactionRules/Actions/SetCategory.php b/app/TransactionRules/Actions/SetCategory.php index d1169898be..0e20efcc72 100644 --- a/app/TransactionRules/Actions/SetCategory.php +++ b/app/TransactionRules/Actions/SetCategory.php @@ -96,7 +96,7 @@ class SetCategory implements ActionInterface ]); /** @var TransactionJournal $object */ - $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); + $object = TransactionJournal::query()->where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); event(new TransactionGroupRequestsAuditLogEntry($this->action->rule, $object, 'set_category', $oldCategoryName, $category->name)); return true; diff --git a/app/TransactionRules/Actions/SetDescription.php b/app/TransactionRules/Actions/SetDescription.php index 00bf47339c..81f1d3563f 100644 --- a/app/TransactionRules/Actions/SetDescription.php +++ b/app/TransactionRules/Actions/SetDescription.php @@ -49,7 +49,7 @@ class SetDescription implements ActionInterface $this->refreshNotes($journal); /** @var TransactionJournal $object */ - $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); + $object = TransactionJournal::query()->where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); $before = $object->description; $after = $this->action->getValue($journal); diff --git a/app/TransactionRules/Actions/SetNotes.php b/app/TransactionRules/Actions/SetNotes.php index 53b3c18592..4c67aeae9d 100644 --- a/app/TransactionRules/Actions/SetNotes.php +++ b/app/TransactionRules/Actions/SetNotes.php @@ -43,7 +43,7 @@ class SetNotes implements ActionInterface public function actOnArray(array $journal): bool { - $dbNote = Note::where('noteable_id', $journal['transaction_journal_id'])->where('noteable_type', TransactionJournal::class)->first(); + $dbNote = Note::query()->where('noteable_id', $journal['transaction_journal_id'])->where('noteable_type', TransactionJournal::class)->first(); if (null === $dbNote) { $dbNote = new Note(); $dbNote->noteable_id = $journal['transaction_journal_id']; @@ -63,7 +63,7 @@ class SetNotes implements ActionInterface )); /** @var TransactionJournal $object */ - $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); + $object = TransactionJournal::query()->where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); event(new TransactionGroupRequestsAuditLogEntry($this->action->rule, $object, 'update_notes', $oldNotes, $newNotes)); diff --git a/app/TransactionRules/Actions/SwitchAccounts.php b/app/TransactionRules/Actions/SwitchAccounts.php index f04a17125d..4ddc58fca2 100644 --- a/app/TransactionRules/Actions/SwitchAccounts.php +++ b/app/TransactionRules/Actions/SwitchAccounts.php @@ -48,14 +48,14 @@ class SwitchAccounts implements ActionInterface { // make object from array (so the data is fresh). /** @var null|TransactionJournal $object */ - $object = TransactionJournal::where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); + $object = TransactionJournal::query()->where('user_id', $journal['user_id'])->find($journal['transaction_journal_id']); if (null === $object) { Log::error(sprintf('Cannot find journal #%d, cannot switch accounts.', $journal['transaction_journal_id'])); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.no_such_journal'))); return false; } - $groupCount = TransactionJournal::where('transaction_group_id', $journal['transaction_group_id'])->count(); + $groupCount = TransactionJournal::query()->where('transaction_group_id', $journal['transaction_group_id'])->count(); if ($groupCount > 1) { Log::error(sprintf('Group #%d has more than one transaction in it, cannot switch accounts.', $journal['transaction_group_id'])); event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.split_group'))); diff --git a/app/TransactionRules/Engine/SearchRuleEngine.php b/app/TransactionRules/Engine/SearchRuleEngine.php index 7985baea0b..574ebf60a5 100644 --- a/app/TransactionRules/Engine/SearchRuleEngine.php +++ b/app/TransactionRules/Engine/SearchRuleEngine.php @@ -189,7 +189,7 @@ class SearchRuleEngine implements RuleEngineInterface private function addNotes(array $transaction): array { $transaction['notes'] = ''; - $dbNote = Note::where('noteable_id', (int) $transaction['transaction_journal_id']) + $dbNote = Note::query()->where('noteable_id', (int) $transaction['transaction_journal_id']) ->where('noteable_type', TransactionJournal::class) ->first(['notes.*']) ; diff --git a/app/TransactionRules/Traits/RefreshNotesTrait.php b/app/TransactionRules/Traits/RefreshNotesTrait.php index 5782475a22..5168a24552 100644 --- a/app/TransactionRules/Traits/RefreshNotesTrait.php +++ b/app/TransactionRules/Traits/RefreshNotesTrait.php @@ -33,7 +33,7 @@ trait RefreshNotesTrait final protected function refreshNotes(array $transaction): array { $transaction['notes'] = ''; - $dbNote = Note::where('noteable_id', (int) $transaction['transaction_journal_id']) + $dbNote = Note::query()->where('noteable_id', (int) $transaction['transaction_journal_id']) ->where('noteable_type', TransactionJournal::class) ->first(['notes.*']) ; diff --git a/app/User.php b/app/User.php index eb276702fc..3fde323914 100644 --- a/app/User.php +++ b/app/User.php @@ -489,7 +489,7 @@ class User extends Authenticatable implements OAuthenticatable Log::debug(sprintf('in hasAnyRoleInGroup(%s)', implode(', ', $roles))); /** @var Collection $dbRoles */ - $dbRoles = UserRole::whereIn('title', $roles)->get(); + $dbRoles = UserRole::query()->whereIn('title', $roles)->get(); if (0 === $dbRoles->count()) { Log::error(sprintf('Could not find role(s): %s. Probably migration mishap.', implode(', ', $roles))); diff --git a/app/Validation/FireflyValidator.php b/app/Validation/FireflyValidator.php index 7799c7ae3c..2b2b84fea7 100644 --- a/app/Validation/FireflyValidator.php +++ b/app/Validation/FireflyValidator.php @@ -472,7 +472,7 @@ class FireflyValidator extends Validator // check transaction type. // TODO create a helper to automatically return these. if ('transaction_type' === $triggerType) { - $count = TransactionType::where('type', ucfirst((string) $value))->count(); + $count = TransactionType::query()->where('type', ucfirst((string) $value))->count(); return 1 === $count; } @@ -881,7 +881,7 @@ class FireflyValidator extends Validator return false; } - $accountTypes = AccountType::whereIn('type', $search)->get(); + $accountTypes = AccountType::query()->whereIn('type', $search)->get(); $ignore = (int) ($parameters[0] ?? 0.0); $accountTypeIds = $accountTypes->pluck('id')->toArray(); diff --git a/app/Validation/TransactionValidation.php b/app/Validation/TransactionValidation.php index f044d4dedf..ebb2bb4da1 100644 --- a/app/Validation/TransactionValidation.php +++ b/app/Validation/TransactionValidation.php @@ -495,14 +495,14 @@ trait TransactionValidation } /** @var null|Transaction $source */ - $source = Transaction::where('transaction_journal_id', $journalId)->where('amount', '<', 0)->with(['account'])->first(); + $source = Transaction::query()->where('transaction_journal_id', $journalId)->where('amount', '<', 0)->with(['account'])->first(); if (null !== $source) { $return['source_id'] = $source->account_id; $return['source_name'] = $source->account->name; } /** @var null|Transaction $destination */ - $destination = Transaction::where('transaction_journal_id', $journalId)->where('amount', '>', 0)->with(['account'])->first(); + $destination = Transaction::query()->where('transaction_journal_id', $journalId)->where('amount', '>', 0)->with(['account'])->first(); if (null !== $destination) { $return['destination_id'] = $destination->account_id; $return['destination_name'] = $destination->account->name; @@ -537,7 +537,7 @@ trait TransactionValidation } /** @var null|TransactionJournal $journal */ - $journal = TransactionJournal::with(['transactionType'])->find($journalId); + $journal = TransactionJournal::query()->with(['transactionType'])->find($journalId); if (null !== $journal) { return strtolower((string) $journal->transactionType->type); } diff --git a/database/factories/AccountFactory.php b/database/factories/AccountFactory.php index 09487b3d4a..3bd9d6020a 100644 --- a/database/factories/AccountFactory.php +++ b/database/factories/AccountFactory.php @@ -12,11 +12,11 @@ class AccountFactory extends Factory { public function definition(): array { - return ['name' => $this->faker->name(), 'active' => true]; + return ['name' => fake()->name(), 'active' => true]; } public function withType(AccountTypeEnum $type): static { - return $this->for(AccountType::where('type', $type->value)->first()); + return $this->for(AccountType::query()->where('type', $type->value)->first()); } } diff --git a/database/seeders/AccountTypeSeeder.php b/database/seeders/AccountTypeSeeder.php index a47ec0b129..e82c955e5f 100644 --- a/database/seeders/AccountTypeSeeder.php +++ b/database/seeders/AccountTypeSeeder.php @@ -37,7 +37,7 @@ class AccountTypeSeeder extends Seeder public function run(): void { foreach (AccountTypeEnum::cases() as $type) { - if (null === AccountType::where('type', $type->value)->first()) { + if (null === AccountType::query()->where('type', $type->value)->first()) { try { AccountType::create(['type' => $type->value]); } catch (PDOException) { diff --git a/database/seeders/ConfigSeeder.php b/database/seeders/ConfigSeeder.php index 8d22729149..d2f1d6eb60 100644 --- a/database/seeders/ConfigSeeder.php +++ b/database/seeders/ConfigSeeder.php @@ -37,7 +37,7 @@ class ConfigSeeder extends Seeder */ public function run(): void { - $entry = Configuration::where('name', 'db_version')->first(); + $entry = Configuration::query()->where('name', 'db_version')->first(); if (null === $entry) { Configuration::create(['name' => 'db_version', 'data' => 1]); diff --git a/database/seeders/ExchangeRateSeeder.php b/database/seeders/ExchangeRateSeeder.php index f45a119f7c..a234eedb7c 100644 --- a/database/seeders/ExchangeRateSeeder.php +++ b/database/seeders/ExchangeRateSeeder.php @@ -88,7 +88,7 @@ class ExchangeRateSeeder extends Seeder private function getCurrency(string $code): null|TransactionCurrency { - return TransactionCurrency::whereNull('deleted_at')->where('code', $code)->first(); + return TransactionCurrency::query()->whereNull('deleted_at')->where('code', $code)->first(); } private function hasRate(User $user, TransactionCurrency $from, TransactionCurrency $to, string $date): bool diff --git a/database/seeders/LinkTypeSeeder.php b/database/seeders/LinkTypeSeeder.php index 1dd73e8d9a..0aa722ca6e 100644 --- a/database/seeders/LinkTypeSeeder.php +++ b/database/seeders/LinkTypeSeeder.php @@ -42,7 +42,7 @@ class LinkTypeSeeder extends Seeder ['name' => 'Reimbursement', 'inward' => 'is (partially) reimbursed by', 'outward' => '(partially) reimburses', 'editable' => false] ]; foreach ($types as $type) { - if (null === LinkType::where('name', $type['name'])->first()) { + if (null === LinkType::query()->where('name', $type['name'])->first()) { try { LinkType::create($type); } catch (PDOException) { diff --git a/database/seeders/PermissionSeeder.php b/database/seeders/PermissionSeeder.php index fd8b35d1d6..a6b4c2ca86 100644 --- a/database/seeders/PermissionSeeder.php +++ b/database/seeders/PermissionSeeder.php @@ -40,7 +40,7 @@ class PermissionSeeder extends Seeder ['name' => 'demo', 'display_name' => 'Demo User', 'description' => 'User is a demo user'] ]; foreach ($roles as $role) { - if (null === Role::where('name', $role['name'])->first()) { + if (null === Role::query()->where('name', $role['name'])->first()) { try { Role::create($role); } catch (PDOException) { diff --git a/database/seeders/TransactionCurrencySeeder.php b/database/seeders/TransactionCurrencySeeder.php index d9aacbb18d..d3d812d8db 100644 --- a/database/seeders/TransactionCurrencySeeder.php +++ b/database/seeders/TransactionCurrencySeeder.php @@ -91,7 +91,7 @@ class TransactionCurrencySeeder extends Seeder $currencies[] = ['code' => 'THB', 'name' => 'Thai baht', 'symbol' => '฿', 'decimal_places' => 2]; foreach ($currencies as $currency) { - if (null === TransactionCurrency::where('code', $currency['code'])->first()) { + if (null === TransactionCurrency::query()->where('code', $currency['code'])->first()) { try { TransactionCurrency::create($currency); } catch (PDOException) { diff --git a/database/seeders/TransactionTypeSeeder.php b/database/seeders/TransactionTypeSeeder.php index 7f82a82709..8c432bdb10 100644 --- a/database/seeders/TransactionTypeSeeder.php +++ b/database/seeders/TransactionTypeSeeder.php @@ -38,7 +38,7 @@ class TransactionTypeSeeder extends Seeder { /** @var TransactionTypeEnum $type */ foreach (TransactionTypeEnum::cases() as $type) { - if (null === TransactionType::where('type', $type->value)->first()) { + if (null === TransactionType::query()->where('type', $type->value)->first()) { try { TransactionType::create(['type' => $type->value]); } catch (PDOException $e) { diff --git a/database/seeders/UserRoleSeeder.php b/database/seeders/UserRoleSeeder.php index 342fefaf94..f8e570eec0 100644 --- a/database/seeders/UserRoleSeeder.php +++ b/database/seeders/UserRoleSeeder.php @@ -42,7 +42,7 @@ class UserRoleSeeder extends Seeder { /** @var UserRoleEnum $role */ foreach (UserRoleEnum::cases() as $role) { - if (null === UserRole::where('title', $role->value)->first()) { + if (null === UserRole::query()->where('title', $role->value)->first()) { try { UserRole::create(['title' => $role->value]); } catch (PDOException) { diff --git a/database/seeders/WebhookDataSeeder.php b/database/seeders/WebhookDataSeeder.php index 4a000ffc25..d3e83a11d0 100644 --- a/database/seeders/WebhookDataSeeder.php +++ b/database/seeders/WebhookDataSeeder.php @@ -41,7 +41,7 @@ class WebhookDataSeeder extends Seeder public function run(): void { foreach (WebhookTrigger::cases() as $trigger) { - if (null === WebhookTriggerModel::where('key', $trigger->value)->where('title', $trigger->name)->first()) { + if (null === WebhookTriggerModel::query()->where('key', $trigger->value)->where('title', $trigger->name)->first()) { try { WebhookTriggerModel::create(['key' => $trigger->value, 'title' => $trigger->name]); } catch (\PDOException $e) { @@ -50,7 +50,7 @@ class WebhookDataSeeder extends Seeder } } foreach (WebhookResponse::cases() as $response) { - if (null === WebhookResponseModel::where('key', $response->value)->where('title', $response->name)->first()) { + if (null === WebhookResponseModel::query()->where('key', $response->value)->where('title', $response->name)->first()) { try { WebhookResponseModel::create(['key' => $response->value, 'title' => $response->name]); } catch (\PDOException $e) { @@ -59,7 +59,7 @@ class WebhookDataSeeder extends Seeder } } foreach (WebhookDelivery::cases() as $delivery) { - if (null === WebhookDeliveryModel::where('key', $delivery->value)->where('title', $delivery->name)->first()) { + if (null === WebhookDeliveryModel::query()->where('key', $delivery->value)->where('title', $delivery->name)->first()) { try { WebhookDeliveryModel::create(['key' => $delivery->value, 'title' => $delivery->name]); } catch (\PDOException $e) { diff --git a/tests/integration/Api/Autocomplete/AccountControllerTest.php b/tests/integration/Api/Autocomplete/AccountControllerTest.php index eb4b56ce37..a5e9787003 100644 --- a/tests/integration/Api/Autocomplete/AccountControllerTest.php +++ b/tests/integration/Api/Autocomplete/AccountControllerTest.php @@ -42,7 +42,7 @@ final class AccountControllerTest extends TestCase { // test API $response = $this->get(route('api.v1.autocomplete.accounts'), ['Accept' => 'application/json']); - $response->assertStatus(401); + $response->assertUnauthorized(); $response->assertHeader('Content-Type', 'application/json'); $response->assertContent('{"message":"Unauthenticated.","exception":"AuthenticationException"}'); } diff --git a/tests/integration/Api/Autocomplete/BillControllerTest.php b/tests/integration/Api/Autocomplete/BillControllerTest.php index 41c7d64454..e213289698 100644 --- a/tests/integration/Api/Autocomplete/BillControllerTest.php +++ b/tests/integration/Api/Autocomplete/BillControllerTest.php @@ -47,7 +47,7 @@ final class BillControllerTest extends TestCase { // test API $response = $this->get(route('api.v1.autocomplete.bills'), ['Accept' => 'application/json']); - $response->assertStatus(401); + $response->assertUnauthorized(); $response->assertHeader('Content-Type', 'application/json'); $response->assertContent('{"message":"Unauthenticated.","exception":"AuthenticationException"}'); } @@ -59,7 +59,7 @@ final class BillControllerTest extends TestCase $this->actingAs($user); $response = $this->get(route('api.v1.autocomplete.bills'), ['Accept' => 'application/json']); - $response->assertStatus(200); + $response->assertOk(); $response->assertHeader('Content-Type', 'application/json'); } @@ -70,7 +70,7 @@ final class BillControllerTest extends TestCase $this->createTestBills(5, $user); $response = $this->get(route('api.v1.autocomplete.bills'), ['Accept' => 'application/json']); - $response->assertStatus(200); + $response->assertOk(); $response->assertHeader('Content-Type', 'application/json'); $response->assertJsonCount(5); $response->assertJsonFragment(['name' => 'Bill 1']); @@ -85,7 +85,7 @@ final class BillControllerTest extends TestCase $this->createTestBills(20, $user); $response = $this->get(route('api.v1.autocomplete.bills', ['query' => 'Bill 1', 'limit' => 20]), ['Accept' => 'application/json']); - $response->assertStatus(200); + $response->assertOk(); $response->assertHeader('Content-Type', 'application/json'); // Bill 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 (11) $response->assertJsonCount(11); @@ -100,7 +100,7 @@ final class BillControllerTest extends TestCase $this->createTestBills(5, $user); $response = $this->get(route('api.v1.autocomplete.bills', ['query' => 'Bill', 'limit' => 3]), ['Accept' => 'application/json']); - $response->assertStatus(200); + $response->assertOk(); $response->assertHeader('Content-Type', 'application/json'); $response->assertJsonCount(3); $response->assertJsonFragment(['name' => 'Bill 1']); diff --git a/tests/integration/Api/Autocomplete/BudgetControllerTest.php b/tests/integration/Api/Autocomplete/BudgetControllerTest.php index 24cd2f4326..7c68f52971 100644 --- a/tests/integration/Api/Autocomplete/BudgetControllerTest.php +++ b/tests/integration/Api/Autocomplete/BudgetControllerTest.php @@ -47,7 +47,7 @@ final class BudgetControllerTest extends TestCase { // test API $response = $this->get(route('api.v1.autocomplete.budgets'), ['Accept' => 'application/json']); - $response->assertStatus(401); + $response->assertUnauthorized(); $response->assertHeader('Content-Type', 'application/json'); $response->assertContent('{"message":"Unauthenticated.","exception":"AuthenticationException"}'); } @@ -59,7 +59,7 @@ final class BudgetControllerTest extends TestCase $this->actingAs($user); $response = $this->get(route('api.v1.autocomplete.budgets'), ['Accept' => 'application/json']); - $response->assertStatus(200); + $response->assertOk(); $response->assertHeader('Content-Type', 'application/json'); } @@ -70,7 +70,7 @@ final class BudgetControllerTest extends TestCase $this->createTestBudgets(5, $user); $response = $this->get(route('api.v1.autocomplete.budgets'), ['Accept' => 'application/json']); - $response->assertStatus(200); + $response->assertOk(); $response->assertHeader('Content-Type', 'application/json'); $response->assertJsonCount(5); $response->assertJsonFragment(['name' => 'Budget 1']); @@ -85,7 +85,7 @@ final class BudgetControllerTest extends TestCase $this->createTestBudgets(20, $user); $response = $this->get(route('api.v1.autocomplete.budgets', ['query' => 'Budget 1', 'limit' => 20]), ['Accept' => 'application/json']); - $response->assertStatus(200); + $response->assertOk(); $response->assertHeader('Content-Type', 'application/json'); // Budget 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 (11) $response->assertJsonCount(11); @@ -100,7 +100,7 @@ final class BudgetControllerTest extends TestCase $this->createTestBudgets(5, $user); $response = $this->get(route('api.v1.autocomplete.budgets', ['query' => 'Budget', 'limit' => 3]), ['Accept' => 'application/json']); - $response->assertStatus(200); + $response->assertOk(); $response->assertHeader('Content-Type', 'application/json'); $response->assertJsonCount(3); } diff --git a/tests/integration/Api/Autocomplete/CategoryControllerTest.php b/tests/integration/Api/Autocomplete/CategoryControllerTest.php index d5c711aa6d..f9323c1044 100644 --- a/tests/integration/Api/Autocomplete/CategoryControllerTest.php +++ b/tests/integration/Api/Autocomplete/CategoryControllerTest.php @@ -47,7 +47,7 @@ final class CategoryControllerTest extends TestCase { // test API $response = $this->get(route('api.v1.autocomplete.categories'), ['Accept' => 'application/json']); - $response->assertStatus(401); + $response->assertUnauthorized(); $response->assertHeader('Content-Type', 'application/json'); $response->assertContent('{"message":"Unauthenticated.","exception":"AuthenticationException"}'); } @@ -59,7 +59,7 @@ final class CategoryControllerTest extends TestCase $this->actingAs($user); $response = $this->get(route('api.v1.autocomplete.categories'), ['Accept' => 'application/json']); - $response->assertStatus(200); + $response->assertOk(); $response->assertHeader('Content-Type', 'application/json'); } @@ -70,7 +70,7 @@ final class CategoryControllerTest extends TestCase $this->createTestCategories(5, $user); $response = $this->get(route('api.v1.autocomplete.categories'), ['Accept' => 'application/json']); - $response->assertStatus(200); + $response->assertOk(); $response->assertHeader('Content-Type', 'application/json'); $response->assertJsonCount(5); $response->assertJsonFragment(['name' => 'Category 1']); @@ -85,7 +85,7 @@ final class CategoryControllerTest extends TestCase $this->createTestCategories(20, $user); $response = $this->get(route('api.v1.autocomplete.categories', ['query' => 'Category 1', 'limit' => 20]), ['Accept' => 'application/json']); - $response->assertStatus(200); + $response->assertOk(); $response->assertHeader('Content-Type', 'application/json'); // Category 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 (11) $response->assertJsonCount(11); @@ -100,7 +100,7 @@ final class CategoryControllerTest extends TestCase $this->createTestCategories(5, $user); $response = $this->get(route('api.v1.autocomplete.categories', ['query' => 'Category', 'limit' => 3]), ['Accept' => 'application/json']); - $response->assertStatus(200); + $response->assertOk(); $response->assertHeader('Content-Type', 'application/json'); $response->assertJsonCount(3); } diff --git a/tests/integration/Api/Autocomplete/CurrencyControllerTest.php b/tests/integration/Api/Autocomplete/CurrencyControllerTest.php index 9a9cbe76bf..06d3c0c5d8 100644 --- a/tests/integration/Api/Autocomplete/CurrencyControllerTest.php +++ b/tests/integration/Api/Autocomplete/CurrencyControllerTest.php @@ -46,7 +46,7 @@ final class CurrencyControllerTest extends TestCase { // test API $response = $this->get(route('api.v1.autocomplete.currencies'), ['Accept' => 'application/json']); - $response->assertStatus(401); + $response->assertUnauthorized(); $response->assertHeader('Content-Type', 'application/json'); $response->assertContent('{"message":"Unauthenticated.","exception":"AuthenticationException"}'); } @@ -62,7 +62,7 @@ final class CurrencyControllerTest extends TestCase // test API $response = $this->get(route('api.v1.autocomplete.currencies'), ['Accept' => 'application/json']); - $response->assertStatus(200); + $response->assertOk(); $response->assertHeader('Content-Type', 'application/json'); $response->assertJsonCount(1); // always connects to EUR. } @@ -75,7 +75,7 @@ final class CurrencyControllerTest extends TestCase // test API $response = $this->get(route('api.v1.autocomplete.currencies'), ['Accept' => 'application/json']); - $response->assertStatus(200); + $response->assertOk(); $response->assertHeader('Content-Type', 'application/json'); } @@ -90,7 +90,7 @@ final class CurrencyControllerTest extends TestCase // test API $response = $this->get(route('api.v1.autocomplete.currencies'), ['Accept' => 'application/json']); - $response->assertStatus(200); + $response->assertOk(); $response->assertHeader('Content-Type', 'application/json'); $response->assertJsonFragment(['name' => 'Currency 1']); $response->assertJsonFragment(['code' => 'CUR1']); @@ -106,7 +106,7 @@ final class CurrencyControllerTest extends TestCase $this->createTestCurrencies(20, true); $response = $this->get(route('api.v1.autocomplete.currencies', ['query' => 'Currency 1', 'limit' => 20]), ['Accept' => 'application/json']); - $response->assertStatus(200); + $response->assertOk(); $response->assertHeader('Content-Type', 'application/json'); // Currency 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 (11) $response->assertJsonCount(11); @@ -123,7 +123,7 @@ final class CurrencyControllerTest extends TestCase // test API $response = $this->get(route('api.v1.autocomplete.currencies', ['query' => 'Currency 1']), ['Accept' => 'application/json']); - $response->assertStatus(200); + $response->assertOk(); $response->assertHeader('Content-Type', 'application/json'); $response->assertJsonFragment(['name' => 'Currency 1']); $response->assertJsonStructure(['*' => ['id', 'name', 'code', 'symbol', 'decimal_places']]); diff --git a/tests/integration/Api/Autocomplete/ObjectGroupControllerTest.php b/tests/integration/Api/Autocomplete/ObjectGroupControllerTest.php index 064522d651..d5b24102e4 100644 --- a/tests/integration/Api/Autocomplete/ObjectGroupControllerTest.php +++ b/tests/integration/Api/Autocomplete/ObjectGroupControllerTest.php @@ -46,7 +46,7 @@ final class ObjectGroupControllerTest extends TestCase public function testGivenAnUnauthenticatedRequestWhenCallingTheObjectGroupEndpointThenReturn401HttpCode(): void { $response = $this->get(route('api.v1.autocomplete.object-groups'), ['Accept' => 'application/json']); - $response->assertStatus(401); + $response->assertUnauthorized(); $response->assertHeader('Content-Type', 'application/json'); $response->assertContent('{"message":"Unauthenticated.","exception":"AuthenticationException"}'); } @@ -59,7 +59,7 @@ final class ObjectGroupControllerTest extends TestCase // test API $response = $this->get(route('api.v1.autocomplete.object-groups'), ['Accept' => 'application/json']); - $response->assertStatus(200); + $response->assertOk(); $response->assertHeader('Content-Type', 'application/json'); } @@ -70,7 +70,7 @@ final class ObjectGroupControllerTest extends TestCase $this->createTestObjectGroups(5, $user); $response = $this->get(route('api.v1.autocomplete.object-groups'), ['Accept' => 'application/json']); - $response->assertStatus(200); + $response->assertOk(); $response->assertHeader('Content-Type', 'application/json'); $response->assertJsonCount(5); $response->assertJsonFragment(['title' => 'Object Group 1']); @@ -85,7 +85,7 @@ final class ObjectGroupControllerTest extends TestCase $this->createTestObjectGroups(20, $user); $response = $this->get(route('api.v1.autocomplete.object-groups', ['query' => 'Object Group 1', 'limit' => 20]), ['Accept' => 'application/json']); - $response->assertStatus(200); + $response->assertOk(); $response->assertHeader('Content-Type', 'application/json'); // Object Group 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 (11) $response->assertJsonCount(11); @@ -100,7 +100,7 @@ final class ObjectGroupControllerTest extends TestCase $this->createTestObjectGroups(5, $user); $response = $this->get(route('api.v1.autocomplete.object-groups', ['query' => 'Object Group', 'limit' => 3]), ['Accept' => 'application/json']); - $response->assertStatus(200); + $response->assertOk(); $response->assertHeader('Content-Type', 'application/json'); $response->assertJsonCount(3); $response->assertJsonFragment(['name' => 'Object Group 1']); diff --git a/tests/integration/Api/Autocomplete/PiggyBankControllerTest.php b/tests/integration/Api/Autocomplete/PiggyBankControllerTest.php index bf23c5e88c..5480bc35c7 100644 --- a/tests/integration/Api/Autocomplete/PiggyBankControllerTest.php +++ b/tests/integration/Api/Autocomplete/PiggyBankControllerTest.php @@ -51,7 +51,7 @@ final class PiggyBankControllerTest extends TestCase { // test API $response = $this->get(route('api.v1.autocomplete.piggy-banks'), ['Accept' => 'application/json']); - $response->assertStatus(401); + $response->assertUnauthorized(); $response->assertHeader('Content-Type', 'application/json'); $response->assertContent('{"message":"Unauthenticated.","exception":"AuthenticationException"}'); } @@ -63,7 +63,7 @@ final class PiggyBankControllerTest extends TestCase $this->actingAs($user); $response = $this->get(route('api.v1.autocomplete.piggy-banks'), ['Accept' => 'application/json']); - $response->assertStatus(200); + $response->assertOk(); $response->assertHeader('Content-Type', 'application/json'); } @@ -74,7 +74,7 @@ final class PiggyBankControllerTest extends TestCase $this->createTestPiggyBanks(5, $user); $response = $this->get(route('api.v1.autocomplete.piggy-banks'), ['Accept' => 'application/json']); - $response->assertStatus(200); + $response->assertOk(); $response->assertHeader('Content-Type', 'application/json'); $response->assertJsonCount(5); $response->assertJsonFragment(['name' => 'Piggy bank 1']); @@ -89,7 +89,7 @@ final class PiggyBankControllerTest extends TestCase $this->createTestPiggyBanks(20, $user); $response = $this->get(route('api.v1.autocomplete.piggy-banks', ['query' => 'Piggy bank 1', 'limit' => 20]), ['Accept' => 'application/json']); - $response->assertStatus(200); + $response->assertOk(); $response->assertHeader('Content-Type', 'application/json'); // Budget 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 (11) $response->assertJsonCount(11); @@ -104,7 +104,7 @@ final class PiggyBankControllerTest extends TestCase $this->createTestPiggyBanks(5, $user); $response = $this->get(route('api.v1.autocomplete.piggy-banks', ['query' => 'Piggy', 'limit' => 3]), ['Accept' => 'application/json']); - $response->assertStatus(200); + $response->assertOk(); $response->assertHeader('Content-Type', 'application/json'); $response->assertJsonCount(3); } diff --git a/tests/integration/Api/Autocomplete/RecurrenceControllerTest.php b/tests/integration/Api/Autocomplete/RecurrenceControllerTest.php index 230ec4ab47..94ae143bf3 100644 --- a/tests/integration/Api/Autocomplete/RecurrenceControllerTest.php +++ b/tests/integration/Api/Autocomplete/RecurrenceControllerTest.php @@ -50,7 +50,7 @@ final class RecurrenceControllerTest extends TestCase $this->actingAs($user); $response = $this->get(route('api.v1.autocomplete.recurring'), ['Accept' => 'application/json']); - $response->assertStatus(200); + $response->assertOk(); $response->assertHeader('Content-Type', 'application/json'); } @@ -61,7 +61,7 @@ final class RecurrenceControllerTest extends TestCase $this->createTestRecurrences(5, $user); $response = $this->get(route('api.v1.autocomplete.recurring'), ['Accept' => 'application/json']); - $response->assertStatus(200); + $response->assertOk(); $response->assertHeader('Content-Type', 'application/json'); $response->assertJsonCount(5); $response->assertJsonFragment(['name' => 'Recurrence 1']); @@ -76,7 +76,7 @@ final class RecurrenceControllerTest extends TestCase $this->createTestRecurrences(5, $user); $response = $this->get(route('api.v1.autocomplete.recurring', ['query' => 'Recurrence', 'limit' => 3]), ['Accept' => 'application/json']); - $response->assertStatus(200); + $response->assertOk(); $response->assertHeader('Content-Type', 'application/json'); $response->assertJsonCount(3); $response->assertJsonFragment(['name' => 'Recurrence 1']); @@ -91,7 +91,7 @@ final class RecurrenceControllerTest extends TestCase $this->createTestRecurrences(20, $user); $response = $this->get(route('api.v1.autocomplete.recurring', ['query' => 'Recurrence 1', 'limit' => 20]), ['Accept' => 'application/json']); - $response->assertStatus(200); + $response->assertOk(); $response->assertHeader('Content-Type', 'application/json'); // Bill 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 (11) $response->assertJsonCount(11); @@ -102,7 +102,7 @@ final class RecurrenceControllerTest extends TestCase { // test API $response = $this->get(route('api.v1.autocomplete.recurring'), ['Accept' => 'application/json']); - $response->assertStatus(401); + $response->assertUnauthorized(); $response->assertHeader('Content-Type', 'application/json'); $response->assertContent('{"message":"Unauthenticated.","exception":"AuthenticationException"}'); } diff --git a/tests/integration/Api/Autocomplete/RuleControllerTest.php b/tests/integration/Api/Autocomplete/RuleControllerTest.php index 0b5eae1a88..f68cae8a92 100644 --- a/tests/integration/Api/Autocomplete/RuleControllerTest.php +++ b/tests/integration/Api/Autocomplete/RuleControllerTest.php @@ -49,7 +49,7 @@ final class RuleControllerTest extends TestCase $this->actingAs($user); $response = $this->get(route('api.v1.autocomplete.rules'), ['Accept' => 'application/json']); - $response->assertStatus(200); + $response->assertOk(); $response->assertHeader('Content-Type', 'application/json'); } @@ -60,7 +60,7 @@ final class RuleControllerTest extends TestCase $this->createTestRules(5, $user); $response = $this->get(route('api.v1.autocomplete.rules'), ['Accept' => 'application/json']); - $response->assertStatus(200); + $response->assertOk(); $response->assertHeader('Content-Type', 'application/json'); $response->assertJsonCount(5); $response->assertJsonFragment(['name' => 'Rule 1']); @@ -75,7 +75,7 @@ final class RuleControllerTest extends TestCase $this->createTestRules(5, $user); $response = $this->get(route('api.v1.autocomplete.rules', ['query' => 'Rule', 'limit' => 3]), ['Accept' => 'application/json']); - $response->assertStatus(200); + $response->assertOk(); $response->assertHeader('Content-Type', 'application/json'); $response->assertJsonCount(3); $response->assertJsonFragment(['name' => 'Rule 1']); @@ -90,7 +90,7 @@ final class RuleControllerTest extends TestCase $this->createTestRules(20, $user); $response = $this->get(route('api.v1.autocomplete.rules', ['query' => 'Rule 1', 'limit' => 20]), ['Accept' => 'application/json']); - $response->assertStatus(200); + $response->assertOk(); $response->assertHeader('Content-Type', 'application/json'); // Bill 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 (11) $response->assertJsonCount(11); @@ -101,7 +101,7 @@ final class RuleControllerTest extends TestCase { // test API $response = $this->get(route('api.v1.autocomplete.rules'), ['Accept' => 'application/json']); - $response->assertStatus(401); + $response->assertUnauthorized(); $response->assertHeader('Content-Type', 'application/json'); $response->assertContent('{"message":"Unauthenticated.","exception":"AuthenticationException"}'); } diff --git a/tests/integration/Api/Autocomplete/RuleGroupControllerTest.php b/tests/integration/Api/Autocomplete/RuleGroupControllerTest.php index 0131a14f35..b7e24a1efb 100644 --- a/tests/integration/Api/Autocomplete/RuleGroupControllerTest.php +++ b/tests/integration/Api/Autocomplete/RuleGroupControllerTest.php @@ -48,7 +48,7 @@ final class RuleGroupControllerTest extends TestCase $this->actingAs($user); $response = $this->get(route('api.v1.autocomplete.rule-groups'), ['Accept' => 'application/json']); - $response->assertStatus(200); + $response->assertOk(); $response->assertHeader('Content-Type', 'application/json'); } @@ -59,7 +59,7 @@ final class RuleGroupControllerTest extends TestCase $this->createTestRuleGroups(5, $user); $response = $this->get(route('api.v1.autocomplete.rule-groups'), ['Accept' => 'application/json']); - $response->assertStatus(200); + $response->assertOk(); $response->assertHeader('Content-Type', 'application/json'); $response->assertJsonCount(5); $response->assertJsonFragment(['name' => 'RuleGroup 1']); @@ -74,7 +74,7 @@ final class RuleGroupControllerTest extends TestCase $this->createTestRuleGroups(5, $user); $response = $this->get(route('api.v1.autocomplete.rule-groups', ['query' => 'RuleGroup', 'limit' => 3]), ['Accept' => 'application/json']); - $response->assertStatus(200); + $response->assertOk(); $response->assertHeader('Content-Type', 'application/json'); $response->assertJsonCount(3); $response->assertJsonFragment(['name' => 'RuleGroup 1']); @@ -89,7 +89,7 @@ final class RuleGroupControllerTest extends TestCase $this->createTestRuleGroups(20, $user); $response = $this->get(route('api.v1.autocomplete.rule-groups', ['query' => 'RuleGroup 1', 'limit' => 20]), ['Accept' => 'application/json']); - $response->assertStatus(200); + $response->assertOk(); $response->assertHeader('Content-Type', 'application/json'); // Bill 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 (11) $response->assertJsonCount(11); @@ -100,7 +100,7 @@ final class RuleGroupControllerTest extends TestCase { // test API $response = $this->get(route('api.v1.autocomplete.rule-groups'), ['Accept' => 'application/json']); - $response->assertStatus(401); + $response->assertUnauthorized(); $response->assertHeader('Content-Type', 'application/json'); $response->assertContent('{"message":"Unauthenticated.","exception":"AuthenticationException"}'); } diff --git a/tests/integration/Api/Autocomplete/TagControllerTest.php b/tests/integration/Api/Autocomplete/TagControllerTest.php index 0069fbdef9..5a7098993f 100644 --- a/tests/integration/Api/Autocomplete/TagControllerTest.php +++ b/tests/integration/Api/Autocomplete/TagControllerTest.php @@ -48,7 +48,7 @@ final class TagControllerTest extends TestCase $this->actingAs($user); $response = $this->get(route('api.v1.autocomplete.tags'), ['Accept' => 'application/json']); - $response->assertStatus(200); + $response->assertOk(); $response->assertHeader('Content-Type', 'application/json'); } @@ -59,7 +59,7 @@ final class TagControllerTest extends TestCase $this->createTestTags(5, $user); $response = $this->get(route('api.v1.autocomplete.tags'), ['Accept' => 'application/json']); - $response->assertStatus(200); + $response->assertOk(); $response->assertHeader('Content-Type', 'application/json'); $response->assertJsonCount(5); $response->assertJsonFragment(['name' => 'Tag 1']); @@ -74,7 +74,7 @@ final class TagControllerTest extends TestCase $this->createTestTags(5, $user); $response = $this->get(route('api.v1.autocomplete.tags', ['query' => 'Tag', 'limit' => 3]), ['Accept' => 'application/json']); - $response->assertStatus(200); + $response->assertOk(); $response->assertHeader('Content-Type', 'application/json'); $response->assertJsonCount(3); $response->assertJsonFragment(['name' => 'Tag 1']); @@ -89,7 +89,7 @@ final class TagControllerTest extends TestCase $this->createTestTags(20, $user); $response = $this->get(route('api.v1.autocomplete.tags', ['query' => 'Tag 1', 'limit' => 20]), ['Accept' => 'application/json']); - $response->assertStatus(200); + $response->assertOk(); $response->assertHeader('Content-Type', 'application/json'); // Bill 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 (11) $response->assertJsonCount(11); @@ -100,7 +100,7 @@ final class TagControllerTest extends TestCase { // test API $response = $this->get(route('api.v1.autocomplete.tags'), ['Accept' => 'application/json']); - $response->assertStatus(401); + $response->assertUnauthorized(); $response->assertHeader('Content-Type', 'application/json'); $response->assertContent('{"message":"Unauthenticated.","exception":"AuthenticationException"}'); } diff --git a/tests/integration/Api/Chart/AccountControllerTest.php b/tests/integration/Api/Chart/AccountControllerTest.php index 369c2e4989..3f72248dca 100644 --- a/tests/integration/Api/Chart/AccountControllerTest.php +++ b/tests/integration/Api/Chart/AccountControllerTest.php @@ -45,14 +45,14 @@ final class AccountControllerTest extends TestCase $this->actingAs($this->user); $params = ['start' => '2024-01-01', 'end' => '2024-01-31']; $response = $this->getJson(route('api.v1.chart.account.overview').'?'.http_build_query($params)); - $response->assertStatus(200); + $response->assertOk(); } public function testGetOverviewChartFails(): void { $this->actingAs($this->user); $response = $this->getJson(route('api.v1.chart.account.overview')); - $response->assertStatus(422); + $response->assertUnprocessable(); } #[Override] diff --git a/tests/integration/Api/Chart/BalanceControllerTest.php b/tests/integration/Api/Chart/BalanceControllerTest.php index 17bff6a5ff..3aa9705f75 100644 --- a/tests/integration/Api/Chart/BalanceControllerTest.php +++ b/tests/integration/Api/Chart/BalanceControllerTest.php @@ -45,14 +45,14 @@ final class BalanceControllerTest extends TestCase $this->actingAs($this->user); $params = ['start' => '2024-01-01', 'end' => '2024-01-31']; $response = $this->getJson(route('api.v1.chart.balance.balance').'?'.http_build_query($params)); - $response->assertStatus(200); + $response->assertOk(); } public function testGetOverviewChartFails(): void { $this->actingAs($this->user); $response = $this->getJson(route('api.v1.chart.balance.balance')); - $response->assertStatus(422); + $response->assertUnprocessable(); } #[Override] diff --git a/tests/integration/Api/Chart/BudgetControllerTest.php b/tests/integration/Api/Chart/BudgetControllerTest.php index 8bd8aa8711..d7f88dd063 100644 --- a/tests/integration/Api/Chart/BudgetControllerTest.php +++ b/tests/integration/Api/Chart/BudgetControllerTest.php @@ -45,14 +45,14 @@ final class BudgetControllerTest extends TestCase $this->actingAs($this->user); $params = ['start' => '2024-01-01', 'end' => '2024-01-31']; $response = $this->getJson(route('api.v1.chart.budget.overview').'?'.http_build_query($params)); - $response->assertStatus(200); + $response->assertOk(); } public function testGetOverviewChartFails(): void { $this->actingAs($this->user); $response = $this->getJson(route('api.v1.chart.budget.overview')); - $response->assertStatus(422); + $response->assertUnprocessable(); } #[Override] diff --git a/tests/integration/Api/Chart/CategoryControllerTest.php b/tests/integration/Api/Chart/CategoryControllerTest.php index e9f78d0d23..3f6732e343 100644 --- a/tests/integration/Api/Chart/CategoryControllerTest.php +++ b/tests/integration/Api/Chart/CategoryControllerTest.php @@ -45,14 +45,14 @@ final class CategoryControllerTest extends TestCase $this->actingAs($this->user); $params = ['start' => '2024-01-01', 'end' => '2024-01-31']; $response = $this->getJson(route('api.v1.chart.category.overview').'?'.http_build_query($params)); - $response->assertStatus(200); + $response->assertOk(); } public function testGetOverviewChartFails(): void { $this->actingAs($this->user); $response = $this->getJson(route('api.v1.chart.category.overview')); - $response->assertStatus(422); + $response->assertUnprocessable(); } #[Override] diff --git a/tests/integration/Api/Models/Account/ListControllerTest.php b/tests/integration/Api/Models/Account/ListControllerTest.php index 1f19172f6c..c589d1b87e 100644 --- a/tests/integration/Api/Models/Account/ListControllerTest.php +++ b/tests/integration/Api/Models/Account/ListControllerTest.php @@ -48,7 +48,7 @@ final class ListControllerTest extends TestCase { $this->actingAs($this->user); $response = $this->getJson(route('api.v1.accounts.attachments', ['account' => $this->account->id])); - $response->assertStatus(200); + $response->assertOk(); $response->assertJson(['meta' => ['pagination' => ['total' => 2, 'total_pages' => 1]]]); } @@ -56,7 +56,7 @@ final class ListControllerTest extends TestCase { $this->actingAs($this->user); $response = $this->getJson(route('api.v1.accounts.attachments', ['account' => $this->account->id, 'limit' => 1])); - $response->assertStatus(200); + $response->assertOk(); $response->assertJson(['meta' => ['pagination' => ['total' => 2, 'total_pages' => 2]]]); } diff --git a/tests/integration/Api/Models/Account/ShowControllerTest.php b/tests/integration/Api/Models/Account/ShowControllerTest.php index 26b17feef6..716c4b9128 100644 --- a/tests/integration/Api/Models/Account/ShowControllerTest.php +++ b/tests/integration/Api/Models/Account/ShowControllerTest.php @@ -46,7 +46,7 @@ final class ShowControllerTest extends TestCase { $this->actingAs($this->user); $response = $this->getJson(route('api.v1.accounts.index')); - $response->assertStatus(200); + $response->assertOk(); $response->assertJson(['meta' => ['pagination' => ['total' => 5]]]); } @@ -54,7 +54,7 @@ final class ShowControllerTest extends TestCase { $this->actingAs($this->user); $response = $this->getJson(route('api.v1.accounts.index').'?type=asset'); - $response->assertStatus(200); + $response->assertOk(); $response->assertJson([ 'data' => [['attributes' => ['type' => 'asset']], ['attributes' => ['type' => 'asset']]], 'meta' => ['pagination' => ['total' => 2]], @@ -65,7 +65,7 @@ final class ShowControllerTest extends TestCase { $this->actingAs($this->user); $response = $this->getJson(route('api.v1.accounts.index').'?type=foobar'); - $response->assertStatus(422); + $response->assertUnprocessable(); $response->assertJson(['errors' => ['type' => ['The selected type is invalid.']]]); } diff --git a/tests/integration/TestCase.php b/tests/integration/TestCase.php index a982a5b1fc..b01d9bca0d 100644 --- a/tests/integration/TestCase.php +++ b/tests/integration/TestCase.php @@ -60,7 +60,7 @@ abstract class TestCase extends BaseTestCase protected function createAuthenticatedUser(): User { $group = UserGroup::create(['title' => 'test@email.com']); - $role = UserRole::where('title', 'owner')->first(); + $role = UserRole::query()->where('title', 'owner')->first(); $user = User::create(['email' => 'test@email.com', 'password' => 'password', 'user_group_id' => $group->id]); GroupMembership::create(['user_id' => $user->id, 'user_group_id' => $group->id, 'user_role_id' => $role->id]); @@ -70,6 +70,6 @@ abstract class TestCase extends BaseTestCase protected function getAuthenticatedUser(): User { - return User::where('email', 'james@firefly')->first(); + return User::query()->where('email', 'james@firefly')->first(); } } diff --git a/tests/integration/Traits/CollectsValues.php b/tests/integration/Traits/CollectsValues.php index 1917ee1159..bb72e40fc0 100644 --- a/tests/integration/Traits/CollectsValues.php +++ b/tests/integration/Traits/CollectsValues.php @@ -33,6 +33,6 @@ trait CollectsValues { public function user(): User { - return User::where('email', 'james@firefly')->first(); + return User::query()->where('email', 'james@firefly')->first(); } }