Skip to content

Firefly III: a personal finances manager

Various code cleanup.

James Cole1d2e95f5af55
diff --git a/.ci/phpstan.neon b/.ci/phpstan.neon
index 08d6b73f36..d2eafa775a 100644
--- a/.ci/phpstan.neon
+++ b/.ci/phpstan.neon
@@ -56,5 +56,5 @@ parameters:
# The level 8 is the highest level. original was 5
# TODO: slowly up the level and fix the issues found.
- level: 4
+ level: 1
diff --git a/app/Api/V1/Controllers/Autocomplete/AccountController.php b/app/Api/V1/Controllers/Autocomplete/AccountController.php
index 88ead8f293..13de86cfc9 100644
--- a/app/Api/V1/Controllers/Autocomplete/AccountController.php
+++ b/app/Api/V1/Controllers/Autocomplete/AccountController.php
@@ -120,8 +120,8 @@ class AccountController extends Controller
$return,
static function (array $left, array $right) {
$order = [AccountType::ASSET, AccountType::REVENUE, AccountType::EXPENSE];
- $posA = array_search($left['type'], $order, true);
- $posB = array_search($right['type'], $order, true);
+ $posA = (int) array_search($left['type'], $order, true);
+ $posB = (int) array_search($right['type'], $order, true);
return $posA - $posB;
}
diff --git a/app/Api/V1/Controllers/Models/BudgetLimit/ShowController.php b/app/Api/V1/Controllers/Models/BudgetLimit/ShowController.php
index 1a4c4e6302..5957e74b0a 100644
--- a/app/Api/V1/Controllers/Models/BudgetLimit/ShowController.php
+++ b/app/Api/V1/Controllers/Models/BudgetLimit/ShowController.php
@@ -147,7 +147,7 @@ class ShowController extends Controller
*/
public function show(Request $request, Budget $budget, BudgetLimit $budgetLimit): JsonResponse
{
- if ((int)$budget->id !== (int)$budgetLimit->budget_id) {
+ if ($budget->id !== $budgetLimit->budget_id) {
throw new FireflyException('20028: The budget limit does not belong to the budget.');
}
// continue!
diff --git a/app/Api/V1/Controllers/Models/BudgetLimit/UpdateController.php b/app/Api/V1/Controllers/Models/BudgetLimit/UpdateController.php
index 8cf724245d..100d6da9ce 100644
--- a/app/Api/V1/Controllers/Models/BudgetLimit/UpdateController.php
+++ b/app/Api/V1/Controllers/Models/BudgetLimit/UpdateController.php
@@ -78,7 +78,7 @@ class UpdateController extends Controller
*/
public function update(UpdateRequest $request, Budget $budget, BudgetLimit $budgetLimit): JsonResponse
{
- if ((int)$budget->id !== (int)$budgetLimit->budget_id) {
+ if ($budget->id !== $budgetLimit->budget_id) {
throw new FireflyException('20028: The budget limit does not belong to the budget.');
}
$data = $request->getAll();
diff --git a/app/Api/V2/Controllers/Autocomplete/AccountController.php b/app/Api/V2/Controllers/Autocomplete/AccountController.php
index fb99a57861..70cc04e509 100644
--- a/app/Api/V2/Controllers/Autocomplete/AccountController.php
+++ b/app/Api/V2/Controllers/Autocomplete/AccountController.php
@@ -125,8 +125,8 @@ class AccountController extends Controller
$allItems,
static function (array $a, array $b): int {
$order = [AccountType::ASSET, AccountType::REVENUE, AccountType::EXPENSE];
- $pos_a = array_search($a['type'], $order, true);
- $pos_b = array_search($b['type'], $order, true);
+ $pos_a = (int) array_search($a['type'], $order, true);
+ $pos_b = (int) array_search($b['type'], $order, true);
return $pos_a - $pos_b;
}
diff --git a/app/Api/V2/Controllers/Chart/BalanceController.php b/app/Api/V2/Controllers/Chart/BalanceController.php
index b5c929face..e11952ae1c 100644
--- a/app/Api/V2/Controllers/Chart/BalanceController.php
+++ b/app/Api/V2/Controllers/Chart/BalanceController.php
@@ -81,7 +81,7 @@ class BalanceController extends Controller
/** @var TransactionCurrency $default */
$default = app('amount')->getDefaultCurrency();
$converter = new ExchangeRateConverter();
- $currencies = [(int)$default->id => $default,]; // currency cache
+ $currencies = [$default->id => $default,]; // currency cache
$data = [];
$chartData = [];
@@ -94,7 +94,7 @@ class BalanceController extends Controller
$journals = $collector->getExtractedJournals();
// set array for default currency (even if unused later on)
- $defaultCurrencyId = (int)$default->id;
+ $defaultCurrencyId = $default->id;
$data[$defaultCurrencyId] = [
'currency_id' => (string)$defaultCurrencyId,
'currency_symbol' => $default->symbol,
@@ -168,7 +168,7 @@ class BalanceController extends Controller
$amountConverted = bcmul($amount, $rate);
// perhaps transaction already has the foreign amount in the native currency.
- if ((int)$journal['foreign_currency_id'] === (int)$default->id) {
+ if ((int)$journal['foreign_currency_id'] === $default->id) {
$amountConverted = $journal['foreign_amount'] ?? '0';
$amountConverted = 'earned' === $key ? app('steam')->positive($amountConverted) : app('steam')->negative($amountConverted);
}
diff --git a/app/Api/V2/Controllers/Chart/BudgetController.php b/app/Api/V2/Controllers/Chart/BudgetController.php
index eb3ebb8389..23177fa36c 100644
--- a/app/Api/V2/Controllers/Chart/BudgetController.php
+++ b/app/Api/V2/Controllers/Chart/BudgetController.php
@@ -170,9 +170,8 @@ class BudgetController extends Controller
*/
private function noBudgetLimits(Budget $budget, Carbon $start, Carbon $end): array
{
- $budgetId = (int)$budget->id;
$spent = $this->opsRepository->listExpenses($start, $end, null, new Collection([$budget]));
- return $this->processExpenses($budgetId, $spent, $start, $end);
+ return $this->processExpenses($budget->id, $spent, $start, $end);
}
/**
@@ -275,11 +274,10 @@ class BudgetController extends Controller
*/
private function processLimit(Budget $budget, BudgetLimit $limit): array
{
- $budgetId = (int)$budget->id;
$end = clone $limit->end_date;
$end->endOfDay();
$spent = $this->opsRepository->listExpenses($limit->start_date, $end, null, new Collection([$budget]));
- $limitCurrencyId = (int)$limit->transaction_currency_id;
+ $limitCurrencyId = $limit->transaction_currency_id;
$limitCurrency = $limit->transactionCurrency;
$converter = new ExchangeRateConverter();
$filtered = [];
@@ -295,9 +293,9 @@ class BudgetController extends Controller
$filtered[$currencyId] = $entry;
}
}
- $result = $this->processExpenses($budgetId, $filtered, $limit->start_date, $end);
+ $result = $this->processExpenses($budget->id, $filtered, $limit->start_date, $end);
if (1 === count($result)) {
- $compare = bccomp((string)$limit->amount, app('steam')->positive($result[$limitCurrencyId]['spent']));
+ $compare = bccomp($limit->amount, app('steam')->positive($result[$limitCurrencyId]['spent']));
if (1 === $compare) {
// convert this amount into the native currency:
$result[$limitCurrencyId]['left'] = bcadd($limit->amount, $result[$limitCurrencyId]['spent']);
diff --git a/app/Api/V2/Controllers/Chart/CategoryController.php b/app/Api/V2/Controllers/Chart/CategoryController.php
index 421a7b6700..a5eccfcdaa 100644
--- a/app/Api/V2/Controllers/Chart/CategoryController.php
+++ b/app/Api/V2/Controllers/Chart/CategoryController.php
@@ -104,7 +104,7 @@ class CategoryController extends Controller
$amount = app('steam')->positive($journal['amount']);
$nativeAmount = $converter->convert($default, $currency, $journal['date'], $amount);
$key = sprintf('%s-%s', $categoryName, $currency->code);
- if ((int)$journal['foreign_currency_id'] === (int)$default->id) {
+ if ((int)$journal['foreign_currency_id'] === $default->id) {
$nativeAmount = app('steam')->positive($journal['foreign_amount']);
}
// create arrays
diff --git a/app/Api/V2/Controllers/Summary/BasicController.php b/app/Api/V2/Controllers/Summary/BasicController.php
index ef0dd72b43..e6489fc17d 100644
--- a/app/Api/V2/Controllers/Summary/BasicController.php
+++ b/app/Api/V2/Controllers/Summary/BasicController.php
@@ -163,7 +163,7 @@ class BasicController extends Controller
$currency = $currencies[$currencyId] ?? TransactionCurrency::find($currencyId);
$currencies[$currencyId] = $currency;
$nativeAmount = $converter->convert($currency, $default, $transactionJournal['date'], $amount);
- if ((int)$transactionJournal['foreign_currency_id'] === (int)$default->id) {
+ if ((int)$transactionJournal['foreign_currency_id'] === $default->id) {
// use foreign amount instead
$nativeAmount = $transactionJournal['foreign_amount'];
}
@@ -201,7 +201,7 @@ class BasicController extends Controller
$currency = $currencies[$currencyId] ?? $this->currencyRepos->find($currencyId);
$currencies[$currencyId] = $currency;
$nativeAmount = $converter->convert($currency, $default, $transactionJournal['date'], $amount);
- if ((int)$transactionJournal['foreign_currency_id'] === (int)$default->id) {
+ if ((int)$transactionJournal['foreign_currency_id'] === $default->id) {
// use foreign amount instead
$nativeAmount = $transactionJournal['foreign_amount'];
}
@@ -407,7 +407,7 @@ class BasicController extends Controller
$currencies[$currencyId] = $currency;
$amount = app('steam')->negative($journal['amount']);
$amountNative = $converter->convert($default, $currency, $start, $amount);
- if ((int)$journal['foreign_currency_id'] === (int)$default->id) {
+ if ((int)$journal['foreign_currency_id'] === $default->id) {
$amountNative = $journal['foreign_amount'];
}
$spent = bcadd($spent, $amount);
diff --git a/app/Console/Commands/Correction/CorrectAmounts.php b/app/Console/Commands/Correction/CorrectAmounts.php
index e1055e7f2b..147fb0eafd 100644
--- a/app/Console/Commands/Correction/CorrectAmounts.php
+++ b/app/Console/Commands/Correction/CorrectAmounts.php
@@ -88,7 +88,7 @@ class CorrectAmounts extends Command
}
/** @var AutoBudget $item */
foreach ($set as $item) {
- $item->amount = app('steam')->positive((string)$item->amount);
+ $item->amount = app('steam')->positive($item->amount);
$item->save();
}
$this->friendlyInfo(sprintf('Corrected %d auto budget amount(s).', $count));
@@ -108,7 +108,7 @@ class CorrectAmounts extends Command
}
/** @var AvailableBudget $item */
foreach ($set as $item) {
- $item->amount = app('steam')->positive((string)$item->amount);
+ $item->amount = app('steam')->positive($item->amount);
$item->save();
}
$this->friendlyInfo(sprintf('Corrected %d available budget amount(s).', $count));
@@ -128,8 +128,8 @@ class CorrectAmounts extends Command
}
/** @var Bill $item */
foreach ($set as $item) {
- $item->amount_min = app('steam')->positive((string)$item->amount_min);
- $item->amount_max = app('steam')->positive((string)$item->amount_max);
+ $item->amount_min = app('steam')->positive($item->amount_min);
+ $item->amount_max = app('steam')->positive($item->amount_max);
$item->save();
}
$this->friendlyInfo(sprintf('Corrected %d bill amount(s).', $count));
@@ -149,7 +149,7 @@ class CorrectAmounts extends Command
}
/** @var BudgetLimit $item */
foreach ($set as $item) {
- $item->amount = app('steam')->positive((string)$item->amount);
+ $item->amount = app('steam')->positive($item->amount);
$item->save();
}
$this->friendlyInfo(sprintf('Corrected %d budget limit amount(s).', $count));
@@ -169,7 +169,7 @@ class CorrectAmounts extends Command
}
/** @var CurrencyExchangeRate $item */
foreach ($set as $item) {
- $item->rate = app('steam')->positive((string)$item->rate);
+ $item->rate = app('steam')->positive($item->rate);
$item->save();
}
$this->friendlyInfo(sprintf('Corrected %d currency exchange rate(s).', $count));
@@ -189,7 +189,7 @@ class CorrectAmounts extends Command
}
/** @var PiggyBankRepetition $item */
foreach ($set as $item) {
- $item->currentamount = app('steam')->positive((string)$item->currentamount);
+ $item->currentamount = app('steam')->positive($item->currentamount);
$item->save();
}
$this->friendlyInfo(sprintf('Corrected %d piggy bank repetition amount(s).', $count));
@@ -209,7 +209,7 @@ class CorrectAmounts extends Command
}
/** @var PiggyBank $item */
foreach ($set as $item) {
- $item->targetamount = app('steam')->positive((string)$item->targetamount);
+ $item->targetamount = app('steam')->positive($item->targetamount);
$item->save();
}
$this->friendlyInfo(sprintf('Corrected %d piggy bank amount(s).', $count));
@@ -231,8 +231,8 @@ class CorrectAmounts extends Command
}
/** @var RecurrenceTransaction $item */
foreach ($set as $item) {
- $item->amount = app('steam')->positive((string)$item->amount);
- $item->foreign_amount = app('steam')->positive((string)$item->foreign_amount);
+ $item->amount = app('steam')->positive($item->amount);
+ $item->foreign_amount = app('steam')->positive($item->foreign_amount);
$item->save();
}
$this->friendlyInfo(sprintf('Corrected %d recurring transaction amount(s).', $count));
@@ -259,7 +259,7 @@ class CorrectAmounts extends Command
}
if (-1 === $check) {
$fixed++;
- $item->trigger_value = app('steam')->positive((string)$item->trigger_value);
+ $item->trigger_value = app('steam')->positive($item->trigger_value);
$item->save();
}
}
diff --git a/app/Console/Commands/Correction/CorrectOpeningBalanceCurrencies.php b/app/Console/Commands/Correction/CorrectOpeningBalanceCurrencies.php
index 67feb9bdbe..5a6ac44727 100644
--- a/app/Console/Commands/Correction/CorrectOpeningBalanceCurrencies.php
+++ b/app/Console/Commands/Correction/CorrectOpeningBalanceCurrencies.php
@@ -133,7 +133,7 @@ class CorrectOpeningBalanceCurrencies extends Command
{
$currency = $this->getCurrency($account);
$count = 0;
- if ((int)$journal->transaction_currency_id !== (int)$currency->id) {
+ if ((int)$journal->transaction_currency_id !== $currency->id) {
$journal->transaction_currency_id = $currency->id;
$journal->save();
$count = 1;
@@ -141,7 +141,7 @@ class CorrectOpeningBalanceCurrencies extends Command
/** @var Transaction $transaction */
foreach ($journal->transactions as $transaction) {
- if ((int)$transaction->transaction_currency_id !== (int)$currency->id) {
+ if ($transaction->transaction_currency_id !== $currency->id) {
$transaction->transaction_currency_id = $currency->id;
$transaction->save();
$count = 1;
diff --git a/app/Console/Commands/Correction/DeleteEmptyJournals.php b/app/Console/Commands/Correction/DeleteEmptyJournals.php
index 8952ed423e..e340250d4c 100644
--- a/app/Console/Commands/Correction/DeleteEmptyJournals.php
+++ b/app/Console/Commands/Correction/DeleteEmptyJournals.php
@@ -69,14 +69,14 @@ class DeleteEmptyJournals extends Command
if (1 === $count % 2) {
// uneven number, delete journal and transactions:
try {
- TransactionJournal::find((int)$row->transaction_journal_id)->delete();
+ TransactionJournal::find($row->transaction_journal_id)->delete();
} catch (QueryException $e) {
app('log')->info(sprintf('Could not delete journal: %s', $e->getMessage()));
app('log')->error($e->getTraceAsString());
}
- Transaction::where('transaction_journal_id', (int)$row->transaction_journal_id)->delete();
+ Transaction::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/DeleteOrphanedTransactions.php b/app/Console/Commands/Correction/DeleteOrphanedTransactions.php
index 712aeaebb0..bc26535586 100644
--- a/app/Console/Commands/Correction/DeleteOrphanedTransactions.php
+++ b/app/Console/Commands/Correction/DeleteOrphanedTransactions.php
@@ -72,7 +72,7 @@ class DeleteOrphanedTransactions extends Command
}
$this->friendlyInfo(sprintf('Found %d orphaned journal(s).', $count));
foreach ($set as $entry) {
- $journal = TransactionJournal::withTrashed()->find((int)$entry->id);
+ $journal = TransactionJournal::withTrashed()->find($entry->id);
if (null !== $journal) {
$journal->delete();
$this->friendlyWarning(
@@ -135,11 +135,11 @@ class DeleteOrphanedTransactions extends Command
/** @var Transaction $transaction */
foreach ($set as $transaction) {
// delete journals
- $journal = TransactionJournal::find((int)$transaction->transaction_journal_id);
+ $journal = TransactionJournal::find($transaction->transaction_journal_id);
if (null !== $journal) {
$journal->delete();
}
- Transaction::where('transaction_journal_id', (int)$transaction->transaction_journal_id)->delete();
+ Transaction::where('transaction_journal_id', $transaction->transaction_journal_id)->delete();
$this->friendlyWarning(
sprintf(
'Deleted transaction journal #%d because account #%d was already deleted.',
diff --git a/app/Console/Commands/Correction/EnableCurrencies.php b/app/Console/Commands/Correction/EnableCurrencies.php
index f337603954..e1844b49be 100644
--- a/app/Console/Commands/Correction/EnableCurrencies.php
+++ b/app/Console/Commands/Correction/EnableCurrencies.php
@@ -73,7 +73,7 @@ class EnableCurrencies extends Command
// get all from budget limits
$limits = BudgetLimit::groupBy('transaction_currency_id')->get(['transaction_currency_id']);
foreach ($limits as $entry) {
- $found[] = (int)$entry->transaction_currency_id;
+ $found[] = $entry->transaction_currency_id;
}
$found = array_values(array_unique($found));
diff --git a/app/Console/Commands/Correction/FixAccountTypes.php b/app/Console/Commands/Correction/FixAccountTypes.php
index 501ea2202b..b7bb806317 100644
--- a/app/Console/Commands/Correction/FixAccountTypes.php
+++ b/app/Console/Commands/Correction/FixAccountTypes.php
@@ -114,7 +114,7 @@ class FixAccountTypes extends Command
$this->friendlyLine(sprintf('Found %d journals that need to be fixed.', $resultSet->count()));
foreach ($resultSet as $entry) {
app('log')->debug(sprintf('Now fixing journal #%d', $entry->id));
- $journal = TransactionJournal::find((int)$entry->id);
+ $journal = TransactionJournal::find($entry->id);
if (null !== $journal) {
$this->inspectJournal($journal);
}
diff --git a/app/Console/Commands/Correction/FixIbans.php b/app/Console/Commands/Correction/FixIbans.php
index 7afbd3c2cf..15ed2805a9 100644
--- a/app/Console/Commands/Correction/FixIbans.php
+++ b/app/Console/Commands/Correction/FixIbans.php
@@ -90,7 +90,7 @@ class FixIbans extends Command
$set = [];
/** @var Account $account */
foreach ($accounts as $account) {
- $userId = (int)$account->user_id;
+ $userId = $account->user_id;
$set[$userId] = $set[$userId] ?? [];
$iban = (string)$account->iban;
if ('' === $iban) {
diff --git a/app/Console/Commands/Correction/FixUnevenAmount.php b/app/Console/Commands/Correction/FixUnevenAmount.php
index 62b95de6dd..10303cd06a 100644
--- a/app/Console/Commands/Correction/FixUnevenAmount.php
+++ b/app/Console/Commands/Correction/FixUnevenAmount.php
@@ -77,7 +77,7 @@ class FixUnevenAmount extends Command
);
$this->friendlyWarning($message);
app('log')->warning($message);
- $this->fixJournal((int)$entry->transaction_journal_id);
+ $this->fixJournal($entry->transaction_journal_id);
$count++;
}
}
@@ -115,7 +115,7 @@ class FixUnevenAmount extends Command
return;
}
- $amount = bcmul('-1', (string)$source->amount);
+ $amount = bcmul('-1', $source->amount);
// fix amount of destination:
/** @var Transaction|null $destination */
diff --git a/app/Console/Commands/System/ForceDecimalSize.php b/app/Console/Commands/System/ForceDecimalSize.php
index 09d48e7965..3b03731de9 100644
--- a/app/Console/Commands/System/ForceDecimalSize.php
+++ b/app/Console/Commands/System/ForceDecimalSize.php
@@ -501,7 +501,7 @@ class ForceDecimalSize extends Command
/** @var Transaction $item */
foreach ($result as $item) {
- $value = (string)$item->amount;
+ $value = $item->amount;
if ('' === $value) {
continue;
}
diff --git a/app/Console/Commands/Upgrade/BackToJournals.php b/app/Console/Commands/Upgrade/BackToJournals.php
index 6daa7fbb93..ba2e4233d6 100644
--- a/app/Console/Commands/Upgrade/BackToJournals.php
+++ b/app/Console/Commands/Upgrade/BackToJournals.php
@@ -169,7 +169,7 @@ class BackToJournals extends Command
// both have a budget, but they don't match.
if (null !== $budget && null !== $journalBudget && $budget->id !== $journalBudget->id) {
// sync to journal:
- $journal->budgets()->sync([(int)$budget->id]);
+ $journal->budgets()->sync([$budget->id]);
return;
}
@@ -177,7 +177,7 @@ class BackToJournals extends Command
// transaction has a budget, but the journal doesn't.
if (null !== $budget && null === $journalBudget) {
// sync to journal:
- $journal->budgets()->sync([(int)$budget->id]);
+ $journal->budgets()->sync([$budget->id]);
}
}
@@ -241,12 +241,12 @@ class BackToJournals extends Command
// both have a category, but they don't match.
if (null !== $category && null !== $journalCategory && $category->id !== $journalCategory->id) {
// sync to journal:
- $journal->categories()->sync([(int)$category->id]);
+ $journal->categories()->sync([$category->id]);
}
// transaction has a category, but the journal doesn't.
if (null !== $category && null === $journalCategory) {
- $journal->categories()->sync([(int)$category->id]);
+ $journal->categories()->sync([$category->id]);
}
}
diff --git a/app/Console/Commands/Upgrade/MigrateRecurrenceType.php b/app/Console/Commands/Upgrade/MigrateRecurrenceType.php
index 9681cde806..aa1e2c7c89 100644
--- a/app/Console/Commands/Upgrade/MigrateRecurrenceType.php
+++ b/app/Console/Commands/Upgrade/MigrateRecurrenceType.php
@@ -99,7 +99,7 @@ class MigrateRecurrenceType extends Command
*/
private function migrateRecurrence(Recurrence $recurrence): void
{
- $originalType = (int)$recurrence->transaction_type_id;
+ $originalType = $recurrence->transaction_type_id;
$newType = $this->getInvalidType();
$recurrence->transaction_type_id = $newType->id;
$recurrence->save();
diff --git a/app/Console/Commands/Upgrade/MigrateToGroups.php b/app/Console/Commands/Upgrade/MigrateToGroups.php
index 098e499f76..b85f906fb5 100644
--- a/app/Console/Commands/Upgrade/MigrateToGroups.php
+++ b/app/Console/Commands/Upgrade/MigrateToGroups.php
@@ -335,7 +335,7 @@ class MigrateToGroups extends Command
if (null !== $budget) {
app('log')->debug(sprintf('Return budget #%d, from transaction #%d', $budget->id, $left->id));
- return (int)$budget->id;
+ return $budget->id;
}
// try to get a budget ID from the right transaction:
@@ -344,7 +344,7 @@ class MigrateToGroups extends Command
if (null !== $budget) {
app('log')->debug(sprintf('Return budget #%d, from transaction #%d', $budget->id, $right->id));
- return (int)$budget->id;
+ return $budget->id;
}
app('log')->debug('Neither left or right have a budget, return NULL');
@@ -368,7 +368,7 @@ class MigrateToGroups extends Command
if (null !== $category) {
app('log')->debug(sprintf('Return category #%d, from transaction #%d', $category->id, $left->id));
- return (int)$category->id;
+ return $category->id;
}
// try to get a category ID from the left transaction:
@@ -377,7 +377,7 @@ class MigrateToGroups extends Command
if (null !== $category) {
app('log')->debug(sprintf('Return category #%d, from transaction #%d', $category->id, $category->id));
- return (int)$category->id;
+ return $category->id;
}
app('log')->debug('Neither left or right have a category, return NULL');
diff --git a/app/Console/Commands/Upgrade/OtherCurrenciesCorrections.php b/app/Console/Commands/Upgrade/OtherCurrenciesCorrections.php
index 845dd0eda8..76675be766 100644
--- a/app/Console/Commands/Upgrade/OtherCurrenciesCorrections.php
+++ b/app/Console/Commands/Upgrade/OtherCurrenciesCorrections.php
@@ -169,8 +169,8 @@ class OtherCurrenciesCorrections extends Command
}
// when mismatch in transaction:
- if ((int)$transaction->transaction_currency_id !== (int)$currency->id) {
- $transaction->foreign_currency_id = (int)$transaction->transaction_currency_id;
+ if ($transaction->transaction_currency_id !== $currency->id) {
+ $transaction->foreign_currency_id = $transaction->transaction_currency_id;
$transaction->foreign_amount = $transaction->amount;
$transaction->transaction_currency_id = $currency->id;
$transaction->save();
diff --git a/app/Console/Commands/Upgrade/TransactionIdentifier.php b/app/Console/Commands/Upgrade/TransactionIdentifier.php
index 2b8648dfb1..d7bf411eaa 100644
--- a/app/Console/Commands/Upgrade/TransactionIdentifier.php
+++ b/app/Console/Commands/Upgrade/TransactionIdentifier.php
@@ -161,7 +161,7 @@ class TransactionIdentifier extends Command
private function findOpposing(Transaction $transaction, array $exclude): ?Transaction
{
// find opposing:
- $amount = bcmul((string)$transaction->amount, '-1');
+ $amount = bcmul($transaction->amount, '-1');
try {
/** @var Transaction $opposing */
diff --git a/app/Console/Commands/Upgrade/TransferCurrenciesCorrections.php b/app/Console/Commands/Upgrade/TransferCurrenciesCorrections.php
index f46d396595..fd7f84b4f3 100644
--- a/app/Console/Commands/Upgrade/TransferCurrenciesCorrections.php
+++ b/app/Console/Commands/Upgrade/TransferCurrenciesCorrections.php
@@ -349,7 +349,7 @@ class TransferCurrenciesCorrections extends Command
if (null === $this->sourceTransaction->transaction_currency_id && null !== $this->sourceCurrency) {
$this->sourceTransaction
->transaction_currency_id
- = (int)$this->sourceCurrency->id;
+ = $this->sourceCurrency->id;
$message = sprintf(
'Transaction #%d has no currency setting, now set to %s.',
$this->sourceTransaction->id,
@@ -369,7 +369,7 @@ class TransferCurrenciesCorrections extends Command
{
if (null !== $this->sourceCurrency
&& null === $this->sourceTransaction->foreign_amount
- && (int)$this->sourceTransaction->transaction_currency_id !== (int)$this->sourceCurrency->id
+ && (int)$this->sourceTransaction->transaction_currency_id !== $this->sourceCurrency->id
) {
$message = sprintf(
'Transaction #%d has a currency setting #%d that should be #%d. Amount remains %s, currency is changed.',
@@ -380,7 +380,7 @@ class TransferCurrenciesCorrections extends Command
);
$this->friendlyWarning($message);
$this->count++;
- $this->sourceTransaction->transaction_currency_id = (int)$this->sourceCurrency->id;
+ $this->sourceTransaction->transaction_currency_id = $this->sourceCurrency->id;
$this->sourceTransaction->save();
}
}
@@ -394,7 +394,7 @@ class TransferCurrenciesCorrections extends Command
if (null === $this->destinationTransaction->transaction_currency_id && null !== $this->destinationCurrency) {
$this->destinationTransaction
->transaction_currency_id
- = (int)$this->destinationCurrency->id;
+ = $this->destinationCurrency->id;
$message = sprintf(
'Transaction #%d has no currency setting, now set to %s.',
$this->destinationTransaction->id,
@@ -414,7 +414,7 @@ class TransferCurrenciesCorrections extends Command
{
if (null !== $this->destinationCurrency
&& null === $this->destinationTransaction->foreign_amount
- && (int)$this->destinationTransaction->transaction_currency_id !== (int)$this->destinationCurrency->id
+ && (int)$this->destinationTransaction->transaction_currency_id !== $this->destinationCurrency->id
) {
$message = sprintf(
'Transaction #%d has a currency setting #%d that should be #%d. Amount remains %s, currency is changed.',
@@ -425,7 +425,7 @@ class TransferCurrenciesCorrections extends Command
);
$this->friendlyWarning($message);
$this->count++;
- $this->destinationTransaction->transaction_currency_id = (int)$this->destinationCurrency->id;
+ $this->destinationTransaction->transaction_currency_id = $this->destinationCurrency->id;
$this->destinationTransaction->save();
}
}
@@ -437,7 +437,7 @@ class TransferCurrenciesCorrections extends Command
*/
private function fixInvalidForeignCurrency(): void
{
- if ((int)$this->destinationCurrency->id === (int)$this->sourceCurrency->id) {
+ if ($this->destinationCurrency->id === $this->sourceCurrency->id) {
// update both transactions to match:
$this->sourceTransaction->foreign_amount = null;
$this->sourceTransaction->foreign_currency_id = null;
@@ -457,7 +457,7 @@ class TransferCurrenciesCorrections extends Command
*/
private function fixMismatchedForeignCurrency(): void
{
- if ((int)$this->sourceCurrency->id !== (int)$this->destinationCurrency->id) {
+ if ($this->sourceCurrency->id !== $this->destinationCurrency->id) {
$this->sourceTransaction->transaction_currency_id = $this->sourceCurrency->id;
$this->sourceTransaction->foreign_currency_id = $this->destinationCurrency->id;
$this->destinationTransaction->transaction_currency_id = $this->sourceCurrency->id;
@@ -479,7 +479,7 @@ class TransferCurrenciesCorrections extends Command
private function fixSourceNullForeignAmount(): void
{
if (null === $this->sourceTransaction->foreign_amount && null !== $this->destinationTransaction->foreign_amount) {
- $this->sourceTransaction->foreign_amount = bcmul((string)$this->destinationTransaction->foreign_amount, '-1');
+ $this->sourceTransaction->foreign_amount = bcmul($this->destinationTransaction->foreign_amount, '-1');
$this->sourceTransaction->save();
$this->count++;
$this->friendlyInfo(
@@ -499,7 +499,7 @@ class TransferCurrenciesCorrections extends Command
private function fixDestNullForeignAmount(): void
{
if (null === $this->destinationTransaction->foreign_amount && null !== $this->sourceTransaction->foreign_amount) {
- $this->destinationTransaction->foreign_amount = bcmul((string)$this->sourceTransaction->foreign_amount, '-1');
+ $this->destinationTransaction->foreign_amount = bcmul($this->sourceTransaction->foreign_amount, '-1');
$this->destinationTransaction->save();
$this->count++;
$this->friendlyInfo(
@@ -519,7 +519,7 @@ class TransferCurrenciesCorrections extends Command
*/
private function fixTransactionJournalCurrency(TransactionJournal $journal): void
{
- if ((int)$journal->transaction_currency_id !== (int)$this->sourceCurrency->id) {
+ if ((int)$journal->transaction_currency_id !== $this->sourceCurrency->id) {
$oldCurrencyCode = $journal->transactionCurrency->code ?? '(nothing)';
$journal->transaction_currency_id = $this->sourceCurrency->id;
$message = sprintf(
diff --git a/app/Console/Commands/Upgrade/UpgradeLiabilities.php b/app/Console/Commands/Upgrade/UpgradeLiabilities.php
index 3723b2858d..c2102638fc 100644
--- a/app/Console/Commands/Upgrade/UpgradeLiabilities.php
+++ b/app/Console/Commands/Upgrade/UpgradeLiabilities.php
@@ -149,9 +149,9 @@ class UpgradeLiabilities extends Command
return;
}
// source MUST be the liability.
- if ((int)$destination->account_id === (int)$account->id) {
+ if ($destination->account_id === $account->id) {
// so if not, switch things around:
- $sourceAccountId = (int)$source->account_id;
+ $sourceAccountId = $source->account_id;
$source->account_id = $destination->account_id;
$destination->account_id = $sourceAccountId;
$source->save();
diff --git a/app/Console/Commands/Upgrade/UpgradeLiabilitiesEight.php b/app/Console/Commands/Upgrade/UpgradeLiabilitiesEight.php
index bd75d43ca9..487e5fa770 100644
--- a/app/Console/Commands/Upgrade/UpgradeLiabilitiesEight.php
+++ b/app/Console/Commands/Upgrade/UpgradeLiabilitiesEight.php
@@ -238,10 +238,10 @@ class UpgradeLiabilitiesEight extends Command
// if source is this liability and destination is expense, remove transaction.
// if source is revenue and destination is liability, remove transaction.
- if ((int)$source->account_id === (int)$account->id && $dest->account->accountType->type === AccountType::EXPENSE) {
+ if ($source->account_id === $account->id && $dest->account->accountType->type === AccountType::EXPENSE) {
$delete = true;
}
- if ((int)$dest->account_id === (int)$account->id && $source->account->accountType->type === AccountType::REVENUE) {
+ if ($dest->account_id === $account->id && $source->account->accountType->type === AccountType::REVENUE) {
$delete = true;
}
diff --git a/app/Exceptions/GracefulNotFoundHandler.php b/app/Exceptions/GracefulNotFoundHandler.php
index ccde64a847..3261c54b95 100644
--- a/app/Exceptions/GracefulNotFoundHandler.php
+++ b/app/Exceptions/GracefulNotFoundHandler.php
@@ -144,7 +144,7 @@ class GracefulNotFoundHandler extends ExceptionHandler
$route = $request->route();
$param = $route->parameter('account');
if ($param instanceof Account) {
- $accountId = (int)$param->id;
+ $accountId = $param->id;
}
if (!($param instanceof Account)) {
$accountId = (int)$param;
diff --git a/app/Exceptions/IntervalException.php b/app/Exceptions/IntervalException.php
index 04d9a5f918..337b7cb79a 100644
--- a/app/Exceptions/IntervalException.php
+++ b/app/Exceptions/IntervalException.php
@@ -36,6 +36,7 @@ final class IntervalException extends Exception
{
public array $availableIntervals;
public Periodicity $periodicity;
+ /** @var mixed */
protected $message = 'The periodicity %s is unknown. Choose one of available periodicity: %s';
public function __construct(string $message = '', int $code = 0, ?Throwable $previous = null)
diff --git a/app/Handlers/Events/Model/BudgetLimitHandler.php b/app/Handlers/Events/Model/BudgetLimitHandler.php
index 4ae09e1ed2..06bdc69a80 100644
--- a/app/Handlers/Events/Model/BudgetLimitHandler.php
+++ b/app/Handlers/Events/Model/BudgetLimitHandler.php
@@ -125,7 +125,7 @@ class BudgetLimitHandler
// no need to calculate if period is equal.
if ($currentPeriod->equals($limitPeriod)) {
- $amount = 0 === (int)$budgetLimit->id ? '0' : $budgetLimit->amount;
+ $amount = 0 === $budgetLimit->id ? '0' : $budgetLimit->amount;
}
if (0 === bccomp($amount, '0')) {
app('log')->debug('Amount is zero, will not create AB.');
@@ -227,7 +227,7 @@ class BudgetLimitHandler
*/
private function getDailyAmount(BudgetLimit $budgetLimit): string
{
- if (0 === (int)$budgetLimit->id) {
+ if (0 === $budgetLimit->id) {
return '0';
}
$limitPeriod = Period::make(
@@ -237,7 +237,7 @@ class BudgetLimitHandler
boundaries: Boundaries::EXCLUDE_NONE()
);
$days = $limitPeriod->length();
- $amount = bcdiv((string)$budgetLimit->amount, (string)$days, 12);
+ $amount = bcdiv($budgetLimit->amount, (string)$days, 12);
app('log')->debug(
sprintf('Total amount for budget limit #%d is %s. Nr. of days is %d. Amount per day is %s', $budgetLimit->id, $budgetLimit->amount, $days, $amount)
);
diff --git a/app/Helpers/Attachments/AttachmentHelper.php b/app/Helpers/Attachments/AttachmentHelper.php
index 7167e21c1f..b2ea13bd3a 100644
--- a/app/Helpers/Attachments/AttachmentHelper.php
+++ b/app/Helpers/Attachments/AttachmentHelper.php
@@ -95,7 +95,7 @@ class AttachmentHelper implements AttachmentHelperInterface
*/
public function getAttachmentLocation(Attachment $attachment): string
{
- return sprintf('%sat-%d.data', \DIRECTORY_SEPARATOR, (int)$attachment->id);
+ return sprintf('%sat-%d.data', \DIRECTORY_SEPARATOR, $attachment->id);
}
/**
diff --git a/app/Helpers/Collector/GroupCollector.php b/app/Helpers/Collector/GroupCollector.php
index 7fc6570316..c862a62e4e 100644
--- a/app/Helpers/Collector/GroupCollector.php
+++ b/app/Helpers/Collector/GroupCollector.php
@@ -563,8 +563,8 @@ class GroupCollector implements GroupCollectorInterface
$parsedGroup = $this->parseAugmentedJournal($augumentedJournal);
$groupArray = [
'id' => (int)$augumentedJournal->transaction_group_id,
- 'user_id' => (int)$augumentedJournal->user_id,
- 'user_group_id' => (int)$augumentedJournal->user_group_id,
+ 'user_id' => $augumentedJournal->user_id,
+ 'user_group_id' => $augumentedJournal->user_group_id,
// Field transaction_group_title was added by the query.
'title' => $augumentedJournal->transaction_group_title, // @phpstan-ignore-line
'transaction_type' => $parsedGroup['transaction_type_type'],
diff --git a/app/Helpers/Report/NetWorth.php b/app/Helpers/Report/NetWorth.php
index eb56b0df28..fba187e7cd 100644
--- a/app/Helpers/Report/NetWorth.php
+++ b/app/Helpers/Report/NetWorth.php
@@ -85,12 +85,12 @@ class NetWorth implements NetWorthInterface
'native' => [
'balance' => '0',
'native_balance' => '0',
- 'currency_id' => (int)$default->id,
+ 'currency_id' => $default->id,
'currency_code' => $default->code,
'currency_name' => $default->name,
'currency_symbol' => $default->symbol,
'currency_decimal_places' => (int)$default->decimal_places,
- 'native_id' => (int)$default->id,
+ 'native_id' => $default->id,
'native_code' => $default->code,
'native_name' => $default->name,
'native_symbol' => $default->symbol,
@@ -103,16 +103,16 @@ class NetWorth implements NetWorthInterface
foreach ($accounts as $account) {
app('log')->debug(sprintf('Now at account #%d ("%s")', $account->id, $account->name));
$currency = $this->getRepository()->getAccountCurrency($account);
- $currencyId = (int)$currency->id;
+ $currencyId = $currency->id;
$balance = '0';
$nativeBalance = '0';
- if (array_key_exists((int)$account->id, $balances)) {
- $balance = $balances[(int)$account->id]['balance'] ?? '0';
- $nativeBalance = $balances[(int)$account->id]['native_balance'] ?? '0';
+ if (array_key_exists($account->id, $balances)) {
+ $balance = $balances[$account->id]['balance'] ?? '0';
+ $nativeBalance = $balances[$account->id]['native_balance'] ?? '0';
}
app('log')->debug(sprintf('Balance is %s, native balance is %s', $balance, $nativeBalance));
// always subtract virtual balance
- $virtualBalance = (string)$account->virtual_balance;
+ $virtualBalance = $account->virtual_balance;
if ('' !== $virtualBalance) {
$balance = bcsub($balance, $virtualBalance);
$nativeVirtualBalance = $converter->convert($default, $currency, $account->created_at, $virtualBalance);
@@ -126,7 +126,7 @@ class NetWorth implements NetWorthInterface
'currency_name' => $currency->name,
'currency_symbol' => $currency->symbol,
'currency_decimal_places' => (int)$currency->decimal_places,
- 'native_id' => (int)$default->id,
+ 'native_id' => $default->id,
'native_code' => $default->code,
'native_name' => $default->name,
'native_symbol' => $default->symbol,
@@ -200,7 +200,7 @@ class NetWorth implements NetWorthInterface
$balance = $balances[$account->id] ?? '0';
// always subtract virtual balance.
- $virtualBalance = (string)$account->virtual_balance;
+ $virtualBalance = $account->virtual_balance;
if ('' !== $virtualBalance) {
$balance = bcsub($balance, $virtualBalance);
}
diff --git a/app/Http/Controllers/Chart/BillController.php b/app/Http/Controllers/Chart/BillController.php
index 6397554f0d..7ee1e0221b 100644
--- a/app/Http/Controllers/Chart/BillController.php
+++ b/app/Http/Controllers/Chart/BillController.php
@@ -164,7 +164,7 @@ class BillController extends Controller
'entries' => [],
],
];
- $currencyId = (int)$bill->transaction_currency_id;
+ $currencyId = $bill->transaction_currency_id;
foreach ($journals as $journal) {
$date = $journal['date']->isoFormat((string)trans('config.month_and_day_js', [], $locale));
$chartData[0]['entries'][$date] = $bill->amount_min; // minimum amount of bill
diff --git a/app/Http/Controllers/Chart/BudgetController.php b/app/Http/Controllers/Chart/BudgetController.php
index 237357cc3c..333a1a95ad 100644
--- a/app/Http/Controllers/Chart/BudgetController.php
+++ b/app/Http/Controllers/Chart/BudgetController.php
@@ -181,7 +181,7 @@ class BudgetController extends Controller
while ($start <= $end) {
$current = clone $start;
$expenses = $this->opsRepository->sumExpenses($current, $current, null, $budgetCollection, $currency);
- $spent = $expenses[(int)$currency->id]['sum'] ?? '0';
+ $spent = $expenses[$currency->id]['sum'] ?? '0';
$amount = bcadd($amount, $spent);
$format = $start->isoFormat((string)trans('config.month_and_day_js', [], $locale));
$entries[$format] = $amount;
diff --git a/app/Http/Controllers/Chart/CategoryController.php b/app/Http/Controllers/Chart/CategoryController.php
index 0cc7060e33..68df80f961 100644
--- a/app/Http/Controllers/Chart/CategoryController.php
+++ b/app/Http/Controllers/Chart/CategoryController.php
@@ -193,7 +193,7 @@ class CategoryController extends Controller
if (null !== $category) {
/** @var OperationsRepositoryInterface $opsRepository */
$opsRepository = app(OperationsRepositoryInterface::class);
- $categoryId = (int)$category->id;
+ $categoryId = $category->id;
// this gives us all currencies
$collection = new Collection([$category]);
$expenses = $opsRepository->listExpenses($start, $end, null, $collection);
diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php
index 106336bc90..8dc9a621fc 100644
--- a/app/Http/Controllers/HomeController.php
+++ b/app/Http/Controllers/HomeController.php
@@ -31,6 +31,7 @@ use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Helpers\Collector\GroupCollectorInterface;
use FireflyIII\Http\Middleware\Installer;
use FireflyIII\Models\AccountType;
+use FireflyIII\Models\TransactionJournal;
use FireflyIII\Repositories\Account\AccountRepositoryInterface;
use FireflyIII\Repositories\Bill\BillRepositoryInterface;
use FireflyIII\User;
diff --git a/app/Http/Controllers/Json/BoxController.php b/app/Http/Controllers/Json/BoxController.php
index e915cf7f63..90ef9536e3 100644
--- a/app/Http/Controllers/Json/BoxController.php
+++ b/app/Http/Controllers/Json/BoxController.php
@@ -102,7 +102,7 @@ class BoxController extends Controller
// spent in this period, in budgets, for default currency.
// also calculate spent per day.
$spent = $opsRepository->sumExpenses($start, $end, null, null, $currency);
- $spentAmount = $spent[(int)$currency->id]['sum'] ?? '0';
+ $spentAmount = $spent[$currency->id]['sum'] ?? '0';
app('log')->debug(sprintf('Spent for default currency for all budgets in this period: %s', $spentAmount));
$days = $today->between($start, $end) ? $today->diffInDays($start) + 1 : $end->diffInDays($start) + 1;
diff --git a/app/Http/Controllers/Transaction/MassController.php b/app/Http/Controllers/Transaction/MassController.php
index 1268159611..30411a6521 100644
--- a/app/Http/Controllers/Transaction/MassController.php
+++ b/app/Http/Controllers/Transaction/MassController.php
@@ -108,7 +108,7 @@ class MassController extends Controller
app('log')->debug(sprintf('Searching for ID #%d', $journalId));
/** @var TransactionJournal|null $journal */
$journal = $this->repository->find((int)$journalId);
- if (null !== $journal && (int)$journalId === (int)$journal->id) {
+ if (null !== $journal && (int)$journalId === $journal->id) {
$this->repository->destroyJournal($journal);
++$count;
app('log')->debug(sprintf('Deleted transaction journal #%d', $journalId));
diff --git a/app/Jobs/CreateAutoBudgetLimits.php b/app/Jobs/CreateAutoBudgetLimits.php
index 70f5d09009..ca62f4d3d2 100644
--- a/app/Jobs/CreateAutoBudgetLimits.php
+++ b/app/Jobs/CreateAutoBudgetLimits.php
@@ -288,7 +288,7 @@ class CreateAutoBudgetLimits implements ShouldQueue
$repository = app(OperationsRepositoryInterface::class);
$repository->setUser($autoBudget->budget->user);
$spent = $repository->sumExpenses($previousStart, $previousEnd, null, new Collection([$autoBudget->budget]), $autoBudget->transactionCurrency);
- $currencyId = (int)$autoBudget->transaction_currency_id;
+ $currencyId = $autoBudget->transaction_currency_id;
$spentAmount = $spent[$currencyId]['sum'] ?? '0';
app('log')->debug(sprintf('Spent in previous budget period (%s-%s) is %s', $previousStart->format('Y-m-d'), $previousEnd->format('Y-m-d'), $spentAmount));
@@ -352,7 +352,7 @@ class CreateAutoBudgetLimits implements ShouldQueue
$repository = app(OperationsRepositoryInterface::class);
$repository->setUser($autoBudget->budget->user);
$spent = $repository->sumExpenses($previousStart, $previousEnd, null, new Collection([$autoBudget->budget]), $autoBudget->transactionCurrency);
- $currencyId = (int)$autoBudget->transaction_currency_id;
+ $currencyId = $autoBudget->transaction_currency_id;
$spentAmount = $spent[$currencyId]['sum'] ?? '0';
app('log')->debug(sprintf('Spent in previous budget period (%s-%s) is %s', $previousStart->format('Y-m-d'), $previousEnd->format('Y-m-d'), $spentAmount));
diff --git a/app/Jobs/CreateRecurringTransactions.php b/app/Jobs/CreateRecurringTransactions.php
index 9f15139cdb..f9852517a7 100644
--- a/app/Jobs/CreateRecurringTransactions.php
+++ b/app/Jobs/CreateRecurringTransactions.php
@@ -468,7 +468,7 @@ class CreateRecurringTransactions implements ShouldQueue
'type' => null === $first->transactionType ? strtolower($recurrence->transactionType->type) : strtolower($first->transactionType->type),
'date' => $date,
'user' => $recurrence->user_id,
- 'currency_id' => (int)$transaction->transaction_currency_id,
+ 'currency_id' => $transaction->transaction_currency_id,
'currency_code' => null,
'description' => $first->description,
'amount' => $transaction->amount,
@@ -485,7 +485,7 @@ class CreateRecurringTransactions implements ShouldQueue
'foreign_amount' => $transaction->foreign_amount,
'reconciled' => false,
'identifier' => $index,
- 'recurrence_id' => (int)$recurrence->id,
+ 'recurrence_id' => $recurrence->id,
'order' => $index,
'notes' => (string)trans('firefly.created_from_recurrence', ['id' => $recurrence->id, 'title' => $recurrence->title]),
'tags' => $this->repository->getTags($transaction),
diff --git a/app/Models/Account.php b/app/Models/Account.php
index 4d0606c990..d136973849 100644
--- a/app/Models/Account.php
+++ b/app/Models/Account.php
@@ -25,6 +25,8 @@ namespace FireflyIII\Models;
use Carbon\Carbon;
use Eloquent;
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
+use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Database\Eloquent\Casts\Attribute;
@@ -42,36 +44,36 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* Class Account
*
- * @property int|string $id
- * @property Carbon|null $created_at
- * @property Carbon|null $updated_at
- * @property Carbon|null $deleted_at
- * @property int|string $user_id
- * @property int|string $account_type_id
- * @property string $name
- * @property string|float|null $virtual_balance
- * @property string|null $iban
- * @property bool $active
- * @property bool $encrypted
- * @property int|string $order
- * @property-read Collection|AccountMeta[] $accountMeta
- * @property-read int|null $account_meta_count
- * @property AccountType $accountType
- * @property-read Collection|Attachment[] $attachments
- * @property-read int|null $attachments_count
- * @property-read string $account_number
- * @property-read string $edit_name
- * @property-read Collection|Location[] $locations
- * @property-read int|null $locations_count
- * @property-read Collection|Note[] $notes
- * @property-read int|null $notes_count
- * @property-read Collection|ObjectGroup[] $objectGroups
- * @property-read int|null $object_groups_count
- * @property-read Collection|PiggyBank[] $piggyBanks
- * @property-read int|null $piggy_banks_count
- * @property-read Collection|Transaction[] $transactions
- * @property-read int|null $transactions_count
- * @property-read User $user
+ * @property int $id
+ * @property Carbon|null $created_at
+ * @property Carbon|null $updated_at
+ * @property Carbon|null $deleted_at
+ * @property int $user_id
+ * @property int $account_type_id
+ * @property string $name
+ * @property string $virtual_balance
+ * @property string|null $iban
+ * @property bool $active
+ * @property bool $encrypted
+ * @property int|string $order
+ * @property-read Collection|AccountMeta[] $accountMeta
+ * @property-read int|null $account_meta_count
+ * @property AccountType $accountType
+ * @property-read Collection|Attachment[] $attachments
+ * @property-read int|null $attachments_count
+ * @property-read string $account_number
+ * @property-read string $edit_name
+ * @property-read Collection|Location[] $locations
+ * @property-read int|null $locations_count
+ * @property-read Collection|Note[] $notes
+ * @property-read int|null $notes_count
+ * @property-read Collection|ObjectGroup[] $objectGroups
+ * @property-read int|null $object_groups_count
+ * @property-read Collection|PiggyBank[] $piggyBanks
+ * @property-read int|null $piggy_banks_count
+ * @property-read Collection|Transaction[] $transactions
+ * @property-read int|null $transactions_count
+ * @property-read User $user
* @method static EloquentBuilder|Account accountTypeIn($types)
* @method static EloquentBuilder|Account newModelQuery()
* @method static EloquentBuilder|Account newQuery()
@@ -91,27 +93,28 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static EloquentBuilder|Account whereVirtualBalance($value)
* @method static Builder|Account withTrashed()
* @method static Builder|Account withoutTrashed()
- * @property Carbon $lastActivityDate
- * @property string $startBalance
- * @property string $endBalance
- * @property string $difference
- * @property string $interest
- * @property string $interestPeriod
- * @property string $accountTypeString
- * @property Location $location
- * @property string $liability_direction
- * @property string $current_debt
- * @property int|null $user_group_id
+ * @property Carbon $lastActivityDate
+ * @property string $startBalance
+ * @property string $endBalance
+ * @property string $difference
+ * @property string $interest
+ * @property string $interestPeriod
+ * @property string $accountTypeString
+ * @property Location $location
+ * @property string $liability_direction
+ * @property string $current_debt
+ * @property int $user_group_id
* @method static EloquentBuilder|Account whereUserGroupId($value)
- * @property-read UserGroup|null $userGroup
+ * @property-read UserGroup|null $userGroup
* @mixin Eloquent
*/
class Account extends Model
{
use HasFactory;
+ use ReturnsIntegerIdTrait;
+ use ReturnsIntegerUserIdTrait;
use SoftDeletes;
-
protected $casts
= [
'created_at' => 'datetime',
@@ -124,7 +127,7 @@ class Account extends Model
protected $fillable = ['user_id', 'user_group_id', 'account_type_id', 'name', 'active', 'virtual_balance', 'iban'];
- protected $hidden = ['encrypted'];
+ protected $hidden = ['encrypted'];
private bool $joinedAccountTypes = false;
/**
@@ -296,7 +299,29 @@ class Account extends Model
protected function virtualBalance(): Attribute
{
return Attribute::make(
- get: static fn ($value) => (string)$value,
+ get: static fn($value) => (string)$value,
+ );
+ }
+ /**
+ * Get the user ID
+ *
+ * @return Attribute
+ */
+ protected function accountTypeId(): Attribute
+ {
+ return Attribute::make(
+ get: static fn($value) => (int)$value,
);
}
+
+ /**
+ * @return Attribute
+ */
+ protected function accountId(): Attribute
+ {
+ return Attribute::make(
+ get: static fn($value) => (int)$value,
+ );
+ }
+
}
diff --git a/app/Models/AccountMeta.php b/app/Models/AccountMeta.php
index 8fd5b16c21..c4df9fe153 100644
--- a/app/Models/AccountMeta.php
+++ b/app/Models/AccountMeta.php
@@ -23,19 +23,20 @@ declare(strict_types=1);
namespace FireflyIII\Models;
+use Carbon\Carbon;
use Eloquent;
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
-use Carbon\Carbon;
/**
* Class AccountMeta
*
- * @property int|string $id
+ * @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
- * @property int|string $account_id
+ * @property int $account_id
* @property string $name
* @property mixed $data
* @property-read Account $account
@@ -52,6 +53,7 @@ use Carbon\Carbon;
*/
class AccountMeta extends Model
{
+ use ReturnsIntegerIdTrait;
protected $casts
= [
@@ -88,4 +90,5 @@ class AccountMeta extends Model
{
$this->attributes['data'] = json_encode($value);
}
+
}
diff --git a/app/Models/AccountType.php b/app/Models/AccountType.php
index fe6fd00f12..9955fa9036 100644
--- a/app/Models/AccountType.php
+++ b/app/Models/AccountType.php
@@ -23,17 +23,18 @@ declare(strict_types=1);
namespace FireflyIII\Models;
+use Carbon\Carbon;
use Eloquent;
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
-use Carbon\Carbon;
/**
* FireflyIII\Models\AccountType
*
- * @property int|string $id
+ * @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property string $type
@@ -50,6 +51,8 @@ use Carbon\Carbon;
*/
class AccountType extends Model
{
+ use ReturnsIntegerIdTrait;
+
public const ASSET = 'Asset account';
public const BENEFICIARY = 'Beneficiary account';
public const CASH = 'Cash account';
@@ -66,7 +69,6 @@ class AccountType extends Model
public const REVENUE = 'Revenue account';
-
protected $casts
= [
'created_at' => 'datetime',
@@ -82,4 +84,6 @@ class AccountType extends Model
{
return $this->hasMany(Account::class);
}
+
+
}
diff --git a/app/Models/Attachment.php b/app/Models/Attachment.php
index de6bedd794..f81a025b6e 100644
--- a/app/Models/Attachment.php
+++ b/app/Models/Attachment.php
@@ -23,8 +23,12 @@ declare(strict_types=1);
namespace FireflyIII\Models;
+use Carbon\Carbon;
use Eloquent;
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
+use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait;
use FireflyIII\User;
+use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@@ -32,18 +36,17 @@ use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Database\Eloquent\Relations\MorphTo;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Query\Builder;
-use Carbon\Carbon;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* FireflyIII\Models\Attachment
*
- * @property int|string $id
+ * @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at
- * @property int|string $user_id
- * @property int|string $attachable_id
+ * @property int $user_id
+ * @property int $attachable_id
* @property string $attachable_type
* @property bool $file_exists
* @property string $md5
@@ -51,7 +54,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @property string|null $title
* @property string|null $description
* @property string $mime
- * @property int|string $size
+ * @property int|string $size
* @property bool $uploaded
* @property string $notes_text
* @property-read Model|Eloquent $attachable
@@ -78,14 +81,15 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static \Illuminate\Database\Eloquent\Builder|Attachment whereUserId($value)
* @method static Builder|Attachment withTrashed()
* @method static Builder|Attachment withoutTrashed()
- * @property int|null $user_group_id
+ * @property int $user_group_id
* @method static \Illuminate\Database\Eloquent\Builder|Attachment whereUserGroupId($value)
* @mixin Eloquent
*/
class Attachment extends Model
{
+ use ReturnsIntegerIdTrait;
use SoftDeletes;
-
+ use ReturnsIntegerUserIdTrait;
protected $casts
= [
@@ -156,4 +160,15 @@ class Attachment extends Model
{
return $this->morphMany(Note::class, 'noteable');
}
+
+ /**
+ * @return Attribute
+ */
+ protected function attachableId(): Attribute
+ {
+ return Attribute::make(
+ get: static fn($value) => (int)$value,
+ );
+ }
+
}
diff --git a/app/Models/AuditLogEntry.php b/app/Models/AuditLogEntry.php
index b1945de8eb..2986489b4c 100644
--- a/app/Models/AuditLogEntry.php
+++ b/app/Models/AuditLogEntry.php
@@ -24,12 +24,14 @@ declare(strict_types=1);
namespace FireflyIII\Models;
+use Carbon\Carbon;
use Eloquent;
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
use Illuminate\Database\Eloquent\Builder;
+use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\MorphTo;
use Illuminate\Database\Eloquent\SoftDeletes;
-use Carbon\Carbon;
/**
* Class AuditLogEntry
@@ -42,13 +44,13 @@ use Carbon\Carbon;
* @method static Builder|AuditLogEntry query()
* @method static \Illuminate\Database\Query\Builder|AuditLogEntry withTrashed()
* @method static \Illuminate\Database\Query\Builder|AuditLogEntry withoutTrashed()
- * @property int|string $id
+ * @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at
- * @property int|string $auditable_id
+ * @property int $auditable_id
* @property string $auditable_type
- * @property int|string $changer_id
+ * @property int $changer_id
* @property string $changer_type
* @property string $action
* @property array|null $before
@@ -68,6 +70,7 @@ use Carbon\Carbon;
*/
class AuditLogEntry extends Model
{
+ use ReturnsIntegerIdTrait;
use SoftDeletes;
protected $casts
@@ -92,4 +95,26 @@ class AuditLogEntry extends Model
{
return $this->morphTo();
}
+
+ /**
+ * @return Attribute
+ */
+ protected function auditableId(): Attribute
+ {
+ return Attribute::make(
+ get: static fn($value) => (int)$value,
+ );
+ }
+
+ /**
+ * @return Attribute
+ */
+ protected function changerId(): Attribute
+ {
+ return Attribute::make(
+ get: static fn($value) => (int)$value,
+ );
+ }
+
+
}
diff --git a/app/Models/AutoBudget.php b/app/Models/AutoBudget.php
index e826f7cfe7..c5490a4ad5 100644
--- a/app/Models/AutoBudget.php
+++ b/app/Models/AutoBudget.php
@@ -25,6 +25,7 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use Eloquent;
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@@ -35,14 +36,14 @@ use Carbon\Carbon;
/**
* FireflyIII\Models\AutoBudget
*
- * @property int|string $id
+ * @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at
- * @property int|string $budget_id
- * @property int|string $transaction_currency_id
- * @property int|string $auto_budget_type
- * @property string|float $amount
+ * @property int $budget_id
+ * @property int $transaction_currency_id
+ * @property int|string $auto_budget_type
+ * @property string $amount
* @property string $period
* @property-read Budget $budget
* @property-read TransactionCurrency $transactionCurrency
@@ -65,6 +66,7 @@ use Carbon\Carbon;
*/
class AutoBudget extends Model
{
+ use ReturnsIntegerIdTrait;
use SoftDeletes;
public const AUTO_BUDGET_ADJUSTED = 3;
@@ -97,4 +99,25 @@ class AutoBudget extends Model
get: static fn ($value) => (string)$value,
);
}
+
+ /**
+ * @return Attribute
+ */
+ protected function budgetId(): Attribute
+ {
+ return Attribute::make(
+ get: static fn($value) => (int)$value,
+ );
+ }
+
+ /**
+ * @return Attribute
+ */
+ protected function transactionCurrencyId(): Attribute
+ {
+ return Attribute::make(
+ get: static fn($value) => (int)$value,
+ );
+ }
+
}
diff --git a/app/Models/AvailableBudget.php b/app/Models/AvailableBudget.php
index 64c930a5a5..a767f5c581 100644
--- a/app/Models/AvailableBudget.php
+++ b/app/Models/AvailableBudget.php
@@ -24,6 +24,8 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use Eloquent;
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
+use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
@@ -36,13 +38,13 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* FireflyIII\Models\AvailableBudget
*
- * @property int|string $id
+ * @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at
- * @property int|string $user_id
- * @property int|string $transaction_currency_id
- * @property string|float $amount
+ * @property int $user_id
+ * @property int $transaction_currency_id
+ * @property string $amount
* @property Carbon $start_date
* @property Carbon $end_date
* @property-read TransactionCurrency $transactionCurrency
@@ -62,14 +64,15 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static \Illuminate\Database\Eloquent\Builder|AvailableBudget whereUserId($value)
* @method static Builder|AvailableBudget withTrashed()
* @method static Builder|AvailableBudget withoutTrashed()
- * @property int|null $user_group_id
+ * @property int $user_group_id
* @method static \Illuminate\Database\Eloquent\Builder|AvailableBudget whereUserGroupId($value)
* @mixin Eloquent
*/
class AvailableBudget extends Model
{
+ use ReturnsIntegerIdTrait;
use SoftDeletes;
-
+ use ReturnsIntegerUserIdTrait;
protected $casts
= [
@@ -131,4 +134,14 @@ class AvailableBudget extends Model
get: static fn ($value) => (string)$value,
);
}
+ /**
+ * @return Attribute
+ */
+ protected function transactionCurrencyId(): Attribute
+ {
+ return Attribute::make(
+ get: static fn($value) => (int)$value,
+ );
+ }
+
}
diff --git a/app/Models/Bill.php b/app/Models/Bill.php
index d8594599b4..b00b280ff8 100644
--- a/app/Models/Bill.php
+++ b/app/Models/Bill.php
@@ -24,6 +24,8 @@ declare(strict_types=1);
namespace FireflyIII\Models;
use Eloquent;
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
+use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Collection;
@@ -41,26 +43,26 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* FireflyIII\Models\Bill
*
- * @property int|string $id
+ * @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at
- * @property int|string $user_id
- * @property int|null $transaction_currency_id
+ * @property int $user_id
+ * @property int $transaction_currency_id
* @property string $name
* @property string $match
- * @property string|float $amount_min
- * @property string|float $amount_max
+ * @property string $amount_min
+ * @property string $amount_max
* @property Carbon $date
* @property Carbon|null $end_date
* @property Carbon|null $extension_date
* @property string $repeat_freq
- * @property int|string $skip
+ * @property int|string $skip
* @property bool $automatch
* @property bool $active
* @property bool $name_encrypted
* @property bool $match_encrypted
- * @property int|string $order
+ * @property int|string $order
* @property-read Collection|Attachment[] $attachments
* @property-read int|null $attachments_count
* @property-read Collection|Note[] $notes
@@ -97,14 +99,15 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static \Illuminate\Database\Eloquent\Builder|Bill whereUserId($value)
* @method static Builder|Bill withTrashed()
* @method static Builder|Bill withoutTrashed()
- * @property int|null $user_group_id
+ * @property int $user_group_id
* @method static \Illuminate\Database\Eloquent\Builder|Bill whereUserGroupId($value)
* @mixin Eloquent
*/
class Bill extends Model
{
+ use ReturnsIntegerIdTrait;
use SoftDeletes;
-
+ use ReturnsIntegerUserIdTrait;
protected $casts
= [
@@ -255,4 +258,16 @@ class Bill extends Model
get: static fn ($value) => (string)$value,
);
}
+
+ /**
+ * @return Attribute
+ */
+ protected function transactionCurrencyId(): Attribute
+ {
+ return Attribute::make(
+ get: static fn($value) => (int)$value,
+ );
+ }
+
+
}
diff --git a/app/Models/Budget.php b/app/Models/Budget.php
index 878e4a74cb..033492193c 100644
--- a/app/Models/Budget.php
+++ b/app/Models/Budget.php
@@ -25,6 +25,8 @@ namespace FireflyIII\Models;
use Carbon\Carbon;
use Eloquent;
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
+use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
@@ -39,15 +41,15 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* FireflyIII\Models\Budget
*
- * @property int|string $id
+ * @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at
- * @property int|string $user_id
+ * @property int $user_id
* @property string $name
* @property bool $active
* @property bool $encrypted
- * @property int|string $order
+ * @property int|string $order
* @property-read Collection|Attachment[] $attachments
* @property-read int|null $attachments_count
* @property-read Collection|AutoBudget[] $autoBudgets
@@ -75,7 +77,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static Builder|Budget withTrashed()
* @method static Builder|Budget withoutTrashed()
* @property string $email
- * @property int|null $user_group_id
+ * @property int $user_group_id
* @method static \Illuminate\Database\Eloquent\Builder|Budget whereUserGroupId($value)
* @property-read Collection|Note[] $notes
* @property-read int|null $notes_count
@@ -83,8 +85,9 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
*/
class Budget extends Model
{
+ use ReturnsIntegerIdTrait;
use SoftDeletes;
-
+ use ReturnsIntegerUserIdTrait;
protected $casts
= [
@@ -177,4 +180,6 @@ class Budget extends Model
{
return $this->belongsToMany(Transaction::class, 'budget_transaction', 'budget_id');
}
+
+
}
diff --git a/app/Models/BudgetLimit.php b/app/Models/BudgetLimit.php
index 89b3523c25..de8b255d0b 100644
--- a/app/Models/BudgetLimit.php
+++ b/app/Models/BudgetLimit.php
@@ -28,6 +28,7 @@ use Eloquent;
use FireflyIII\Events\Model\BudgetLimit\Created;
use FireflyIII\Events\Model\BudgetLimit\Deleted;
use FireflyIII\Events\Model\BudgetLimit\Updated;
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
@@ -37,17 +38,17 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/**
* FireflyIII\Models\BudgetLimit
*
- * @property int|string $id
+ * @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
- * @property int|string $budget_id
- * @property int|null $transaction_currency_id
+ * @property int $budget_id
+ * @property int $transaction_currency_id
* @property Carbon $start_date
* @property Carbon|null $end_date
- * @property string|float $amount
+ * @property string $amount
* @property string $spent
* @property string|null $period
- * @property int|string $generated
+ * @property int|string $generated
* @property-read Budget $budget
* @property-read TransactionCurrency|null $transactionCurrency
* @method static Builder|BudgetLimit newModelQuery()
@@ -67,6 +68,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
*/
class BudgetLimit extends Model
{
+ use ReturnsIntegerIdTrait;
protected $casts
= [
@@ -135,4 +137,26 @@ class BudgetLimit extends Model
get: static fn ($value) => (string)$value,
);
}
+
+ /**
+ * @return Attribute
+ */
+ protected function budgetId(): Attribute
+ {
+ return Attribute::make(
+ get: static fn($value) => (int)$value,
+ );
+ }
+
+ /**
+ * @return Attribute
+ */
+ protected function transactionCurrencyId(): Attribute
+ {
+ return Attribute::make(
+ get: static fn($value) => (int)$value,
+ );
+ }
+
+
}
diff --git a/app/Models/Category.php b/app/Models/Category.php
index b0080a04ed..c0af609e5a 100644
--- a/app/Models/Category.php
+++ b/app/Models/Category.php
@@ -25,6 +25,7 @@ namespace FireflyIII\Models;
use Carbon\Carbon;
use Eloquent;
+use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
@@ -34,15 +35,15 @@ use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Query\Builder;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
-
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
/**
* FireflyIII\Models\Category
*
- * @property int|string $id
- * @property Carbon|null $created_at
- * @property Carbon|null $updated_at
- * @property Carbon|null $deleted_at
- * @property int|string $user_id
+ * @property int $id
+ * @property Carbon|null $created_at
+ * @property Carbon|null $updated_at
+ * @property Carbon|null $deleted_at
+ * @property int $user_id
* @property string $name
* @property Carbon $lastActivity
* @property bool $encrypted
@@ -68,14 +69,15 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static \Illuminate\Database\Eloquent\Builder|Category whereUserId($value)
* @method static Builder|Category withTrashed()
* @method static Builder|Category withoutTrashed()
- * @property int|null $user_group_id
+ * @property int $user_group_id
* @method static \Illuminate\Database\Eloquent\Builder|Category whereUserGroupId($value)
* @mixin Eloquent
*/
class Category extends Model
{
+ use ReturnsIntegerIdTrait;
use SoftDeletes;
-
+ use ReturnsIntegerUserIdTrait;
protected $casts
= [
@@ -151,4 +153,5 @@ class Category extends Model
{
return $this->belongsToMany(Transaction::class, 'category_transaction', 'category_id');
}
+
}
diff --git a/app/Models/Configuration.php b/app/Models/Configuration.php
index d758c8c9f4..1e6adde23c 100644
--- a/app/Models/Configuration.php
+++ b/app/Models/Configuration.php
@@ -23,16 +23,16 @@ declare(strict_types=1);
namespace FireflyIII\Models;
+use Carbon\Carbon;
use Eloquent;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Query\Builder;
-use Carbon\Carbon;
-
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
/**
* FireflyIII\Models\Configuration
*
- * @property int|string $id
+ * @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at
@@ -54,6 +54,7 @@ use Carbon\Carbon;
*/
class Configuration extends Model
{
+ use ReturnsIntegerIdTrait;
use SoftDeletes;
@@ -87,4 +88,6 @@ class Configuration extends Model
{
$this->attributes['data'] = json_encode($value);
}
+
+
}
diff --git a/app/Models/CurrencyExchangeRate.php b/app/Models/CurrencyExchangeRate.php
index 3faf5a835d..a6998ed82e 100644
--- a/app/Models/CurrencyExchangeRate.php
+++ b/app/Models/CurrencyExchangeRate.php
@@ -22,8 +22,9 @@
declare(strict_types=1);
namespace FireflyIII\Models;
-
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
use Eloquent;
+use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Casts\Attribute;
@@ -35,16 +36,16 @@ use Carbon\Carbon;
/**
* Class CurrencyExchangeRate
*
- * @property int|string $id
+ * @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property string|null $deleted_at
- * @property int|string $user_id
- * @property int|string $from_currency_id
- * @property int|string $to_currency_id
+ * @property int $user_id
+ * @property int $from_currency_id
+ * @property int $to_currency_id
* @property Carbon $date
- * @property string|float $rate
- * @property string|null $user_rate
+ * @property string $rate
+ * @property string $user_rate
* @property-read TransactionCurrency $fromCurrency
* @property-read TransactionCurrency $toCurrency
* @property-read User $user
@@ -61,7 +62,7 @@ use Carbon\Carbon;
* @method static Builder|CurrencyExchangeRate whereUpdatedAt($value)
* @method static Builder|CurrencyExchangeRate whereUserId($value)
* @method static Builder|CurrencyExchangeRate whereUserRate($value)
- * @property int|null $user_group_id
+ * @property int $user_group_id
* @method static Builder|CurrencyExchangeRate whereUserGroupId($value)
* @method static Builder|CurrencyExchangeRate onlyTrashed()
* @method static Builder|CurrencyExchangeRate withTrashed()
@@ -70,7 +71,10 @@ use Carbon\Carbon;
*/
class CurrencyExchangeRate extends Model
{
+ use ReturnsIntegerIdTrait;
use SoftDeletes;
+ use ReturnsIntegerUserIdTrait;
+
protected $casts
= [
@@ -126,4 +130,26 @@ class CurrencyExchangeRate extends Model
get: static fn ($value) => (string)$value,
);
}
+
+ /**
+ * @return Attribute
+ */
+ protected function fromCurrencyId(): Attribute
+ {
+ return Attribute::make(
+ get: static fn($value) => (int)$value,
+ );
+ }
+
+ /**
+ * @return Attribute
+ */
+ protected function toCurrencyId(): Attribute
+ {
+ return Attribute::make(
+ get: static fn($value) => (int)$value,
+ );
+ }
+
+
}
diff --git a/app/Models/GroupMembership.php b/app/Models/GroupMembership.php
index b9011228ef..d2e9dd8394 100644
--- a/app/Models/GroupMembership.php
+++ b/app/Models/GroupMembership.php
@@ -24,23 +24,25 @@ declare(strict_types=1);
namespace FireflyIII\Models;
+use Carbon\Carbon;
use Eloquent;
+use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Builder;
+use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
-use Carbon\Carbon;
-
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
/**
* Class GroupMembership
*
- * @property int|string $id
+ * @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property string|null $deleted_at
- * @property int|string $user_id
- * @property int|string $user_group_id
- * @property int|string $user_role_id
+ * @property int $user_id
+ * @property int $user_group_id
+ * @property int $user_role_id
* @property-read User $user
* @property-read UserGroup $userGroup
* @property-read UserRole $userRole
@@ -58,6 +60,9 @@ use Carbon\Carbon;
*/
class GroupMembership extends Model
{
+ use ReturnsIntegerIdTrait;
+ use ReturnsIntegerUserIdTrait;
+
protected $fillable = ['user_id', 'user_group_id', 'user_role_id'];
/**
@@ -83,4 +88,16 @@ class GroupMembership extends Model
{
return $this->belongsTo(UserRole::class);
}
+
+ /**
+ * @return Attribute
+ */
+ protected function userRoleId(): Attribute
+ {
+ return Attribute::make(
+ get: static fn($value) => (int)$value,
+ );
+ }
+
+
}
diff --git a/app/Models/InvitedUser.php b/app/Models/InvitedUser.php
index aa753d8edd..694bf9d392 100644
--- a/app/Models/InvitedUser.php
+++ b/app/Models/InvitedUser.php
@@ -26,12 +26,13 @@ namespace FireflyIII\Models;
use Carbon\Carbon;
use Eloquent;
+use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
-
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
/**
* Class InvitedUser
*
@@ -39,10 +40,10 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static Builder|InvitedUser newModelQuery()
* @method static Builder|InvitedUser newQuery()
* @method static Builder|InvitedUser query()
- * @property int|string $id
+ * @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
- * @property int|string $user_id
+ * @property int $user_id
* @property string $email
* @property string $invite_code
* @property Carbon $expires
@@ -59,6 +60,9 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
*/
class InvitedUser extends Model
{
+ use ReturnsIntegerIdTrait;
+ use ReturnsIntegerUserIdTrait;
+
protected $casts
= [
'expires' => 'datetime',
@@ -93,4 +97,6 @@ class InvitedUser extends Model
{
return $this->belongsTo(User::class);
}
+
+
}
diff --git a/app/Models/LinkType.php b/app/Models/LinkType.php
index a725f498b1..25cc93e8d7 100644
--- a/app/Models/LinkType.php
+++ b/app/Models/LinkType.php
@@ -23,19 +23,19 @@ declare(strict_types=1);
namespace FireflyIII\Models;
+use Carbon\Carbon;
use Eloquent;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Query\Builder;
-use Carbon\Carbon;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
-
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
/**
* FireflyIII\Models\LinkType
*
- * @property int|string $id
+ * @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at
@@ -64,6 +64,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
*/
class LinkType extends Model
{
+ use ReturnsIntegerIdTrait;
use SoftDeletes;
@@ -106,4 +107,6 @@ class LinkType extends Model
{
return $this->hasMany(TransactionJournalLink::class);
}
+
+
}
diff --git a/app/Models/Location.php b/app/Models/Location.php
index d12ef14adc..52a4d6c9fd 100644
--- a/app/Models/Location.php
+++ b/app/Models/Location.php
@@ -24,22 +24,23 @@ declare(strict_types=1);
namespace FireflyIII\Models;
+use Carbon\Carbon;
use Eloquent;
use Illuminate\Database\Eloquent\Builder;
+use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Database\Eloquent\Relations\MorphTo;
-use Carbon\Carbon;
-
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
/**
* FireflyIII\Models\Location
*
- * @property int|string $id
+ * @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at
- * @property int|string $locatable_id
+ * @property int $locatable_id
* @property string $locatable_type
* @property float|null $latitude
* @property float|null $longitude
@@ -63,6 +64,7 @@ use Carbon\Carbon;
*/
class Location extends Model
{
+ use ReturnsIntegerIdTrait;
protected $casts
= [
@@ -110,4 +112,16 @@ class Location extends Model
{
return $this->morphTo();
}
+
+ /**
+ * @return Attribute
+ */
+ protected function locatableId(): Attribute
+ {
+ return Attribute::make(
+ get: static fn($value) => (int)$value,
+ );
+ }
+
+
}
diff --git a/app/Models/Note.php b/app/Models/Note.php
index 212f41cae7..8e0b5aaaf6 100644
--- a/app/Models/Note.php
+++ b/app/Models/Note.php
@@ -23,21 +23,22 @@ declare(strict_types=1);
namespace FireflyIII\Models;
+use Carbon\Carbon;
use Eloquent;
+use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\MorphTo;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Query\Builder;
-use Carbon\Carbon;
-
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
/**
* FireflyIII\Models\Note
*
- * @property int|string $id
+ * @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at
- * @property int|string $noteable_id
+ * @property int $noteable_id
* @property string $noteable_type
* @property string|null $title
* @property string|null $text
@@ -60,6 +61,7 @@ use Carbon\Carbon;
*/
class Note extends Model
{
+ use ReturnsIntegerIdTrait;
use SoftDeletes;
@@ -80,4 +82,16 @@ class Note extends Model
{
return $this->morphTo();
}
+
+ /**
+ * @return Attribute
+ */
+ protected function noteableId(): Attribute
+ {
+ return Attribute::make(
+ get: static fn($value) => (int)$value,
+ );
+ }
+
+
}
diff --git a/app/Models/ObjectGroup.php b/app/Models/ObjectGroup.php
index 60e4ccfd5e..0781142153 100644
--- a/app/Models/ObjectGroup.php
+++ b/app/Models/ObjectGroup.php
@@ -24,26 +24,28 @@ declare(strict_types=1);
namespace FireflyIII\Models;
+use Carbon\Carbon;
use Eloquent;
+use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Builder;
+use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\MorphToMany;
-use Carbon\Carbon;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
-
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
/**
* FireflyIII\Models\ObjectGroup
*
- * @property int|string $id
- * @property int|string $user_id
+ * @property int $id
+ * @property int $user_id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at
* @property string $title
- * @property int|string $order
+ * @property int $order
* @property-read Collection|Account[] $accounts
* @property-read int|null $accounts_count
* @property-read Collection|Bill[] $bills
@@ -61,12 +63,14 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static Builder|ObjectGroup whereTitle($value)
* @method static Builder|ObjectGroup whereUpdatedAt($value)
* @method static Builder|ObjectGroup whereUserId($value)
- * @property int|null $user_group_id
+ * @property int $user_group_id
* @method static Builder|ObjectGroup whereUserGroupId($value)
* @mixin Eloquent
*/
class ObjectGroup extends Model
{
+ use ReturnsIntegerIdTrait;
+ use ReturnsIntegerUserIdTrait;
protected $casts
= [
@@ -130,4 +134,16 @@ class ObjectGroup extends Model
{
return $this->morphedByMany(PiggyBank::class, 'object_groupable');
}
+
+
+ /**
+ * @return Attribute
+ */
+ protected function order(): Attribute
+ {
+ return Attribute::make(
+ get: static fn($value) => (int)$value,
+ );
+ }
+
}
diff --git a/app/Models/PiggyBank.php b/app/Models/PiggyBank.php
index 6d9f6cbfca..3adbd26e68 100644
--- a/app/Models/PiggyBank.php
+++ b/app/Models/PiggyBank.php
@@ -35,20 +35,20 @@ use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Query\Builder;
use Carbon\Carbon;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
-
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
/**
* FireflyIII\Models\PiggyBank
*
- * @property int|string $id
+ * @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at
- * @property int|string $account_id
+ * @property int $account_id
* @property string $name
- * @property string|float $targetamount
+ * @property string $targetamount
* @property Carbon|null $startdate
* @property Carbon|null $targetdate
- * @property int|string $order
+ * @property int|string $order
* @property bool $active
* @property bool $encrypted
* @property-read Account $account
@@ -84,6 +84,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
*/
class PiggyBank extends Model
{
+ use ReturnsIntegerIdTrait;
use SoftDeletes;
protected $casts
@@ -192,4 +193,14 @@ class PiggyBank extends Model
get: static fn ($value) => (string)$value,
);
}
+
+ /**
+ * @return Attribute
+ */
+ protected function accountId(): Attribute
+ {
+ return Attribute::make(
+ get: static fn($value) => (int)$value,
+ );
+ }
}
diff --git a/app/Models/PiggyBankEvent.php b/app/Models/PiggyBankEvent.php
index f04479de95..912b11777e 100644
--- a/app/Models/PiggyBankEvent.php
+++ b/app/Models/PiggyBankEvent.php
@@ -29,14 +29,14 @@ use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Carbon\Carbon;
-
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
/**
* FireflyIII\Models\PiggyBankEvent
*
- * @property int|string $id
+ * @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
- * @property int|string $piggy_bank_id
+ * @property int $piggy_bank_id
* @property int|null $transaction_journal_id
* @property Carbon $date
* @property string $amount
@@ -56,6 +56,7 @@ use Carbon\Carbon;
*/
class PiggyBankEvent extends Model
{
+ use ReturnsIntegerIdTrait;
protected $casts
= [
@@ -104,4 +105,14 @@ class PiggyBankEvent extends Model
get: static fn ($value) => (string)$value,
);
}
+
+ /**
+ * @return Attribute
+ */
+ protected function piggyBankId(): Attribute
+ {
+ return Attribute::make(
+ get: static fn($value) => (int)$value,
+ );
+ }
}
diff --git a/app/Models/PiggyBankRepetition.php b/app/Models/PiggyBankRepetition.php
index 5640c308b6..b8fec231a4 100644
--- a/app/Models/PiggyBankRepetition.php
+++ b/app/Models/PiggyBankRepetition.php
@@ -29,18 +29,18 @@ use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
-
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
/**
* FireflyIII\Models\PiggyBankRepetition
*
- * @property int|string $id
- * @property Carbon|null $created_at
- * @property Carbon|null $updated_at
- * @property int|string $piggy_bank_id
- * @property Carbon|null $startdate
- * @property Carbon|null $targetdate
- * @property string|float $currentamount
- * @property-read PiggyBank $piggyBank
+ * @property int $id
+ * @property Carbon|null $created_at
+ * @property Carbon|null $updated_at
+ * @property int $piggy_bank_id
+ * @property Carbon|null $startdate
+ * @property Carbon|null $targetdate
+ * @property string $currentamount
+ * @property-read PiggyBank $piggyBank
* @method static EloquentBuilder|PiggyBankRepetition newModelQuery()
* @method static EloquentBuilder|PiggyBankRepetition newQuery()
* @method static EloquentBuilder|PiggyBankRepetition onDates(Carbon $start, Carbon $target)
@@ -57,6 +57,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
*/
class PiggyBankRepetition extends Model
{
+ use ReturnsIntegerIdTrait;
protected $casts
= [
@@ -132,4 +133,14 @@ class PiggyBankRepetition extends Model
get: static fn ($value) => (string)$value,
);
}
+
+ /**
+ * @return Attribute
+ */
+ protected function piggyBankId(): Attribute
+ {
+ return Attribute::make(
+ get: static fn($value) => (int)$value,
+ );
+ }
}
diff --git a/app/Models/Preference.php b/app/Models/Preference.php
index 8904904e99..db27acd374 100644
--- a/app/Models/Preference.php
+++ b/app/Models/Preference.php
@@ -23,21 +23,22 @@ declare(strict_types=1);
namespace FireflyIII\Models;
+use Carbon\Carbon;
use Eloquent;
+use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
-use Carbon\Carbon;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
-
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
/**
* FireflyIII\Models\Preference
*
- * @property int|string $id
+ * @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
- * @property int|string $user_id
+ * @property int $user_id
* @property string $name
* @property int|string|array|null $data
* @property-read User $user
@@ -54,6 +55,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
*/
class Preference extends Model
{
+ use ReturnsIntegerIdTrait;
+ use ReturnsIntegerUserIdTrait;
protected $casts
= [
diff --git a/app/Models/Recurrence.php b/app/Models/Recurrence.php
index e0f75e5fd1..07fb06ea3a 100644
--- a/app/Models/Recurrence.php
+++ b/app/Models/Recurrence.php
@@ -25,7 +25,9 @@ namespace FireflyIII\Models;
use Carbon\Carbon;
use Eloquent;
+use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait;
use FireflyIII\User;
+use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@@ -34,22 +36,22 @@ use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Query\Builder;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
-
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
/**
* FireflyIII\Models\Recurrence
*
- * @property int|string $id
+ * @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at
- * @property int|string $user_id
- * @property int|string $transaction_type_id
+ * @property int $user_id
+ * @property int $transaction_type_id
* @property string $title
* @property string $description
* @property Carbon|null $first_date
* @property Carbon|null $repeat_until
* @property Carbon|null $latest_date
- * @property int|string $repetitions
+ * @property int|string $repetitions
* @property bool $apply_rules
* @property bool $active
* @property-read Collection|Attachment[] $attachments
@@ -85,13 +87,15 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static \Illuminate\Database\Eloquent\Builder|Recurrence whereUserId($value)
* @method static Builder|Recurrence withTrashed()
* @method static Builder|Recurrence withoutTrashed()
- * @property int|null $user_group_id
+ * @property int $user_group_id
* @method static \Illuminate\Database\Eloquent\Builder|Recurrence whereUserGroupId($value)
* @mixin Eloquent
*/
class Recurrence extends Model
{
+ use ReturnsIntegerIdTrait;
use SoftDeletes;
+ use ReturnsIntegerUserIdTrait;
protected $casts
@@ -201,4 +205,14 @@ class Recurrence extends Model
{
return $this->belongsTo(TransactionType::class);
}
+
+ /**
+ * @return Attribute
+ */
+ protected function transactionTypeId(): Attribute
+ {
+ return Attribute::make(
+ get: static fn($value) => (int)$value,
+ );
+ }
}
diff --git a/app/Models/RecurrenceMeta.php b/app/Models/RecurrenceMeta.php
index fca651fe5e..a69bfc7687 100644
--- a/app/Models/RecurrenceMeta.php
+++ b/app/Models/RecurrenceMeta.php
@@ -23,21 +23,22 @@ declare(strict_types=1);
namespace FireflyIII\Models;
+use Carbon\Carbon;
use Eloquent;
+use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Query\Builder;
-use Carbon\Carbon;
-
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
/**
* FireflyIII\Models\RecurrenceMeta
*
- * @property int|string $id
+ * @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at
- * @property int|string $recurrence_id
+ * @property int $recurrence_id
* @property string $name
* @property mixed $value
* @property-read Recurrence $recurrence
@@ -58,6 +59,7 @@ use Carbon\Carbon;
*/
class RecurrenceMeta extends Model
{
+ use ReturnsIntegerIdTrait;
use SoftDeletes;
@@ -81,4 +83,14 @@ class RecurrenceMeta extends Model
{
return $this->belongsTo(Recurrence::class);
}
+
+ /**
+ * @return Attribute
+ */
+ protected function recurrenceId(): Attribute
+ {
+ return Attribute::make(
+ get: static fn($value) => (int)$value,
+ );
+ }
}
diff --git a/app/Models/RecurrenceRepetition.php b/app/Models/RecurrenceRepetition.php
index 696bb60a4e..2171ee76d4 100644
--- a/app/Models/RecurrenceRepetition.php
+++ b/app/Models/RecurrenceRepetition.php
@@ -23,25 +23,26 @@ declare(strict_types=1);
namespace FireflyIII\Models;
+use Carbon\Carbon;
use Eloquent;
+use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Query\Builder;
-use Carbon\Carbon;
-
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
/**
* FireflyIII\Models\RecurrenceRepetition
*
- * @property int|string $id
+ * @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at
- * @property int|string $recurrence_id
+ * @property int $recurrence_id
* @property string $repetition_type
* @property string $repetition_moment
- * @property int|string $repetition_skip
- * @property int|string $weekend
+ * @property int|string $repetition_skip
+ * @property int|string $weekend
* @property-read Recurrence $recurrence
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceRepetition newModelQuery()
* @method static \Illuminate\Database\Eloquent\Builder|RecurrenceRepetition newQuery()
@@ -62,6 +63,7 @@ use Carbon\Carbon;
*/
class RecurrenceRepetition extends Model
{
+ use ReturnsIntegerIdTrait;
use SoftDeletes;
public const WEEKEND_DO_NOTHING = 1;
@@ -92,4 +94,14 @@ class RecurrenceRepetition extends Model
{
return $this->belongsTo(Recurrence::class);
}
+
+ /**
+ * @return Attribute
+ */
+ protected function recurrenceId(): Attribute
+ {
+ return Attribute::make(
+ get: static fn($value) => (int)$value,
+ );
+ }
}
diff --git a/app/Models/RecurrenceTransaction.php b/app/Models/RecurrenceTransaction.php
index 4c79f9d005..9b80e576e3 100644
--- a/app/Models/RecurrenceTransaction.php
+++ b/app/Models/RecurrenceTransaction.php
@@ -32,21 +32,21 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Query\Builder;
use Carbon\Carbon;
-
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
/**
* FireflyIII\Models\RecurrenceTransaction
*
- * @property int|string $id
+ * @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at
- * @property int|string $recurrence_id
- * @property int|string $transaction_currency_id
- * @property int|string|null $foreign_currency_id
- * @property int|string $source_id
- * @property int|string $destination_id
- * @property string|float $amount
- * @property string|float|null $foreign_amount
+ * @property int $recurrence_id
+ * @property int $transaction_currency_id
+ * @property int|string|null $foreign_currency_id
+ * @property int $source_id
+ * @property int $destination_id
+ * @property string $amount
+ * @property string $foreign_amount
* @property string $description
* @property-read Account $destinationAccount
* @property-read TransactionCurrency|null $foreignCurrency
@@ -80,6 +80,7 @@ use Carbon\Carbon;
*/
class RecurrenceTransaction extends Model
{
+ use ReturnsIntegerIdTrait;
use SoftDeletes;
@@ -181,5 +182,56 @@ class RecurrenceTransaction extends Model
return Attribute::make(
get: static fn ($value) => (string)$value,
);
+
+ }
+
+ /**
+ * @return Attribute
+ */
+ protected function recurrenceId(): Attribute
+ {
+ return Attribute::make(
+ get: static fn($value) => (int)$value,
+ );
+ }
+
+ /**
+ * @return Attribute
+ */
+ protected function transactionCurrencyId(): Attribute
+ {
+ return Attribute::make(
+ get: static fn($value) => (int)$value,
+ );
+ }
+
+ /**
+ * @return Attribute
+ */
+ protected function sourceId(): Attribute
+ {
+ return Attribute::make(
+ get: static fn($value) => (int)$value,
+ );
+ }
+
+ /**
+ * @return Attribute
+ */
+ protected function destinationId(): Attribute
+ {
+ return Attribute::make(
+ get: static fn($value) => (int)$value,
+ );
+ }
+
+ /**
+ * @return Attribute
+ */
+ protected function userId(): Attribute
+ {
+ return Attribute::make(
+ get: static fn($value) => (int)$value,
+ );
}
}
diff --git a/app/Models/RecurrenceTransactionMeta.php b/app/Models/RecurrenceTransactionMeta.php
index 181ffa254e..9cc8ef3a9c 100644
--- a/app/Models/RecurrenceTransactionMeta.php
+++ b/app/Models/RecurrenceTransactionMeta.php
@@ -23,21 +23,22 @@ declare(strict_types=1);
namespace FireflyIII\Models;
+use Carbon\Carbon;
use Eloquent;
+use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Query\Builder;
-use Carbon\Carbon;
-
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
/**
* FireflyIII\Models\RecurrenceTransactionMeta
*
- * @property int|string $id
+ * @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at
- * @property int|string $rt_id
+ * @property int|string $rt_id
* @property string $name
* @property mixed $value
* @property-read RecurrenceTransaction $recurrenceTransaction
@@ -58,6 +59,7 @@ use Carbon\Carbon;
*/
class RecurrenceTransactionMeta extends Model
{
+ use ReturnsIntegerIdTrait;
use SoftDeletes;
@@ -81,4 +83,14 @@ class RecurrenceTransactionMeta extends Model
{
return $this->belongsTo(RecurrenceTransaction::class, 'rt_id');
}
+
+ /**
+ * @return Attribute
+ */
+ protected function rtId(): Attribute
+ {
+ return Attribute::make(
+ get: static fn($value) => (int)$value,
+ );
+ }
}
diff --git a/app/Models/Role.php b/app/Models/Role.php
index ac0f5e29da..03698a3ad8 100644
--- a/app/Models/Role.php
+++ b/app/Models/Role.php
@@ -23,18 +23,19 @@ declare(strict_types=1);
namespace FireflyIII\Models;
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
+use Carbon\Carbon;
use Eloquent;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
-use Carbon\Carbon;
/**
* FireflyIII\Models\Role
*
- * @property int|string $id
+ * @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property string $name
@@ -55,6 +56,7 @@ use Carbon\Carbon;
*/
class Role extends Model
{
+ use ReturnsIntegerIdTrait;
protected $casts
= [
diff --git a/app/Models/Rule.php b/app/Models/Rule.php
index 37bacf10f9..3e08296524 100644
--- a/app/Models/Rule.php
+++ b/app/Models/Rule.php
@@ -23,29 +23,31 @@ declare(strict_types=1);
namespace FireflyIII\Models;
+use Carbon\Carbon;
use Eloquent;
+use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait;
use FireflyIII\User;
+use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Query\Builder;
-use Carbon\Carbon;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
-
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
/**
* FireflyIII\Models\Rule
*
- * @property int|string $id
+ * @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at
- * @property int|string $user_id
- * @property int|string $rule_group_id
+ * @property int $user_id
+ * @property int $rule_group_id
* @property string $title
* @property string|null $description
- * @property int|string $order
+ * @property int $order
* @property bool $active
* @property bool $stop_processing
* @property bool $strict
@@ -74,14 +76,16 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static \Illuminate\Database\Eloquent\Builder|Rule whereUserId($value)
* @method static Builder|Rule withTrashed()
* @method static Builder|Rule withoutTrashed()
- * @property int|null $user_group_id
+ * @property int $user_group_id
* @method static \Illuminate\Database\Eloquent\Builder|Rule whereUserGroupId($value)
* @property-read UserGroup|null $userGroup
* @mixin Eloquent
*/
class Rule extends Model
{
+ use ReturnsIntegerIdTrait;
use SoftDeletes;
+ use ReturnsIntegerUserIdTrait;
protected $casts
@@ -170,4 +174,24 @@ class Rule extends Model
{
return $this->belongsTo(UserGroup::class);
}
+
+ /**
+ * @return Attribute
+ */
+ protected function ruleGroupId(): Attribute
+ {
+ return Attribute::make(
+ get: static fn($value) => (int)$value,
+ );
+ }
+
+ /**
+ * @return Attribute
+ */
+ protected function order(): Attribute
+ {
+ return Attribute::make(
+ get: static fn($value) => (int)$value,
+ );
+ }
}
diff --git a/app/Models/RuleAction.php b/app/Models/RuleAction.php
index 5fadfa9378..ec0e3c3c75 100644
--- a/app/Models/RuleAction.php
+++ b/app/Models/RuleAction.php
@@ -23,22 +23,23 @@ declare(strict_types=1);
namespace FireflyIII\Models;
+use Carbon\Carbon;
use Eloquent;
use Illuminate\Database\Eloquent\Builder;
+use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
-use Carbon\Carbon;
-
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
/**
* FireflyIII\Models\RuleAction
*
- * @property int|string $id
+ * @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
- * @property int|string $rule_id
- * @property string|null $action_type
- * @property string|null $action_value
- * @property int|string $order
+ * @property int $rule_id
+ * @property string|null $action_type
+ * @property string|null $action_value
+ * @property int|string $order
* @property bool $active
* @property bool $stop_processing
* @property-read Rule $rule
@@ -58,6 +59,7 @@ use Carbon\Carbon;
*/
class RuleAction extends Model
{
+ use ReturnsIntegerIdTrait;
protected $casts
= [
@@ -78,4 +80,14 @@ class RuleAction extends Model
{
return $this->belongsTo(Rule::class);
}
+
+ /**
+ * @return Attribute
+ */
+ protected function ruleId(): Attribute
+ {
+ return Attribute::make(
+ get: static fn($value) => (int)$value,
+ );
+ }
}
diff --git a/app/Models/RuleGroup.php b/app/Models/RuleGroup.php
index 5d7dfcf1c3..b9dbfb9301 100644
--- a/app/Models/RuleGroup.php
+++ b/app/Models/RuleGroup.php
@@ -23,7 +23,9 @@ declare(strict_types=1);
namespace FireflyIII\Models;
+use Carbon\Carbon;
use Eloquent;
+use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
@@ -31,20 +33,19 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Query\Builder;
-use Carbon\Carbon;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
-
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
/**
* FireflyIII\Models\RuleGroup
*
- * @property int|string $id
+ * @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at
- * @property int|string $user_id
- * @property string|null $title
+ * @property int $user_id
+ * @property string|null $title
* @property string|null $description
- * @property int|string $order
+ * @property int|string $order
* @property bool $active
* @property bool $stop_processing
* @property Collection|Rule[] $rules
@@ -66,13 +67,15 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static \Illuminate\Database\Eloquent\Builder|RuleGroup whereUserId($value)
* @method static Builder|RuleGroup withTrashed()
* @method static Builder|RuleGroup withoutTrashed()
- * @property int|null $user_group_id
+ * @property int $user_group_id
* @method static \Illuminate\Database\Eloquent\Builder|RuleGroup whereUserGroupId($value)
* @mixin Eloquent
*/
class RuleGroup extends Model
{
+ use ReturnsIntegerIdTrait;
use SoftDeletes;
+ use ReturnsIntegerUserIdTrait;
protected $casts
diff --git a/app/Models/RuleTrigger.php b/app/Models/RuleTrigger.php
index 188d903e45..f437205406 100644
--- a/app/Models/RuleTrigger.php
+++ b/app/Models/RuleTrigger.php
@@ -23,22 +23,23 @@ declare(strict_types=1);
namespace FireflyIII\Models;
+use Carbon\Carbon;
use Eloquent;
use Illuminate\Database\Eloquent\Builder;
+use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
-use Carbon\Carbon;
-
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
/**
* FireflyIII\Models\RuleTrigger
*
- * @property int|string $id
+ * @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
- * @property int|string $rule_id
- * @property string|null $trigger_type
- * @property string|null $trigger_value
- * @property int|string $order
+ * @property int $rule_id
+ * @property string|null $trigger_type
+ * @property string|null $trigger_value
+ * @property int|string $order
* @property bool $active
* @property bool $stop_processing
* @property-read Rule $rule
@@ -58,6 +59,7 @@ use Carbon\Carbon;
*/
class RuleTrigger extends Model
{
+ use ReturnsIntegerIdTrait;
protected $casts
= [
@@ -78,4 +80,14 @@ class RuleTrigger extends Model
{
return $this->belongsTo(Rule::class);
}
+
+ /**
+ * @return Attribute
+ */
+ protected function ruleId(): Attribute
+ {
+ return Attribute::make(
+ get: static fn($value) => (int)$value,
+ );
+ }
}
diff --git a/app/Models/Tag.php b/app/Models/Tag.php
index d87f83e4eb..fe69702d69 100644
--- a/app/Models/Tag.php
+++ b/app/Models/Tag.php
@@ -23,7 +23,9 @@ declare(strict_types=1);
namespace FireflyIII\Models;
+use Carbon\Carbon;
use Eloquent;
+use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
@@ -32,17 +34,16 @@ use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Query\Builder;
-use Carbon\Carbon;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
-
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
/**
* FireflyIII\Models\Tag
*
- * @property int|string $id
+ * @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at
- * @property int|string $user_id
+ * @property int $user_id
* @property string $tag
* @property string $tagMode
* @property Carbon|null $date
@@ -75,13 +76,15 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static \Illuminate\Database\Eloquent\Builder|Tag whereZoomLevel($value)
* @method static Builder|Tag withTrashed()
* @method static Builder|Tag withoutTrashed()
- * @property int|null $user_group_id
+ * @property int $user_group_id
* @method static \Illuminate\Database\Eloquent\Builder|Tag whereUserGroupId($value)
* @mixin Eloquent
*/
class Tag extends Model
{
+ use ReturnsIntegerIdTrait;
use SoftDeletes;
+ use ReturnsIntegerUserIdTrait;
protected $casts
diff --git a/app/Models/Transaction.php b/app/Models/Transaction.php
index f61624df45..0052dff7fc 100644
--- a/app/Models/Transaction.php
+++ b/app/Models/Transaction.php
@@ -33,35 +33,35 @@ use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\SoftDeletes;
-
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
/**
* FireflyIII\Models\Transaction
*
- * @property int|string $id
- * @property Carbon|null $created_at
- * @property Carbon|null $updated_at
- * @property Carbon|null $deleted_at
- * @property bool $reconciled
- * @property int|string $account_id
- * @property int|string $transaction_journal_id
- * @property string|null $description
- * @property int|null $transaction_currency_id
- * @property string|null $modified
- * @property string|null $modified_foreign
- * @property string $date
- * @property string $max_date
- * @property string|float $amount
- * @property string|float|null $foreign_amount
- * @property int|null $foreign_currency_id
- * @property int $identifier
- * @property-read Account $account
- * @property-read Collection|Budget[] $budgets
- * @property-read int|null $budgets_count
- * @property-read Collection|Category[] $categories
- * @property-read int|null $categories_count
- * @property-read TransactionCurrency|null $foreignCurrency
- * @property-read TransactionCurrency|null $transactionCurrency
- * @property-read TransactionJournal $transactionJournal
+ * @property int $id
+ * @property Carbon|null $created_at
+ * @property Carbon|null $updated_at
+ * @property Carbon|null $deleted_at
+ * @property bool $reconciled
+ * @property int $account_id
+ * @property int $transaction_journal_id
+ * @property string|null $description
+ * @property int|null $transaction_currency_id
+ * @property string|null $modified
+ * @property string|null $modified_foreign
+ * @property string $date
+ * @property string $max_date
+ * @property string $amount
+ * @property string|null $foreign_amount
+ * @property int|null $foreign_currency_id
+ * @property int $identifier
+ * @property-read Account $account
+ * @property-read Collection|Budget[] $budgets
+ * @property-read int|null $budgets_count
+ * @property-read Collection|Category[] $categories
+ * @property-read int|null $categories_count
+ * @property-read TransactionCurrency|null $foreignCurrency
+ * @property-read TransactionCurrency|null $transactionCurrency
+ * @property-read TransactionJournal $transactionJournal
* @method static Builder|Transaction after(Carbon $date)
* @method static Builder|Transaction before(Carbon $date)
* @method static Builder|Transaction newModelQuery()
@@ -84,12 +84,13 @@ use Illuminate\Database\Eloquent\SoftDeletes;
* @method static Builder|Transaction whereUpdatedAt($value)
* @method static \Illuminate\Database\Query\Builder|Transaction withTrashed()
* @method static \Illuminate\Database\Query\Builder|Transaction withoutTrashed()
- * @property int|string $the_count
+ * @property int|string $the_count
* @mixin Eloquent
*/
class Transaction extends Model
{
use HasFactory;
+ use ReturnsIntegerIdTrait;
use SoftDeletes;
@@ -275,4 +276,23 @@ class Transaction extends Model
get: static fn ($value) => (string)$value,
);
}
+
+ /**
+ * @return Attribute
+ */
+ protected function accountId(): Attribute
+ {
+ return Attribute::make(
+ get: static fn($value) => (int)$value,
+ );
+ }
+ /**
+ * @return Attribute
+ */
+ protected function transactionJournalId(): Attribute
+ {
+ return Attribute::make(
+ get: static fn($value) => (int)$value,
+ );
+ }
}
diff --git a/app/Models/TransactionCurrency.php b/app/Models/TransactionCurrency.php
index c49b2d43e6..6cfbe7dd70 100644
--- a/app/Models/TransactionCurrency.php
+++ b/app/Models/TransactionCurrency.php
@@ -33,11 +33,11 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Query\Builder;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
-
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
/**
* FireflyIII\Models\TransactionCurrency
*
- * @property int|string $id
+ * @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at
@@ -77,12 +77,11 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
*/
class TransactionCurrency extends Model
{
+ use ReturnsIntegerIdTrait;
use SoftDeletes;
- public ?bool $userEnabled;
public ?bool $userDefault;
-
-
+ public ?bool $userEnabled;
protected $casts
= [
'created_at' => 'datetime',
@@ -124,7 +123,7 @@ class TransactionCurrency extends Model
{
$current = $user->userGroup->currencies()->where('transaction_currencies.id', $this->id)->first();
$default = app('amount')->getDefaultCurrencyByUserGroup($user->userGroup);
- $this->userDefault = (int)$default->id === (int)$this->id;
+ $this->userDefault = $default->id === $this->id;
$this->userEnabled = null !== $current;
}
diff --git a/app/Models/TransactionGroup.php b/app/Models/TransactionGroup.php
index 68f2cc11f8..d508dc7118 100644
--- a/app/Models/TransactionGroup.php
+++ b/app/Models/TransactionGroup.php
@@ -23,7 +23,9 @@ declare(strict_types=1);
namespace FireflyIII\Models;
+use Carbon\Carbon;
use Eloquent;
+use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
@@ -31,17 +33,16 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Query\Builder;
-use Carbon\Carbon;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
-
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
/**
* FireflyIII\Models\TransactionGroup
*
- * @property int|string $id
+ * @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at
- * @property int|string $user_id
+ * @property int $user_id
* @property string|null $title
* @property-read Collection|TransactionJournal[] $transactionJournals
* @property-read int|null $transaction_journals_count
@@ -58,14 +59,16 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static \Illuminate\Database\Eloquent\Builder|TransactionGroup whereUserId($value)
* @method static Builder|TransactionGroup withTrashed()
* @method static Builder|TransactionGroup withoutTrashed()
- * @property int|null $user_group_id
+ * @property int $user_group_id
* @method static \Illuminate\Database\Eloquent\Builder|TransactionGroup whereUserGroupId($value)
* @property-read UserGroup|null $userGroup
* @mixin Eloquent
*/
class TransactionGroup extends Model
{
+ use ReturnsIntegerIdTrait;
use SoftDeletes;
+ use ReturnsIntegerUserIdTrait;
protected $casts
diff --git a/app/Models/TransactionJournal.php b/app/Models/TransactionJournal.php
index bbd0c78c3c..048649cb57 100644
--- a/app/Models/TransactionJournal.php
+++ b/app/Models/TransactionJournal.php
@@ -25,9 +25,11 @@ namespace FireflyIII\Models;
use Carbon\Carbon;
use Eloquent;
+use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Builder as EloquentBuilder;
+use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
@@ -37,20 +39,20 @@ use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
-
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
/**
* FireflyIII\Models\TransactionJournal
*
- * @property int|string $id
+ * @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at
- * @property int|string $user_id
- * @property int |string $transaction_type_id
- * @property int|string|null $transaction_group_id
- * @property int|string|null $bill_id
- * @property int|string|null $transaction_currency_id
- * @property string|null $description
+ * @property int $user_id
+ * @property int $transaction_type_id
+ * @property int|string|null $transaction_group_id
+ * @property int|string|null $bill_id
+ * @property int|string|null $transaction_currency_id
+ * @property string|null $description
* @property Carbon $date
* @property Carbon|null $interest_date
* @property Carbon|null $book_date
@@ -114,8 +116,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @method static \Illuminate\Database\Query\Builder|TransactionJournal withoutTrashed()
* @property-read Collection|Location[] $locations
* @property-read int|null $locations_count
- * @property int|string $the_count
- * @property int|null $user_group_id
+ * @property int|string $the_count
+ * @property int $user_group_id
* @method static EloquentBuilder|TransactionJournal whereUserGroupId($value)
* @property-read Collection<int, AuditLogEntry> $auditLogEntries
* @property-read int|null $audit_log_entries_count
@@ -124,7 +126,9 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class TransactionJournal extends Model
{
use HasFactory;
+ use ReturnsIntegerIdTrait;
use SoftDeletes;
+ use ReturnsIntegerUserIdTrait;
protected $casts
@@ -390,4 +394,14 @@ class TransactionJournal extends Model
{
return $this->hasMany(Transaction::class);
}
+
+ /**
+ * @return Attribute
+ */
+ protected function transactionTypeId(): Attribute
+ {
+ return Attribute::make(
+ get: static fn($value) => (int)$value,
+ );
+ }
}
diff --git a/app/Models/TransactionJournalLink.php b/app/Models/TransactionJournalLink.php
index 7ce69ed427..2c64cbf33d 100644
--- a/app/Models/TransactionJournalLink.php
+++ b/app/Models/TransactionJournalLink.php
@@ -26,19 +26,20 @@ namespace FireflyIII\Models;
use Carbon\Carbon;
use Eloquent;
use Illuminate\Database\Eloquent\Builder;
+use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\MorphMany;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
-
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
/**
* FireflyIII\Models\TransactionJournalLink
*
- * @property int|string $id
+ * @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
- * @property string|int $link_type_id
+ * @property int $link_type_id
* @property int $source_id
* @property int $destination_id
* @property string|null $comment
@@ -63,6 +64,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
*/
class TransactionJournalLink extends Model
{
+ use ReturnsIntegerIdTrait;
protected $casts
= [
@@ -129,4 +131,32 @@ class TransactionJournalLink extends Model
{
return $this->belongsTo(TransactionJournal::class, 'source_id');
}
+ /**
+ * @return Attribute
+ */
+ protected function linkTypeId(): Attribute
+ {
+ return Attribute::make(
+ get: static fn($value) => (int)$value,
+ );
+ }
+
+ /**
+ * @return Attribute
+ */
+ protected function sourceId(): Attribute
+ {
+ return Attribute::make(
+ get: static fn($value) => (int)$value,
+ );
+ }
+ /**
+ * @return Attribute
+ */
+ protected function destinationId(): Attribute
+ {
+ return Attribute::make(
+ get: static fn($value) => (int)$value,
+ );
+ }
}
diff --git a/app/Models/TransactionJournalMeta.php b/app/Models/TransactionJournalMeta.php
index c8631a80de..254c4843d6 100644
--- a/app/Models/TransactionJournalMeta.php
+++ b/app/Models/TransactionJournalMeta.php
@@ -23,20 +23,21 @@ declare(strict_types=1);
namespace FireflyIII\Models;
+use Carbon\Carbon;
use Eloquent;
+use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Query\Builder;
-use Carbon\Carbon;
-
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
/**
* FireflyIII\Models\TransactionJournalMeta
*
- * @property int|string $id
+ * @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
- * @property int|string $transaction_journal_id
+ * @property int $transaction_journal_id
* @property string $name
* @property mixed $data
* @property string $hash
@@ -60,6 +61,7 @@ use Carbon\Carbon;
*/
class TransactionJournalMeta extends Model
{
+ use ReturnsIntegerIdTrait;
use SoftDeletes;
@@ -103,4 +105,13 @@ class TransactionJournalMeta extends Model
{
return $this->belongsTo(TransactionJournal::class);
}
+ /**
+ * @return Attribute
+ */
+ protected function transactionJournalId(): Attribute
+ {
+ return Attribute::make(
+ get: static fn($value) => (int)$value,
+ );
+ }
}
diff --git a/app/Models/TransactionType.php b/app/Models/TransactionType.php
index ae4748125b..2d7e8faab6 100644
--- a/app/Models/TransactionType.php
+++ b/app/Models/TransactionType.php
@@ -23,19 +23,19 @@ declare(strict_types=1);
namespace FireflyIII\Models;
+use Carbon\Carbon;
use Eloquent;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Query\Builder;
-use Carbon\Carbon;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
-
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
/**
* FireflyIII\Models\TransactionType
*
- * @property int|string $id
+ * @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at
@@ -57,6 +57,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
*/
class TransactionType extends Model
{
+ use ReturnsIntegerIdTrait;
use SoftDeletes;
public const DEPOSIT = 'Deposit';
diff --git a/app/Models/UserGroup.php b/app/Models/UserGroup.php
index 5f15cff459..a358435d3c 100644
--- a/app/Models/UserGroup.php
+++ b/app/Models/UserGroup.php
@@ -24,6 +24,7 @@ declare(strict_types=1);
namespace FireflyIII\Models;
+use Carbon\Carbon;
use Eloquent;
use FireflyIII\Enums\UserRoleEnum;
use FireflyIII\User;
@@ -33,13 +34,12 @@ use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
-use Carbon\Carbon;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
-
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
/**
* Class UserGroup
*
- * @property int|string $id
+ * @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property string|null $deleted_at
@@ -92,6 +92,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
*/
class UserGroup extends Model
{
+ use ReturnsIntegerIdTrait;
+
protected $fillable = ['title'];
/**
diff --git a/app/Models/UserRole.php b/app/Models/UserRole.php
index fcad8e0632..9054cbbd70 100644
--- a/app/Models/UserRole.php
+++ b/app/Models/UserRole.php
@@ -24,17 +24,17 @@ declare(strict_types=1);
namespace FireflyIII\Models;
+use Carbon\Carbon;
use Eloquent;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
-use Carbon\Carbon;
-
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
/**
* Class UserRole
*
- * @property int|string $id
+ * @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property string|null $deleted_at
@@ -53,6 +53,8 @@ use Carbon\Carbon;
*/
class UserRole extends Model
{
+ use ReturnsIntegerIdTrait;
+
protected $fillable = ['title'];
/**
diff --git a/app/Models/Webhook.php b/app/Models/Webhook.php
index 7632104812..343cb13bf5 100644
--- a/app/Models/Webhook.php
+++ b/app/Models/Webhook.php
@@ -23,10 +23,12 @@ declare(strict_types=1);
namespace FireflyIII\Models;
+use Carbon\Carbon;
use Eloquent;
use FireflyIII\Enums\WebhookDelivery;
use FireflyIII\Enums\WebhookResponse;
use FireflyIII\Enums\WebhookTrigger;
+use FireflyIII\Support\Models\ReturnsIntegerUserIdTrait;
use FireflyIII\User;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
@@ -34,17 +36,16 @@ use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;
-use Carbon\Carbon;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
-
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
/**
* FireflyIII\Models\Webhook
*
- * @property int|string $id
+ * @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property Carbon|null $deleted_at
- * @property int|string $user_id
+ * @property int $user_id
* @property bool $active
* @property int $trigger
* @property int $response
@@ -73,13 +74,15 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @property string $secret
* @method static Builder|Webhook whereSecret($value)
* @method static Builder|Webhook whereTitle($value)
- * @property int|null $user_group_id
+ * @property int $user_group_id
* @method static Builder|Webhook whereUserGroupId($value)
* @mixin Eloquent
*/
class Webhook extends Model
{
+ use ReturnsIntegerIdTrait;
use SoftDeletes;
+ use ReturnsIntegerUserIdTrait;
protected $casts
= [
diff --git a/app/Models/WebhookAttempt.php b/app/Models/WebhookAttempt.php
index cf7f943388..666ef81f5f 100644
--- a/app/Models/WebhookAttempt.php
+++ b/app/Models/WebhookAttempt.php
@@ -23,24 +23,25 @@ declare(strict_types=1);
namespace FireflyIII\Models;
+use Carbon\Carbon;
use Eloquent;
use FireflyIII\User;
+use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Query\Builder;
-use Carbon\Carbon;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
-
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
/**
* Class WebhookAttempt
*
- * @property int|string $id
+ * @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property string|null $deleted_at
- * @property int|string $webhook_message_id
- * @property int|string $status_code
+ * @property int $webhook_message_id
+ * @property int|string $status_code
* @property string|null $logs
* @property string|null $response
* @property-read WebhookMessage $webhookMessage
@@ -62,6 +63,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
*/
class WebhookAttempt extends Model
{
+ use ReturnsIntegerIdTrait;
use SoftDeletes;
/**
@@ -94,4 +96,14 @@ class WebhookAttempt extends Model
{
return $this->belongsTo(WebhookMessage::class);
}
+
+ /**
+ * @return Attribute
+ */
+ protected function webhookMessageId(): Attribute
+ {
+ return Attribute::make(
+ get: static fn($value) => (int)$value,
+ );
+ }
}
diff --git a/app/Models/WebhookMessage.php b/app/Models/WebhookMessage.php
index d047b0ada3..4abf57bf24 100644
--- a/app/Models/WebhookMessage.php
+++ b/app/Models/WebhookMessage.php
@@ -33,15 +33,15 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Carbon\Carbon;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
-
+use FireflyIII\Support\Models\ReturnsIntegerIdTrait;
/**
* FireflyIII\Models\WebhookMessage
*
- * @property int|string $id
+ * @property int $id
* @property Carbon|null $created_at
* @property Carbon|null $updated_at
* @property string|null $deleted_at
- * @property int|string $webhook_id
+ * @property int $webhook_id
* @property bool $sent
* @property bool $errored
* @property int $attempts
@@ -69,6 +69,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
*/
class WebhookMessage extends Model
{
+ use ReturnsIntegerIdTrait;
+
protected $casts
= [
'sent' => 'boolean',
@@ -128,4 +130,14 @@ class WebhookMessage extends Model
get: static fn ($value) => (bool)$value,
);
}
+
+ /**
+ * @return Attribute
+ */
+ protected function webhookId(): Attribute
+ {
+ return Attribute::make(
+ get: static fn($value) => (int)$value,
+ );
+ }
}
diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php
index e8d357ffe2..16130185a2 100644
--- a/app/Repositories/Account/AccountRepository.php
+++ b/app/Repositories/Account/AccountRepository.php
@@ -363,7 +363,7 @@ class AccountRepository implements AccountRepositoryInterface
return null;
}
- return (string)$transaction->amount;
+ return $transaction->amount;
}
/**
@@ -635,6 +635,7 @@ class AccountRepository implements AccountRepositoryInterface
*/
public function oldestJournal(Account $account): ?TransactionJournal
{
+ /** @var TransactionJournal|null $first */
$first = $account->transactions()
->leftJoin('transaction_journals', 'transaction_journals.id', '=', 'transactions.transaction_journal_id')
->orderBy('transaction_journals.date', 'ASC')
@@ -643,7 +644,7 @@ class AccountRepository implements AccountRepositoryInterface
->orderBy('transaction_journals.id', 'ASC')
->first(['transaction_journals.id']);
if (null !== $first) {
- return TransactionJournal::find((int)$first->id);
+ return TransactionJournal::find($first->id);
}
return null;
diff --git a/app/Repositories/Bill/BillRepository.php b/app/Repositories/Bill/BillRepository.php
index 59f212f5a0..f1621a009d 100644
--- a/app/Repositories/Bill/BillRepository.php
+++ b/app/Repositories/Bill/BillRepository.php
@@ -633,8 +633,8 @@ class BillRepository implements BillRepositoryInterface
/** @var Transaction|null $sourceTransaction */
$sourceTransaction = $transactionJournal->transactions()->where('amount', '<', 0)->first();
if (null !== $sourceTransaction) {
- $amount = (string)$sourceTransaction->amount;
- if ((int)$sourceTransaction->foreign_currency_id === (int)$currency->id) {
+ $amount = $sourceTransaction->amount;
+ if ((int)$sourceTransaction->foreign_currency_id === $currency->id) {
// use foreign amount instead!
$amount = (string)$sourceTransaction->foreign_amount;
}
diff --git a/app/Repositories/Budget/AvailableBudgetRepository.php b/app/Repositories/Budget/AvailableBudgetRepository.php
index 61c1930715..69f130ad5d 100644
--- a/app/Repositories/Budget/AvailableBudgetRepository.php
+++ b/app/Repositories/Budget/AvailableBudgetRepository.php
@@ -134,12 +134,13 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
public function getAvailableBudget(TransactionCurrency $currency, Carbon $start, Carbon $end): string
{
$amount = '0';
+ /** @var AvailableBudget|null $availableBudget */
$availableBudget = $this->user->availableBudgets()
->where('transaction_currency_id', $currency->id)
->where('start_date', $start->format('Y-m-d'))
->where('end_date', $end->format('Y-m-d'))->first();
if (null !== $availableBudget) {
- $amount = (string)$availableBudget->amount;
+ $amount = $availableBudget->amount;
}
return $amount;
diff --git a/app/Repositories/Budget/BudgetRepository.php b/app/Repositories/Budget/BudgetRepository.php
index b2451853f8..ce578dcc0f 100644
--- a/app/Repositories/Budget/BudgetRepository.php
+++ b/app/Repositories/Budget/BudgetRepository.php
@@ -114,24 +114,24 @@ class BudgetRepository implements BudgetRepositoryInterface
];
// same period
if ($limit->start_date->isSameDay($start) && $limit->end_date->isSameDay($end)) {
- $return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], (string)$limit->amount);
+ $return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], $limit->amount);
app('log')->debug(sprintf('Add full amount [1]: %s', $limit->amount));
continue;
}
// limit is inside of date range
if ($start->lte($limit->start_date) && $end->gte($limit->end_date)) {
- $return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], (string)$limit->amount);
+ $return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], $limit->amount);
app('log')->debug(sprintf('Add full amount [2]: %s', $limit->amount));
continue;
}
$total = $limit->start_date->diffInDays($limit->end_date) + 1; // include the day itself.
$days = $this->daysInOverlap($limit, $start, $end);
- $amount = bcmul(bcdiv((string)$limit->amount, (string)$total), (string)$days);
+ $amount = bcmul(bcdiv($limit->amount, (string)$total), (string)$days);
$return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], $amount);
app('log')->debug(
sprintf(
'Amount per day: %s (%s over %d days). Total amount for %d days: %s',
- bcdiv((string)$limit->amount, (string)$total),
+ bcdiv($limit->amount, (string)$total),
$limit->amount,
$total,
$days,
@@ -230,24 +230,24 @@ class BudgetRepository implements BudgetRepositoryInterface
];
// same period
if ($limit->start_date->isSameDay($start) && $limit->end_date->isSameDay($end)) {
- $return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], (string)$limit->amount);
+ $return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], $limit->amount);
app('log')->debug(sprintf('Add full amount [1]: %s', $limit->amount));
continue;
}
// limit is inside of date range
if ($start->lte($limit->start_date) && $end->gte($limit->end_date)) {
- $return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], (string)$limit->amount);
+ $return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], $limit->amount);
app('log')->debug(sprintf('Add full amount [2]: %s', $limit->amount));
continue;
}
$total = $limit->start_date->diffInDays($limit->end_date) + 1; // include the day itself.
$days = $this->daysInOverlap($limit, $start, $end);
- $amount = bcmul(bcdiv((string)$limit->amount, (string)$total), (string)$days);
+ $amount = bcmul(bcdiv($limit->amount, (string)$total), (string)$days);
$return[$currency->id]['sum'] = bcadd($return[$currency->id]['sum'], $amount);
app('log')->debug(
sprintf(
'Amount per day: %s (%s over %d days). Total amount for %d days: %s',
- bcdiv((string)$limit->amount, (string)$total),
+ bcdiv($limit->amount, (string)$total),
$limit->amount,
$total,
$days,
@@ -489,8 +489,8 @@ class BudgetRepository implements BudgetRepositoryInterface
$budgets = $this->getBudgets();
/** @var Budget $budget */
foreach ($budgets as $budget) {
- DB::table('budget_transaction')->where('budget_id', (int)$budget->id)->delete();
- DB::table('budget_transaction_journal')->where('budget_id', (int)$budget->id)->delete();
+ 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')->where('value', (string)$budget->id)->delete();
RuleAction::where('action_type', 'set_budget')->where('action_value', (string)$budget->id)->delete();
$budget->delete();
diff --git a/app/Repositories/Budget/OperationsRepository.php b/app/Repositories/Budget/OperationsRepository.php
index 6bb1fa70eb..22ddc55675 100644
--- a/app/Repositories/Budget/OperationsRepository.php
+++ b/app/Repositories/Budget/OperationsRepository.php
@@ -58,7 +58,7 @@ class OperationsRepository implements OperationsRepositoryInterface
foreach ($budget->budgetlimits as $limit) {
$diff = $limit->start_date->diffInDays($limit->end_date);
$diff = 0 === $diff ? 1 : $diff;
- $amount = (string)$limit->amount;
+ $amount = $limit->amount;
$perDay = bcdiv($amount, (string)$diff);
$total = bcadd($total, $perDay);
$count++;
diff --git a/app/Repositories/PiggyBank/ModifiesPiggyBanks.php b/app/Repositories/PiggyBank/ModifiesPiggyBanks.php
index 6205206882..e505044ff7 100644
--- a/app/Repositories/PiggyBank/ModifiesPiggyBanks.php
+++ b/app/Repositories/PiggyBank/ModifiesPiggyBanks.php
@@ -119,7 +119,7 @@ trait ModifiesPiggyBanks
{
$today = today(config('app.timezone'));
$leftOnAccount = $this->leftOnAccount($piggyBank, $today);
- $savedSoFar = (string)$this->getRepetition($piggyBank)->currentamount;
+ $savedSoFar = $this->getRepetition($piggyBank)->currentamount;
$maxAmount = $leftOnAccount;
$leftToSave = null;
if (0 !== bccomp($piggyBank->targetamount, '0')) {
diff --git a/app/Repositories/PiggyBank/PiggyBankRepository.php b/app/Repositories/PiggyBank/PiggyBankRepository.php
index a1e95044ba..8976aa4bc5 100644
--- a/app/Repositories/PiggyBank/PiggyBankRepository.php
+++ b/app/Repositories/PiggyBank/PiggyBankRepository.php
@@ -146,7 +146,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
return '0';
}
- return (string)$rep->currentamount;
+ return $rep->currentamount;
}
/**
@@ -225,11 +225,11 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
// currency of the account + the piggy bank currency are almost the same.
// which amount from the transaction matches?
$amount = null;
- if ((int)$source->transaction_currency_id === (int)$currency->id) {
+ if ((int)$source->transaction_currency_id === $currency->id) {
app('log')->debug('Use normal amount');
$amount = app('steam')->$operator($source->amount); // @phpstan-ignore-line
}
- if ((int)$source->foreign_currency_id === (int)$currency->id) {
+ if ((int)$source->foreign_currency_id === $currency->id) {
app('log')->debug('Use foreign amount');
$amount = app('steam')->$operator($source->foreign_amount); // @phpstan-ignore-line
}
@@ -240,10 +240,10 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
}
app('log')->debug(sprintf('The currency is %s and the amount is %s', $currency->code, $amount));
- $room = bcsub((string)$piggyBank->targetamount, (string)$repetition->currentamount);
+ $room = bcsub($piggyBank->targetamount, $repetition->currentamount);
$compare = bcmul($repetition->currentamount, '-1');
- if (bccomp((string)$piggyBank->targetamount, '0') === 0) {
+ if (bccomp($piggyBank->targetamount, '0') === 0) {
// amount is zero? then the "room" is positive amount of we wish to add or remove.
$room = app('steam')->positive($amount);
app('log')->debug(sprintf('Room is now %s', $room));
diff --git a/app/Repositories/Rule/RuleRepository.php b/app/Repositories/Rule/RuleRepository.php
index 3815e05251..6e7a96e799 100644
--- a/app/Repositories/Rule/RuleRepository.php
+++ b/app/Repositories/Rule/RuleRepository.php
@@ -376,8 +376,8 @@ class RuleRepository implements RuleRepositoryInterface
*/
public function setOrder(Rule $rule, int $newOrder): void
{
- $oldOrder = (int)$rule->order;
- $groupId = (int)$rule->rule_group_id;
+ $oldOrder = $rule->order;
+ $groupId = $rule->rule_group_id;
$maxOrder = $this->maxOrder($rule->ruleGroup);
$newOrder = $newOrder > $maxOrder ? $maxOrder + 1 : $newOrder;
app('log')->debug(sprintf('New order will be %d', $newOrder));
diff --git a/app/Repositories/RuleGroup/RuleGroupRepository.php b/app/Repositories/RuleGroup/RuleGroupRepository.php
index c3e42d60b3..58ca9afa0f 100644
--- a/app/Repositories/RuleGroup/RuleGroupRepository.php
+++ b/app/Repositories/RuleGroup/RuleGroupRepository.php
@@ -151,7 +151,7 @@ class RuleGroupRepository implements RuleGroupRepositoryInterface
$count = 1;
/** @var Rule $entry */
foreach ($set as $entry) {
- if ((int)$entry->order !== $count) {
+ if ($entry->order !== $count) {
app('log')->debug(sprintf('Rule #%d was on spot %d but must be on spot %d', $entry->id, $entry->order, $count));
$entry->order = $count;
$entry->save();
diff --git a/app/Repositories/TransactionGroup/TransactionGroupRepository.php b/app/Repositories/TransactionGroup/TransactionGroupRepository.php
index 4d22bdc832..4548182dfc 100644
--- a/app/Repositories/TransactionGroup/TransactionGroupRepository.php
+++ b/app/Repositories/TransactionGroup/TransactionGroupRepository.php
@@ -175,7 +175,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
$result = [];
/** @var Attachment $attachment */
foreach ($set as $attachment) {
- $journalId = (int)$attachment->attachable_id;
+ $journalId = $attachment->attachable_id;
$result[$journalId] = $result[$journalId] ?? [];
$current = $attachment->toArray();
$current['file_exists'] = true;
@@ -417,7 +417,7 @@ class TransactionGroupRepository implements TransactionGroupRepositoryInterface
if (null !== $currencyPreference) {
$currency = TransactionCurrency::where('id', $currencyPreference->data)->first();
}
- $journalId = (int)$row->transaction_journal_id;
+ $journalId = $row->transaction_journal_id;
$return[$journalId] = $return[$journalId] ?? [];
$return[$journalId][] = [
diff --git a/app/Repositories/UserGroup/UserGroupRepository.php b/app/Repositories/UserGroup/UserGroupRepository.php
index 3df3d341bf..a5fcc65dcd 100644
--- a/app/Repositories/UserGroup/UserGroupRepository.php
+++ b/app/Repositories/UserGroup/UserGroupRepository.php
@@ -225,7 +225,7 @@ class UserGroupRepository implements UserGroupRepositoryInterface
// if it's 1:
if (1 === $membershipCount) {
- $lastUserId = (int)$userGroup->groupMemberships()->distinct()->first(['group_memberships.user_id'])->user_id;
+ $lastUserId = $userGroup->groupMemberships()->distinct()->first(['group_memberships.user_id'])->user_id;
// if this is also the user we're editing right now, and we remove all of their roles:
if ($lastUserId === (int)$user->id && 0 === count($data['roles'])) {
app('log')->debug('User is last in this group, refuse to act');
diff --git a/app/Repositories/UserGroups/Bill/BillRepository.php b/app/Repositories/UserGroups/Bill/BillRepository.php
index b6a4bd27c5..626b60a1ca 100644
--- a/app/Repositories/UserGroups/Bill/BillRepository.php
+++ b/app/Repositories/UserGroups/Bill/BillRepository.php
@@ -81,7 +81,7 @@ class BillRepository implements BillRepositoryInterface
/** @var Collection $set */
$set = $bill->transactionJournals()->after($start)->before($end)->get(['transaction_journals.*']);
$currency = $bill->transactionCurrency;
- $currencyId = (int)$bill->transaction_currency_id;
+ $currencyId = $bill->transaction_currency_id;
$return[$currencyId] = $return[$currencyId] ?? [
'currency_id' => (string)$currency->id,
@@ -103,18 +103,18 @@ class BillRepository implements BillRepositoryInterface
/** @var Transaction|null $sourceTransaction */
$sourceTransaction = $transactionJournal->transactions()->where('amount', '<', 0)->first();
if (null !== $sourceTransaction) {
- $amount = (string)$sourceTransaction->amount;
- if ((int)$sourceTransaction->foreign_currency_id === (int)$currency->id) {
+ $amount = $sourceTransaction->amount;
+ if ((int)$sourceTransaction->foreign_currency_id === $currency->id) {
// use foreign amount instead!
$amount = (string)$sourceTransaction->foreign_amount;
}
// convert to native currency
$nativeAmount = $amount;
- if ($currencyId !== (int)$default->id) {
+ if ($currencyId !== $default->id) {
// get rate and convert.
$nativeAmount = $converter->convert($currency, $default, $transactionJournal->date, $amount);
}
- if ((int)$sourceTransaction->foreign_currency_id === (int)$default->id) {
+ if ((int)$sourceTransaction->foreign_currency_id === $default->id) {
// ignore conversion, use foreign amount
$nativeAmount = (string)$sourceTransaction->foreign_amount;
}
@@ -154,7 +154,7 @@ class BillRepository implements BillRepositoryInterface
if ($total > 0) {
$currency = $bill->transactionCurrency;
- $currencyId = (int)$bill->transaction_currency_id;
+ $currencyId = $bill->transaction_currency_id;
$average = bcdiv(bcadd($bill->amount_max, $bill->amount_min), '2');
$nativeAverage = $converter->convert($currency, $default, $start, $average);
$return[$currencyId] = $return[$currencyId] ?? [
diff --git a/app/Repositories/UserGroups/Budget/AvailableBudgetRepository.php b/app/Repositories/UserGroups/Budget/AvailableBudgetRepository.php
index 29748532eb..f32da21d50 100644
--- a/app/Repositories/UserGroups/Budget/AvailableBudgetRepository.php
+++ b/app/Repositories/UserGroups/Budget/AvailableBudgetRepository.php
@@ -53,7 +53,7 @@ class AvailableBudgetRepository implements AvailableBudgetRepositoryInterface
->where('end_date', $end->format('Y-m-d'))->get();
/** @var AvailableBudget $availableBudget */
foreach ($availableBudgets as $availableBudget) {
- $currencyId = (int)$availableBudget->transaction_currency_id;
+ $currencyId = $availableBudget->transaction_currency_id;
$return[$currencyId] = $return[$currencyId] ?? [
'currency_id' => $currencyId,
'currency_code' => $availableBudget->transactionCurrency->code,
diff --git a/app/Repositories/UserGroups/Currency/CurrencyRepository.php b/app/Repositories/UserGroups/Currency/CurrencyRepository.php
index 1af2ea506c..27cb8dbe0c 100644
--- a/app/Repositories/UserGroups/Currency/CurrencyRepository.php
+++ b/app/Repositories/UserGroups/Currency/CurrencyRepository.php
@@ -113,7 +113,7 @@ class CurrencyRepository implements CurrencyRepositoryInterface
// is being used in accounts (as integer)
$meta = AccountMeta::leftJoin('accounts', 'accounts.id', '=', 'account_meta.account_id')
->whereNull('accounts.deleted_at')
- ->where('account_meta.name', 'currency_id')->where('account_meta.data', json_encode((int)$currency->id))->count();
+ ->where('account_meta.name', 'currency_id')->where('account_meta.data', json_encode($currency->id))->count();
if ($meta > 0) {
app('log')->info(sprintf('Used in %d accounts as currency_id, return true. ', $meta));
@@ -181,10 +181,10 @@ class CurrencyRepository implements CurrencyRepositoryInterface
$local = $this->get();
return $all->map(static function (TransactionCurrency $current) use ($local) {
$hasId = $local->contains(static function (TransactionCurrency $entry) use ($current) {
- return (int)$entry->id === (int)$current->id;
+ return $entry->id === $current->id;
});
$isDefault = $local->contains(static function (TransactionCurrency $entry) use ($current) {
- return 1 === (int)$entry->pivot->group_default && (int)$entry->id === (int)$current->id;
+ return 1 === (int)$entry->pivot->group_default && $entry->id === $current->id;
});
$current->userEnabled = $hasId;
$current->userDefault = $isDefault;
diff --git a/app/Services/Internal/Destroy/AccountDestroyService.php b/app/Services/Internal/Destroy/AccountDestroyService.php
index 1cd34e6295..c736265d01 100644
--- a/app/Services/Internal/Destroy/AccountDestroyService.php
+++ b/app/Services/Internal/Destroy/AccountDestroyService.php
@@ -81,7 +81,7 @@ class AccountDestroyService
->where('transaction_types.type', TransactionType::OPENING_BALANCE)
->get(['transactions.transaction_journal_id']);
if ($set->count() > 0) {
- $journalId = (int)$set->first()->transaction_journal_id;
+ $journalId = $set->first()->transaction_journal_id;
app('log')->debug(sprintf('Found opening balance journal with ID #%d', $journalId));
// get transactions with this journal (should be just one):
@@ -129,7 +129,7 @@ class AccountDestroyService
/** @var stdClass $row */
foreach ($collection as $row) {
if ((int)$row->the_count > 1) {
- $journalId = (int)$row->transaction_journal_id;
+ $journalId = $row->transaction_journal_id;
$journal = $user->transactionJournals()->find($journalId);
if (null !== $journal) {
app('log')->debug(sprintf('Deleted journal #%d because it has the same source as destination.', $journal->id));
diff --git a/app/Services/Internal/Destroy/BudgetDestroyService.php b/app/Services/Internal/Destroy/BudgetDestroyService.php
index d9675f743a..29856c8773 100644
--- a/app/Services/Internal/Destroy/BudgetDestroyService.php
+++ b/app/Services/Internal/Destroy/BudgetDestroyService.php
@@ -46,10 +46,10 @@ class BudgetDestroyService
}
// also delete all relations between categories and transaction journals:
- DB::table('budget_transaction_journal')->where('budget_id', (int)$budget->id)->delete();
+ DB::table('budget_transaction_journal')->where('budget_id', $budget->id)->delete();
// also delete all relations between categories and transactions:
- DB::table('budget_transaction')->where('budget_id', (int)$budget->id)->delete();
+ DB::table('budget_transaction')->where('budget_id', $budget->id)->delete();
// also delete all budget limits
foreach ($budget->budgetlimits()->get() as $limit) {
diff --git a/app/Services/Internal/Destroy/CategoryDestroyService.php b/app/Services/Internal/Destroy/CategoryDestroyService.php
index 36c2f74ef4..15daf3d6e2 100644
--- a/app/Services/Internal/Destroy/CategoryDestroyService.php
+++ b/app/Services/Internal/Destroy/CategoryDestroyService.php
@@ -41,10 +41,10 @@ class CategoryDestroyService
$category->delete();
// also delete all relations between categories and transaction journals:
- DB::table('category_transaction_journal')->where('category_id', (int)$category->id)->delete();
+ DB::table('category_transaction_journal')->where('category_id', $category->id)->delete();
// also delete all relations between categories and transactions:
- DB::table('category_transaction')->where('category_id', (int)$category->id)->delete();
+ DB::table('category_transaction')->where('category_id', $category->id)->delete();
// delete references to category from recurring transactions.
DB::table('rt_meta')->where('name', 'category_id')->where('value', $category->id)->delete();
diff --git a/app/Services/Internal/Support/CreditRecalculateService.php b/app/Services/Internal/Support/CreditRecalculateService.php
index 7ee64b67c8..6a06a40982 100644
--- a/app/Services/Internal/Support/CreditRecalculateService.php
+++ b/app/Services/Internal/Support/CreditRecalculateService.php
@@ -238,7 +238,7 @@ class CreditRecalculateService
$source = $openingBalance->transactions()->where('amount', '<', 0)->first();
/** @var Transaction $dest */
$dest = $openingBalance->transactions()->where('amount', '>', 0)->first();
- if ((int)$source->account_id !== $account->id) {
+ if ($source->account_id !== $account->id) {
app('log')->info(sprintf('Liability #%d has a reversed opening balance. Will fix this now.', $account->id));
app('log')->debug(sprintf('Source amount "%s" is now "%s"', $source->amount, app('steam')->positive($source->amount)));
app('log')->debug(sprintf('Destination amount "%s" is now "%s"', $dest->amount, app('steam')->negative($dest->amount)));
@@ -307,7 +307,7 @@ class CreditRecalculateService
// because we're lending person X more money
if (
$type === TransactionType::WITHDRAWAL
- && (int)$account->id === (int)$transaction->account_id
+ && $account->id === $transaction->account_id
&& 1 === bccomp($usedAmount, '0')
&& 'credit' === $direction
) {
@@ -323,7 +323,7 @@ class CreditRecalculateService
// because we're sending money away from the loan (like loan forgiveness)
if (
$type === TransactionType::WITHDRAWAL
- && (int)$account->id === (int)$sourceTransaction->account_id
+ && $account->id === $sourceTransaction->account_id
&& -1 === bccomp($usedAmount, '0')
&& 'credit' === $direction
) {
@@ -339,7 +339,7 @@ class CreditRecalculateService
// because the person is paying us back.
if (
$type === TransactionType::DEPOSIT
- && (int)$account->id === (int)$transaction->account_id
+ && $account->id === $transaction->account_id
&& -1 === bccomp($usedAmount, '0')
&& 'credit' === $direction
) {
@@ -355,7 +355,7 @@ class CreditRecalculateService
// because the person is having to pay more money.
if (
$type === TransactionType::DEPOSIT
- && (int)$account->id === (int)$destTransaction->account_id
+ && $account->id === $destTransaction->account_id
&& 1 === bccomp($usedAmount, '0')
&& 'credit' === $direction
) {
@@ -369,7 +369,7 @@ class CreditRecalculateService
// because the person has to pay more back.
if (
$type === TransactionType::TRANSFER
- && (int)$account->id === (int)$destTransaction->account_id
+ && $account->id === $destTransaction->account_id
&& 1 === bccomp($usedAmount, '0')
&& 'credit' === $direction
) {
@@ -384,7 +384,7 @@ class CreditRecalculateService
// because we're paying off the debt
if (
$type === TransactionType::WITHDRAWAL
- && (int)$account->id === (int)$transaction->account_id
+ && $account->id === $transaction->account_id
&& 1 === bccomp($usedAmount, '0')
&& 'debit' === $direction
) {
@@ -399,7 +399,7 @@ class CreditRecalculateService
// because we are borrowing more money.
if (
$type === TransactionType::DEPOSIT
- && (int)$account->id === (int)$transaction->account_id
+ && $account->id === $transaction->account_id
&& -1 === bccomp($usedAmount, '0')
&& 'debit' === $direction
) {
@@ -414,7 +414,7 @@ class CreditRecalculateService
// because we are paying interest.
if (
$type === TransactionType::WITHDRAWAL
- && (int)$account->id === (int)$transaction->account_id
+ && $account->id === $transaction->account_id
&& -1 === bccomp($usedAmount, '0')
&& 'debit' === $direction
) {
diff --git a/app/Services/Internal/Support/JournalServiceTrait.php b/app/Services/Internal/Support/JournalServiceTrait.php
index dc9743d1da..4a98462f70 100644
--- a/app/Services/Internal/Support/JournalServiceTrait.php
+++ b/app/Services/Internal/Support/JournalServiceTrait.php
@@ -490,7 +490,7 @@ trait JournalServiceTrait
if ('' !== $string) {
$tag = $this->tagFactory->findOrCreate($string);
if (null !== $tag) {
- $set[] = (int)$tag->id;
+ $set[] = $tag->id;
}
}
}
diff --git a/app/Services/Internal/Update/AccountUpdateService.php b/app/Services/Internal/Update/AccountUpdateService.php
index 13788b490a..6932751ba7 100644
--- a/app/Services/Internal/Update/AccountUpdateService.php
+++ b/app/Services/Internal/Update/AccountUpdateService.php
@@ -250,7 +250,7 @@ class AccountUpdateService
foreach ($array as $type) {
/** @var AccountType $type */
$type = AccountType::whereType($type)->first();
- $return[] = (int)$type->id;
+ $return[] = $type->id;
}
return $return;
@@ -340,7 +340,7 @@ class AccountUpdateService
$array = $preference->data;
app('log')->debug('Old array is: ', $array);
app('log')->debug(sprintf('Must remove : %d', $account->id));
- $removeAccountId = (int)$account->id;
+ $removeAccountId = $account->id;
$new = [];
foreach ($array as $value) {
if ((int)$value !== $removeAccountId) {
diff --git a/app/Services/Internal/Update/GroupCloneService.php b/app/Services/Internal/Update/GroupCloneService.php
index 7c8f68b709..5cf3734f88 100644
--- a/app/Services/Internal/Update/GroupCloneService.php
+++ b/app/Services/Internal/Update/GroupCloneService.php
@@ -49,7 +49,7 @@ class GroupCloneService
$newGroup = $group->replicate();
$newGroup->save();
foreach ($group->transactionJournals as $journal) {
- $this->cloneJournal($journal, $newGroup, (int)$group->id);
+ $this->cloneJournal($journal, $newGroup, $group->id);
}
return $newGroup;
diff --git a/app/Services/Internal/Update/RecurrenceUpdateService.php b/app/Services/Internal/Update/RecurrenceUpdateService.php
index 078f76d906..0253b7a33e 100644
--- a/app/Services/Internal/Update/RecurrenceUpdateService.php
+++ b/app/Services/Internal/Update/RecurrenceUpdateService.php
@@ -300,7 +300,7 @@ class RecurrenceUpdateService
unset($submitted['currency_id'], $submitted['currency_code']);
}
if (null !== $currency) {
- $submitted['currency_id'] = (int)$currency->id;
+ $submitted['currency_id'] = $currency->id;
}
if (array_key_exists('foreign_currency_id', $submitted) || array_key_exists('foreign_currency_code', $submitted)) {
$foreignCurrency = $currencyFactory->find(
@@ -312,7 +312,7 @@ class RecurrenceUpdateService
unset($submitted['foreign_currency_id'], $currency['foreign_currency_code']);
}
if (null !== $foreignCurrency) {
- $submitted['foreign_currency_id'] = (int)$foreignCurrency->id;
+ $submitted['foreign_currency_id'] = $foreignCurrency->id;
}
// update fields that are part of the recurring transaction itself.
diff --git a/app/Support/Chart/Budget/FrontpageChartGenerator.php b/app/Support/Chart/Budget/FrontpageChartGenerator.php
index 086092da0d..3d681750fc 100644
--- a/app/Support/Chart/Budget/FrontpageChartGenerator.php
+++ b/app/Support/Chart/Budget/FrontpageChartGenerator.php
@@ -159,7 +159,7 @@ class FrontpageChartGenerator
/** @var array $entry */
foreach ($spent as $entry) {
// only spent the entry where the entry's currency matches the budget limit's currency
- if ($entry['currency_id'] === (int)$limit->transaction_currency_id) {
+ if ($entry['currency_id'] === $limit->transaction_currency_id) {
$data = $this->processRow($data, $budget, $limit, $entry);
}
}
diff --git a/app/Support/ExpandedForm.php b/app/Support/ExpandedForm.php
index 4895db91f3..b540fcfa56 100644
--- a/app/Support/ExpandedForm.php
+++ b/app/Support/ExpandedForm.php
@@ -226,7 +226,7 @@ class ExpandedForm
/** @var Eloquent $entry */
foreach ($set as $entry) {
// All Eloquent models have an ID
- $entryId = (int)$entry->id; /** @phpstan-ignore-line */
+ $entryId = $entry->id; /** @phpstan-ignore-line */
$current = $entry->toArray();
$title = null;
foreach ($fields as $field) {
diff --git a/app/Support/Http/Api/ExchangeRateConverter.php b/app/Support/Http/Api/ExchangeRateConverter.php
index 2c48376c35..8e9ec07ed9 100644
--- a/app/Support/Http/Api/ExchangeRateConverter.php
+++ b/app/Support/Http/Api/ExchangeRateConverter.php
@@ -78,12 +78,12 @@ class ExchangeRateConverter
private function getRate(TransactionCurrency $from, TransactionCurrency $to, Carbon $date): string
{
// first attempt:
- $rate = $this->getFromDB((int)$from->id, (int)$to->id, $date->format('Y-m-d'));
+ $rate = $this->getFromDB($from->id, $to->id, $date->format('Y-m-d'));
if (null !== $rate) {
return $rate;
}
// no result. perhaps the other way around?
- $rate = $this->getFromDB((int)$to->id, (int)$from->id, $date->format('Y-m-d'));
+ $rate = $this->getFromDB($to->id, $from->id, $date->format('Y-m-d'));
if (null !== $rate) {
return bcdiv('1', $rate);
}
@@ -151,16 +151,16 @@ class ExchangeRateConverter
private function getEuroRate(TransactionCurrency $currency, Carbon $date): string
{
$euroId = $this->getEuroId();
- if ($euroId === (int)$currency->id) {
+ if ($euroId === $currency->id) {
return '1';
}
- $rate = $this->getFromDB((int)$currency->id, $euroId, $date->format('Y-m-d'));
+ $rate = $this->getFromDB($currency->id, $euroId, $date->format('Y-m-d'));
if (null !== $rate) {
// app('log')->debug(sprintf('Rate for %s to EUR is %s.', $currency->code, $rate));
return $rate;
}
- $rate = $this->getFromDB($euroId, (int)$currency->id, $date->format('Y-m-d'));
+ $rate = $this->getFromDB($euroId, $currency->id, $date->format('Y-m-d'));
if (null !== $rate) {
return bcdiv('1', $rate);
// app('log')->debug(sprintf('Inverted rate for %s to EUR is %s.', $currency->code, $rate));
@@ -194,7 +194,7 @@ class ExchangeRateConverter
if (null === $euro) {
throw new FireflyException('Cannot find EUR in system, cannot do currency conversion.');
}
- $cache->store((int)$euro->id);
- return (int)$euro->id;
+ $cache->store($euro->id);
+ return $euro->id;
}
}
diff --git a/app/Support/Http/Controllers/AugumentData.php b/app/Support/Http/Controllers/AugumentData.php
index c21eb7b3b5..014a802749 100644
--- a/app/Support/Http/Controllers/AugumentData.php
+++ b/app/Support/Http/Controllers/AugumentData.php
@@ -220,7 +220,7 @@ trait AugumentData
$currentStart = clone $entry->start_date;
$currentEnd = clone $entry->end_date;
$expenses = $opsRepository->sumExpenses($currentStart, $currentEnd, null, $budgetCollection, $currency);
- $spent = $expenses[(int)$currency->id]['sum'] ?? '0';
+ $spent = $expenses[$currency->id]['sum'] ?? '0';
$entry->spent = $spent;
$limits->push($entry);
diff --git a/app/Support/Models/ReturnsIntegerIdTrait.php b/app/Support/Models/ReturnsIntegerIdTrait.php
new file mode 100644
index 0000000000..682e39cf99
--- /dev/null
+++ b/app/Support/Models/ReturnsIntegerIdTrait.php
@@ -0,0 +1,44 @@
+<?php
+/*
+ * ReturnsIntegerIdTrait.php
+ * Copyright (c) 2023 [email protected]
+ *
+ * This file is part of Firefly III (https://github.com/firefly-iii).
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+declare(strict_types=1);
+
+namespace FireflyIII\Support\Models;
+
+use Illuminate\Database\Eloquent\Casts\Attribute;
+
+/**
+* Trait ReturnsIntegerIdTrait
+ */
+trait ReturnsIntegerIdTrait
+{
+ /**
+ * Get the ID
+ *
+ * @return Attribute
+ */
+ protected function id(): Attribute
+ {
+ return Attribute::make(
+ get: static fn($value) => (int)$value,
+ );
+ }
+}
diff --git a/app/Support/Models/ReturnsIntegerUserIdTrait.php b/app/Support/Models/ReturnsIntegerUserIdTrait.php
new file mode 100644
index 0000000000..0bc40fe293
--- /dev/null
+++ b/app/Support/Models/ReturnsIntegerUserIdTrait.php
@@ -0,0 +1,54 @@
+<?php
+/*
+ * ReturnsIntegerIdTrait.php
+ * Copyright (c) 2023 [email protected]
+ *
+ * This file is part of Firefly III (https://github.com/firefly-iii).
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+declare(strict_types=1);
+
+namespace FireflyIII\Support\Models;
+
+use Illuminate\Database\Eloquent\Casts\Attribute;
+
+/**
+* Trait ReturnsIntegerUserIdTrait
+ */
+trait ReturnsIntegerUserIdTrait
+{
+ /**
+ * @return Attribute
+ */
+ protected function userId(): Attribute
+ {
+ return Attribute::make(
+ get: static fn($value) => (int)$value,
+ );
+ }
+
+ /**
+ * Get the user group ID
+ *
+ * @return Attribute
+ */
+ protected function userGroupId(): Attribute
+ {
+ return Attribute::make(
+ get: static fn($value) => (int)$value,
+ );
+ }
+}
diff --git a/app/Support/Report/Budget/BudgetReportGenerator.php b/app/Support/Report/Budget/BudgetReportGenerator.php
index 67d8b0d920..69ec468187 100644
--- a/app/Support/Report/Budget/BudgetReportGenerator.php
+++ b/app/Support/Report/Budget/BudgetReportGenerator.php
@@ -168,7 +168,7 @@ class BudgetReportGenerator
*/
private function processBudget(Budget $budget): void
{
- $budgetId = (int)$budget->id;
+ $budgetId = $budget->id;
$this->report['budgets'][$budgetId] = $this->report['budgets'][$budgetId] ?? [
'budget_id' => $budgetId,
'budget_name' => $budget->name,
@@ -192,10 +192,10 @@ class BudgetReportGenerator
*/
private function processLimit(Budget $budget, BudgetLimit $limit): void
{
- $budgetId = (int)$budget->id;
- $limitId = (int)$limit->id;
+ $budgetId = $budget->id;
+ $limitId = $limit->id;
$limitCurrency = $limit->transactionCurrency ?? $this->currency;
- $currencyId = (int)$limitCurrency->id;
+ $currencyId = $limitCurrency->id;
$expenses = $this->opsRepository->sumExpenses($limit->start_date, $limit->end_date, $this->accounts, new Collection([$budget]));
$spent = $expenses[$currencyId]['sum'] ?? '0';
$left = -1 === bccomp(bcadd($limit->amount, $spent), '0') ? '0' : bcadd($limit->amount, $spent);
diff --git a/app/Support/Steam.php b/app/Support/Steam.php
index c741f58a8e..ca8bb33c38 100644
--- a/app/Support/Steam.php
+++ b/app/Support/Steam.php
@@ -136,7 +136,7 @@ class Steam
$repository->setUser($account->user);
$currency = $repository->getAccountCurrency($account) ?? app('amount')->getDefaultCurrencyByUserGroup($account->user->userGroup);
}
- $currencyId = (int)$currency->id;
+ $currencyId = $currency->id;
$start->addDay();
@@ -229,7 +229,7 @@ class Steam
->get(['transactions.foreign_amount'])->toArray();
$foreignBalance = $this->sumTransactions($transactions, 'foreign_amount');
$balance = bcadd($nativeBalance, $foreignBalance);
- $virtual = null === $account->virtual_balance ? '0' : (string)$account->virtual_balance;
+ $virtual = null === $account->virtual_balance ? '0' : $account->virtual_balance;
$balance = bcadd($balance, $virtual);
$cache->store($balance);
@@ -297,7 +297,7 @@ class Steam
$day = Carbon::createFromFormat('Y-m-d H:i:s', $transaction['date'], config('app.timezone'));
$format = $day->format('Y-m-d');
// if the transaction is in the expected currency, change nothing.
- if ((int)$transaction['transaction_currency_id'] === (int)$native->id) {
+ if ((int)$transaction['transaction_currency_id'] === $native->id) {
// change the current balance, set it to today, continue the loop.
$currentBalance = bcadd($currentBalance, $transaction['amount']);
$balances[$format] = $currentBalance;
@@ -305,7 +305,7 @@ class Steam
continue;
}
// if foreign currency is in the expected currency, do nothing:
- if ((int)$transaction['foreign_currency_id'] === (int)$native->id) {
+ if ((int)$transaction['foreign_currency_id'] === $native->id) {
$currentBalance = bcadd($currentBalance, $transaction['foreign_amount']);
$balances[$format] = $currentBalance;
app('log')->debug(sprintf('%s: transaction in %s (foreign), new balance is %s.', $format, $native->code, $currentBalance));
@@ -369,7 +369,7 @@ class Steam
if (null === $currency) {
throw new FireflyException('Cannot get converted account balance: no currency found for account.');
}
- if ((int)$native->id === (int)$currency->id) {
+ if ($native->id === $currency->id) {
return $this->balance($account, $date);
}
/**
@@ -466,7 +466,7 @@ class Steam
}
// add virtual balance (also needs conversion)
- $virtual = null === $account->virtual_balance ? '0' : (string)$account->virtual_balance;
+ $virtual = null === $account->virtual_balance ? '0' : $account->virtual_balance;
$virtual = $converter->convert($currency, $native, $account->created_at, $virtual);
$balance = bcadd($balance, $virtual);
@@ -535,7 +535,7 @@ class Steam
/** @var Account $account */
foreach ($accounts as $account) {
$default = app('amount')->getDefaultCurrencyByUserGroup($account->user->userGroup);
- $result[(int)$account->id]
+ $result[$account->id]
= [
'balance' => $this->balance($account, $date),
'native_balance' => $this->balanceConverted($account, $date, $default),
@@ -735,10 +735,11 @@ class Steam
->groupBy(['transactions.account_id', 'transaction_journals.user_id'])
->get(['transactions.account_id', DB::raw('MAX(transaction_journals.date) AS max_date')]);
+ /** @var Transaction $entry */
foreach ($set as $entry) {
$date = new Carbon($entry->max_date, config('app.timezone'));
$date->setTimezone(config('app.timezone'));
- $list[(int)$entry->account_id] = $date;
+ $list[$entry->account_id] = $date;
}
return $list;
diff --git a/app/TransactionRules/Actions/ConvertToTransfer.php b/app/TransactionRules/Actions/ConvertToTransfer.php
index b4720bc2e7..704d63c637 100644
--- a/app/TransactionRules/Actions/ConvertToTransfer.php
+++ b/app/TransactionRules/Actions/ConvertToTransfer.php
@@ -75,7 +75,7 @@ class ConvertToTransfer implements ActionInterface
$type = $object->transactionType->type;
$user = $object->user;
- $journalId = (int)$object->id;
+ $journalId = $object->id;
if (TransactionType::TRANSFER === $type) {
app('log')->error(
sprintf('Journal #%d is already a transfer so cannot be converted (rule #%d).', $object->id, $this->action->rule_id)
@@ -196,7 +196,7 @@ class ConvertToTransfer implements ActionInterface
private function convertWithdrawalArray(TransactionJournal $journal, Account $opposing): bool
{
$sourceAccount = $this->getSourceAccount($journal);
- if ((int)$sourceAccount->id === (int)$opposing->id) {
+ if ($sourceAccount->id === $opposing->id) {
app('log')->error(
vsprintf(
'Journal #%d has already has "%s" as a source asset. ConvertToTransfer failed. (rule #%d).',
@@ -255,7 +255,7 @@ class ConvertToTransfer implements ActionInterface
private function convertDepositArray(TransactionJournal $journal, Account $opposing): bool
{
$destAccount = $this->getDestinationAccount($journal);
- if ((int)$destAccount->id === (int)$opposing->id) {
+ if ($destAccount->id === $opposing->id) {
app('log')->error(
vsprintf(
'Journal #%d has already has "%s" as a destination asset. ConvertToTransfer failed. (rule #%d).',
diff --git a/app/TransactionRules/Actions/SetBudget.php b/app/TransactionRules/Actions/SetBudget.php
index d4875ffc54..15a078bccd 100644
--- a/app/TransactionRules/Actions/SetBudget.php
+++ b/app/TransactionRules/Actions/SetBudget.php
@@ -87,7 +87,7 @@ class SetBudget implements ActionInterface
$object = $user->transactionJournals()->find($journal['transaction_journal_id']);
$oldBudget = $object->budgets()->first();
$oldBudgetName = $oldBudget?->name;
- if ((int)$oldBudget?->id === (int)$budget->id) {
+ if ((int)$oldBudget?->id === $budget->id) {
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.already_linked_to_budget', ['name' => $budget->name])));
return false;
}
diff --git a/app/TransactionRules/Actions/SetCategory.php b/app/TransactionRules/Actions/SetCategory.php
index ca2e7d630d..bb56998c99 100644
--- a/app/TransactionRules/Actions/SetCategory.php
+++ b/app/TransactionRules/Actions/SetCategory.php
@@ -91,7 +91,7 @@ class SetCategory implements ActionInterface
$object = $user->transactionJournals()->find($journal['transaction_journal_id']);
$oldCategory = $object->categories()->first();
$oldCategoryName = $oldCategory?->name;
- if ((int)$oldCategory?->id === (int)$category->id) {
+ if ((int)$oldCategory?->id === $category->id) {
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.already_linked_to_category', ['name' => $category->name])));
return false;
}
diff --git a/app/TransactionRules/Actions/SetDestinationAccount.php b/app/TransactionRules/Actions/SetDestinationAccount.php
index d821679330..6941019b66 100644
--- a/app/TransactionRules/Actions/SetDestinationAccount.php
+++ b/app/TransactionRules/Actions/SetDestinationAccount.php
@@ -99,7 +99,7 @@ class SetDestinationAccount implements ActionInterface
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.cannot_find_source_transaction_account')));
return false;
}
- if (null !== $newAccount && (int)$newAccount->id === (int)$source->account_id) {
+ if (null !== $newAccount && $newAccount->id === $source->account_id) {
app('log')->error(
sprintf(
'New destination account ID #%d and current source account ID #%d are the same. Do nothing.',
diff --git a/app/TransactionRules/Actions/SetSourceAccount.php b/app/TransactionRules/Actions/SetSourceAccount.php
index aec83df0d0..aa95d66c7a 100644
--- a/app/TransactionRules/Actions/SetSourceAccount.php
+++ b/app/TransactionRules/Actions/SetSourceAccount.php
@@ -94,7 +94,7 @@ class SetSourceAccount implements ActionInterface
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.cannot_find_destination_transaction_account')));
return false;
}
- if (null !== $newAccount && (int)$newAccount->id === (int)$destination->account_id) {
+ if (null !== $newAccount && $newAccount->id === $destination->account_id) {
app('log')->error(
sprintf(
'New source account ID #%d and current destination account ID #%d are the same. Do nothing.',
diff --git a/app/TransactionRules/Actions/SwitchAccounts.php b/app/TransactionRules/Actions/SwitchAccounts.php
index eba4fb37cd..8ea7dc5acd 100644
--- a/app/TransactionRules/Actions/SwitchAccounts.php
+++ b/app/TransactionRules/Actions/SwitchAccounts.php
@@ -84,7 +84,7 @@ class SwitchAccounts implements ActionInterface
event(new RuleActionFailedOnArray($this->action, $journal, trans('rules.cannot_find_accounts')));
return false;
}
- $sourceAccountId = (int)$sourceTransaction->account_id;
+ $sourceAccountId = $sourceTransaction->account_id;
$destinationAccountId = $destTransaction->account_id;
$sourceTransaction->account_id = $destinationAccountId;
$destTransaction->account_id = $sourceAccountId;
diff --git a/app/TransactionRules/Actions/UpdatePiggybank.php b/app/TransactionRules/Actions/UpdatePiggybank.php
index aceedd746d..8f5902af65 100644
--- a/app/TransactionRules/Actions/UpdatePiggybank.php
+++ b/app/TransactionRules/Actions/UpdatePiggybank.php
@@ -62,7 +62,6 @@ class UpdatePiggybank implements ActionInterface
$user = User::find($journal['user_id']);
/** @var TransactionJournal $journalObj */
$journalObj = $user->transactionJournals()->find($journal['transaction_journal_id']);
- $type = TransactionType::find((int)$journalObj->transaction_type_id);
$piggyBank = $this->findPiggyBank($user);
if (null === $piggyBank) {
@@ -80,7 +79,7 @@ class UpdatePiggybank implements ActionInterface
/** @var Transaction $destination */
$destination = $journalObj->transactions()->where('amount', '>', 0)->first();
- if ((int)$source->account_id === (int)$piggyBank->account_id) {
+ if ($source->account_id === $piggyBank->account_id) {
app('log')->debug('Piggy bank account is linked to source, so remove amount from piggy bank.');
$this->removeAmount($piggyBank, $journalObj, $destination->amount);
@@ -101,7 +100,7 @@ class UpdatePiggybank implements ActionInterface
return true;
}
- if ((int)$destination->account_id === (int)$piggyBank->account_id) {
+ if ($destination->account_id === $piggyBank->account_id) {
app('log')->debug('Piggy bank account is linked to source, so add amount to piggy bank.');
$this->addAmount($piggyBank, $journalObj, $destination->amount);
diff --git a/app/Transformers/BillTransformer.php b/app/Transformers/BillTransformer.php
index a22a798261..e242ed40f1 100644
--- a/app/Transformers/BillTransformer.php
+++ b/app/Transformers/BillTransformer.php
@@ -71,8 +71,8 @@ class BillTransformer extends AbstractTransformer
/** @var ObjectGroup|null $objectGroup */
$objectGroup = $bill->objectGroups->first();
if (null !== $objectGroup) {
- $objectGroupId = (int)$objectGroup->id;
- $objectGroupOrder = (int)$objectGroup->order;
+ $objectGroupId = $objectGroup->id;
+ $objectGroupOrder = $objectGroup->order;
$objectGroupTitle = $objectGroup->title;
}
@@ -190,7 +190,7 @@ class BillTransformer extends AbstractTransformer
foreach ($set as $entry) {
$result[] = [
'transaction_group_id' => (int)$entry->transaction_group_id,
- 'transaction_journal_id' => (int)$entry->id,
+ 'transaction_journal_id' => $entry->id,
'date' => $entry->date->format('Y-m-d'),
];
}
diff --git a/app/Transformers/BudgetLimitTransformer.php b/app/Transformers/BudgetLimitTransformer.php
index a3c8dffad7..bc93efb1d6 100644
--- a/app/Transformers/BudgetLimitTransformer.php
+++ b/app/Transformers/BudgetLimitTransformer.php
@@ -77,7 +77,7 @@ class BudgetLimitTransformer extends AbstractTransformer
$currencySymbol = null;
if (null !== $currency) {
$amount = $budgetLimit->amount;
- $currencyId = (int)$currency->id;
+ $currencyId = $currency->id;
$currencyName = $currency->name;
$currencyCode = $currency->code;
$currencySymbol = $currency->symbol;
diff --git a/app/Transformers/CategoryTransformer.php b/app/Transformers/CategoryTransformer.php
index f04df6ced5..03d8bb8e36 100644
--- a/app/Transformers/CategoryTransformer.php
+++ b/app/Transformers/CategoryTransformer.php
@@ -70,7 +70,7 @@ class CategoryTransformer extends AbstractTransformer
$notes = $this->repository->getNoteText($category);
return [
- 'id' => (int)$category->id,
+ 'id' => $category->id,
'created_at' => $category->created_at->toAtomString(),
'updated_at' => $category->updated_at->toAtomString(),
'name' => $category->name,
diff --git a/app/Transformers/CurrencyTransformer.php b/app/Transformers/CurrencyTransformer.php
index 2764bde256..d1ad7299eb 100644
--- a/app/Transformers/CurrencyTransformer.php
+++ b/app/Transformers/CurrencyTransformer.php
@@ -40,7 +40,7 @@ class CurrencyTransformer extends AbstractTransformer
public function transform(TransactionCurrency $currency): array
{
return [
- 'id' => (int)$currency->id,
+ 'id' => $currency->id,
'created_at' => $currency->created_at->toAtomString(),
'updated_at' => $currency->updated_at->toAtomString(),
'default' => $currency->userDefault,
diff --git a/app/Transformers/LinkTypeTransformer.php b/app/Transformers/LinkTypeTransformer.php
index 13f3b36eb5..9002a2767d 100644
--- a/app/Transformers/LinkTypeTransformer.php
+++ b/app/Transformers/LinkTypeTransformer.php
@@ -41,7 +41,7 @@ class LinkTypeTransformer extends AbstractTransformer
public function transform(LinkType $linkType): array
{
return [
- 'id' => (int)$linkType->id,
+ 'id' => $linkType->id,
'created_at' => $linkType->created_at->toAtomString(),
'updated_at' => $linkType->updated_at->toAtomString(),
'name' => $linkType->name,
diff --git a/app/Transformers/TransactionGroupTransformer.php b/app/Transformers/TransactionGroupTransformer.php
index aac7e6f410..38cde1edf5 100644
--- a/app/Transformers/TransactionGroupTransformer.php
+++ b/app/Transformers/TransactionGroupTransformer.php
@@ -382,7 +382,7 @@ class TransactionGroupTransformer extends AbstractTransformer
$destination = $this->getDestinationTransaction($journal);
$type = $journal->transactionType->type;
$currency = $source->transactionCurrency;
- $amount = app('steam')->bcround($this->getAmount($type, (string)$source->amount), $currency->decimal_places ?? 0);
+ $amount = app('steam')->bcround($this->getAmount($type, $source->amount), $currency->decimal_places ?? 0);
$foreignAmount = $this->getForeignAmount($type, null === $source->foreign_amount ? null : (string)$source->foreign_amount);
$metaFieldData = $this->groupRepos->getMetaFields($journal->id, $this->metaFields);
$metaDates = $this->getDates($this->groupRepos->getMetaDateFields($journal->id, $this->metaDateFields));
@@ -407,12 +407,12 @@ class TransactionGroupTransformer extends AbstractTransformer
return [
'user' => (int)$journal->user_id,
- 'transaction_journal_id' => (int)$journal->id,
+ 'transaction_journal_id' => $journal->id,
'type' => strtolower($type),
'date' => $journal->date->toAtomString(),
'order' => $journal->order,
- 'currency_id' => (int)$currency->id,
+ 'currency_id' => $currency->id,
'currency_code' => $currency->code,
'currency_symbol' => $currency->symbol,
'currency_decimal_places' => (int)$currency->decimal_places,
@@ -427,12 +427,12 @@ class TransactionGroupTransformer extends AbstractTransformer
'description' => $journal->description,
- 'source_id' => (int)$source->account_id,
+ 'source_id' => $source->account_id,
'source_name' => $source->account->name,
'source_iban' => $source->account->iban,
'source_type' => $source->account->accountType->type,
- 'destination_id' => (int)$destination->account_id,
+ 'destination_id' => $destination->account_id,
'destination_name' => $destination->account->name,
'destination_iban' => $destination->account->iban,
'destination_type' => $destination->account->accountType->type,
@@ -589,7 +589,7 @@ class TransactionGroupTransformer extends AbstractTransformer
if (null === $currency) {
return $array;
}
- $array['id'] = (int)$currency->id;
+ $array['id'] = $currency->id;
$array['code'] = $currency->code;
$array['symbol'] = $currency->symbol;
$array['decimal_places'] = (int)$currency->decimal_places;
@@ -611,7 +611,7 @@ class TransactionGroupTransformer extends AbstractTransformer
if (null === $budget) {
return $array;
}
- $array['id'] = (int)$budget->id;
+ $array['id'] = $budget->id;
$array['name'] = $budget->name;
return $array;
@@ -631,7 +631,7 @@ class TransactionGroupTransformer extends AbstractTransformer
if (null === $category) {
return $array;
}
- $array['id'] = (int)$category->id;
+ $array['id'] = $category->id;
$array['name'] = $category->name;
return $array;
diff --git a/app/Transformers/V2/AccountTransformer.php b/app/Transformers/V2/AccountTransformer.php
index 8a192d121b..45a4498b15 100644
--- a/app/Transformers/V2/AccountTransformer.php
+++ b/app/Transformers/V2/AccountTransformer.php
@@ -70,7 +70,7 @@ class AccountTransformer extends AbstractTransformer
$currencies = $repository->getByIds($currencyIds);
foreach ($currencies as $currency) {
- $id = (int)$currency->id;
+ $id = $currency->id;
$this->currencies[$id] = $currency;
}
foreach ($meta as $entry) {
@@ -110,7 +110,7 @@ class AccountTransformer extends AbstractTransformer
*/
public function transform(Account $account): array
{
- $id = (int)$account->id;
+ $id = $account->id;
// various meta
$accountRole = $this->accountMeta[$id]['account_role'] ?? null;
diff --git a/app/Transformers/V2/BillTransformer.php b/app/Transformers/V2/BillTransformer.php
index 5dff9fedae..3505eea4e5 100644
--- a/app/Transformers/V2/BillTransformer.php
+++ b/app/Transformers/V2/BillTransformer.php
@@ -111,13 +111,13 @@ class BillTransformer extends AbstractTransformer
$transactions = [];
/** @var Transaction $transaction */
foreach ($set as $transaction) {
- $journalId = (int)$transaction->transaction_journal_id;
+ $journalId = $transaction->transaction_journal_id;
$transactions[$journalId] = $transaction->toArray();
}
/** @var TransactionJournal $journal */
foreach ($journals as $journal) {
app('log')->debug(sprintf('Processing journal #%d', $journal->id));
- $transaction = $transactions[(int)$journal->id] ?? [];
+ $transaction = $transactions[$journal->id] ?? [];
$billId = (int)$journal->bill_id;
$currencyId = (int)($transaction['transaction_currency_id'] ?? 0);
$currencies[$currencyId] = $currencies[$currencyId] ?? TransactionCurrency::find($currencyId);
@@ -183,7 +183,7 @@ class BillTransformer extends AbstractTransformer
$paidData = $this->paidDates[(int)$bill->id] ?? [];
$nextExpectedMatch = $this->nextExpectedMatch($bill, $this->paidDates[(int)$bill->id] ?? []);
$payDates = $this->payDates($bill);
- $currency = $this->currencies[(int)$bill->transaction_currency_id];
+ $currency = $this->currencies[$bill->transaction_currency_id];
$group = $this->groups[(int)$bill->id] ?? null;
// date for currency conversion
diff --git a/app/Transformers/V2/BudgetLimitTransformer.php b/app/Transformers/V2/BudgetLimitTransformer.php
index deaca5f37d..2c28e62c9c 100644
--- a/app/Transformers/V2/BudgetLimitTransformer.php
+++ b/app/Transformers/V2/BudgetLimitTransformer.php
@@ -80,7 +80,7 @@ class BudgetLimitTransformer extends AbstractTransformer
$currencySymbol = null;
if (null !== $currency) {
$amount = $budgetLimit->amount;
- $currencyId = (int)$currency->id;
+ $currencyId = $currency->id;
$currencyName = $currency->name;
$currencyCode = $currency->code;
$currencySymbol = $currency->symbol;
diff --git a/app/Transformers/V2/CurrencyTransformer.php b/app/Transformers/V2/CurrencyTransformer.php
index af4f53d61c..b3973b6f09 100644
--- a/app/Transformers/V2/CurrencyTransformer.php
+++ b/app/Transformers/V2/CurrencyTransformer.php
@@ -48,7 +48,7 @@ class CurrencyTransformer extends AbstractTransformer
public function transform(TransactionCurrency $currency): array
{
return [
- 'id' => (int)$currency->id,
+ 'id' => $currency->id,
'created_at' => $currency->created_at->toAtomString(),
'updated_at' => $currency->updated_at->toAtomString(),
'default' => $currency->userDefault,
diff --git a/app/Transformers/V2/PiggyBankTransformer.php b/app/Transformers/V2/PiggyBankTransformer.php
index 6b00b29d93..e7509552ea 100644
--- a/app/Transformers/V2/PiggyBankTransformer.php
+++ b/app/Transformers/V2/PiggyBankTransformer.php
@@ -83,7 +83,7 @@ class PiggyBankTransformer extends AbstractTransformer
$currencies = [];
/** @var Account $account */
foreach ($accountInfo as $account) {
- $id = (int)$account->id;
+ $id = $account->id;
$this->accounts[$id] = [
'name' => $account->name,
];
diff --git a/app/Transformers/V2/TransactionGroupTransformer.php b/app/Transformers/V2/TransactionGroupTransformer.php
index 6868554516..8c1f5a9dcc 100644
--- a/app/Transformers/V2/TransactionGroupTransformer.php
+++ b/app/Transformers/V2/TransactionGroupTransformer.php
@@ -77,7 +77,7 @@ class TransactionGroupTransformer extends AbstractTransformer
$meta = TransactionJournalMeta::whereIn('transaction_journal_id', array_keys($journals))->get();
/** @var TransactionJournalMeta $entry */
foreach ($meta as $entry) {
- $id = (int)$entry->transaction_journal_id;
+ $id = $entry->transaction_journal_id;
$this->meta[$id][$entry->name] = $entry->data;
}
diff --git a/app/Validation/TransactionValidation.php b/app/Validation/TransactionValidation.php
index eedc402612..1e69266de1 100644
--- a/app/Validation/TransactionValidation.php
+++ b/app/Validation/TransactionValidation.php
@@ -268,7 +268,7 @@ trait TransactionValidation
$foreignCurrencyCode = $transaction['foreign_currency_code'] ?? false;
$foreignCurrencyId = (int)($transaction['foreign_currency_id'] ?? 0);
app('log')->debug(sprintf('Foreign currency code seems to be #%d "%s"', $foreignCurrencyId, $foreignCurrencyCode), $transaction);
- if ($foreignCurrencyCode !== $sourceCurrency->code && $foreignCurrencyId !== (int)$sourceCurrency->id) {
+ if ($foreignCurrencyCode !== $sourceCurrency->code && $foreignCurrencyId !== $sourceCurrency->id) {
$validator->errors()->add(sprintf('transactions.%d.foreign_currency_code', $index), (string)trans('validation.require_foreign_src'));
return;
}
@@ -293,7 +293,7 @@ trait TransactionValidation
$foreignCurrencyCode = $transaction['foreign_currency_code'] ?? false;
$foreignCurrencyId = (int)($transaction['foreign_currency_id'] ?? 0);
app('log')->debug(sprintf('Foreign currency code seems to be #%d "%s"', $foreignCurrencyId, $foreignCurrencyCode), $transaction);
- if ($foreignCurrencyCode !== $destinationCurrency->code && $foreignCurrencyId !== (int)$destinationCurrency->id) {
+ if ($foreignCurrencyCode !== $destinationCurrency->code && $foreignCurrencyId !== $destinationCurrency->id) {
app('log')->debug(sprintf('No match on code, "%s" vs "%s"', $foreignCurrencyCode, $destinationCurrency->code));
app('log')->debug(sprintf('No match on ID, #%d vs #%d', $foreignCurrencyId, $destinationCurrency->id));
$validator->errors()->add(sprintf('transactions.%d.foreign_amount', $index), (string)trans('validation.require_foreign_dest'));
@@ -507,7 +507,7 @@ trait TransactionValidation
/** @var TransactionJournal $journal */
foreach ($transactionGroup->transactionJournals as $journal) {
$journalId = (int)($transaction['transaction_journal_id'] ?? 0);
- if ((int)$journal->id === $journalId) {
+ if ($journal->id === $journalId) {
return $journal->transactions()->where('amount', '<', 0)->first()->account;
}
}