Skip to content

Firefly III: a personal finances manager

Clean up some code.

James Cole99c94cbb923b
diff --git a/app/Api/V1/Controllers/Autocomplete/AccountController.php b/app/Api/V1/Controllers/Autocomplete/AccountController.php
index 667763ab6d..77dac54cac 100644
--- a/app/Api/V1/Controllers/Autocomplete/AccountController.php
+++ b/app/Api/V1/Controllers/Autocomplete/AccountController.php
@@ -48,12 +48,11 @@ final class AccountController extends Controller
// this array only exists to test if the constructor will use it properly.
#[Override]
- protected array $accepts = ['application/json', 'application/vnd.api+json'];
- #[Override]
protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];
-
+ #[Override]
+ protected array $accepts = ['application/json', 'application/vnd.api+json'];
/** @var array<int, string> */
- private array $balanceTypes;
+ private array $balanceTypes;
private AccountRepositoryInterface $repository;
/**
@@ -90,9 +89,9 @@ final class AccountController extends Controller
// set date to end-of-day for account balance. so it is at $date 23:59:59
$date->endOfDay();
- $return = [];
- $result = $this->repository->searchAccount((string) $query, $types, $limit);
- $allBalances = Steam::accountsBalancesOptimized($result, $date, $this->primaryCurrency, $this->convertToPrimary);
+ $return = [];
+ $result = $this->repository->searchAccount((string)$query, $types, $limit);
+ $allBalances = Steam::accountsBalancesOptimized($result, $date, $this->primaryCurrency, $this->convertToPrimary);
/** @var Account $account */
foreach ($result as $account) {
@@ -109,18 +108,18 @@ final class AccountController extends Controller
$nameWithBalance = sprintf('%s (%s)', $account->name, Amount::formatAnything($useCurrency, $amount, false));
}
- $return[] = [
- 'id' => (string) $account->id,
+ $return[] = [
+ 'id' => (string)$account->id,
'name' => $account->name,
'name_with_balance' => $nameWithBalance,
'active' => $account->active,
'type' => $account->accountType->type,
- 'currency_id' => (string) $useCurrency->id,
+ 'currency_id' => (string)$useCurrency->id,
'currency_name' => $useCurrency->name,
'currency_code' => $useCurrency->code,
'currency_symbol' => $useCurrency->symbol,
'currency_decimal_places' => $useCurrency->decimal_places,
- 'account_currency_id' => (string) $currency->id,
+ 'account_currency_id' => (string)$currency->id,
'account_currency_name' => $currency->name,
'account_currency_code' => $currency->code,
'account_currency_symbol' => $currency->symbol,
@@ -131,8 +130,8 @@ final class AccountController extends Controller
// custom order.
usort($return, static function (array $left, array $right): int {
$order = [AccountTypeEnum::ASSET->value, AccountTypeEnum::REVENUE->value, AccountTypeEnum::EXPENSE->value];
- $posA = (int) array_search($left['type'], $order, true);
- $posB = (int) 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/Autocomplete/BillController.php b/app/Api/V1/Controllers/Autocomplete/BillController.php
index 694dbcebe3..83bde73e0e 100644
--- a/app/Api/V1/Controllers/Autocomplete/BillController.php
+++ b/app/Api/V1/Controllers/Autocomplete/BillController.php
@@ -38,9 +38,9 @@ use Override;
*/
final class BillController extends Controller
{
- private BillRepositoryInterface $repository;
#[Override]
- protected array $acceptedRoles = [UserRoleEnum::READ_SUBSCRIPTIONS];
+ protected array $acceptedRoles = [UserRoleEnum::READ_SUBSCRIPTIONS];
+ private BillRepositoryInterface $repository;
/**
* BillController constructor.
@@ -65,7 +65,7 @@ final class BillController extends Controller
public function bills(AutocompleteApiRequest $request): JsonResponse
{
$result = $this->repository->searchBill($request->attributes->get('query'), $request->attributes->get('limit'));
- $filtered = $result->map(static fn (Bill $item): array => ['id' => (string) $item->id, 'name' => $item->name, 'active' => $item->active]);
+ $filtered = $result->map(static fn(Bill $item): array => ['id' => (string)$item->id, 'name' => $item->name, 'active' => $item->active]);
return response()->api($filtered->toArray());
}
diff --git a/app/Api/V1/Controllers/Autocomplete/BudgetController.php b/app/Api/V1/Controllers/Autocomplete/BudgetController.php
index 92ed277ee4..51315938ff 100644
--- a/app/Api/V1/Controllers/Autocomplete/BudgetController.php
+++ b/app/Api/V1/Controllers/Autocomplete/BudgetController.php
@@ -38,9 +38,9 @@ use Override;
*/
final class BudgetController extends Controller
{
- private BudgetRepositoryInterface $repository;
#[Override]
- protected array $acceptedRoles = [UserRoleEnum::READ_BUDGETS];
+ protected array $acceptedRoles = [UserRoleEnum::READ_BUDGETS];
+ private BudgetRepositoryInterface $repository;
/**
* BudgetController constructor.
@@ -65,7 +65,7 @@ final class BudgetController extends Controller
public function budgets(AutocompleteApiRequest $request): JsonResponse
{
$result = $this->repository->searchBudget($request->attributes->get('query'), $request->attributes->get('limit'));
- $filtered = $result->map(static fn (Budget $item): array => ['id' => (string) $item->id, 'name' => $item->name, 'active' => $item->active]);
+ $filtered = $result->map(static fn(Budget $item): array => ['id' => (string)$item->id, 'name' => $item->name, 'active' => $item->active]);
return response()->api($filtered->toArray());
}
diff --git a/app/Api/V1/Controllers/Autocomplete/CategoryController.php b/app/Api/V1/Controllers/Autocomplete/CategoryController.php
index c8ccd50e78..2b7dd82e84 100644
--- a/app/Api/V1/Controllers/Autocomplete/CategoryController.php
+++ b/app/Api/V1/Controllers/Autocomplete/CategoryController.php
@@ -38,9 +38,9 @@ use Override;
*/
final class CategoryController extends Controller
{
- private CategoryRepositoryInterface $repository;
#[Override]
- protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];
+ protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];
+ private CategoryRepositoryInterface $repository;
/**
* CategoryController constructor.
@@ -65,7 +65,7 @@ final class CategoryController extends Controller
public function categories(AutocompleteApiRequest $request): JsonResponse
{
$result = $this->repository->searchCategory($request->attributes->get('query'), $request->attributes->get('limit'));
- $filtered = $result->map(static fn (Category $item): array => ['id' => (string) $item->id, 'name' => $item->name]);
+ $filtered = $result->map(static fn(Category $item): array => ['id' => (string)$item->id, 'name' => $item->name]);
return response()->api($filtered->toArray());
}
diff --git a/app/Api/V1/Controllers/Autocomplete/CurrencyController.php b/app/Api/V1/Controllers/Autocomplete/CurrencyController.php
index 02b4ef0657..92a93db162 100644
--- a/app/Api/V1/Controllers/Autocomplete/CurrencyController.php
+++ b/app/Api/V1/Controllers/Autocomplete/CurrencyController.php
@@ -40,9 +40,9 @@ use Override;
*/
final class CurrencyController extends Controller
{
- private CurrencyRepositoryInterface $repository;
#[Override]
- protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];
+ protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];
+ private CurrencyRepositoryInterface $repository;
/**
* CurrencyController constructor.
@@ -72,7 +72,7 @@ final class CurrencyController extends Controller
/** @var TransactionCurrency $currency */
foreach ($collection as $currency) {
$result[] = [
- 'id' => (string) $currency->id,
+ 'id' => (string)$currency->id,
'name' => $currency->name,
'code' => $currency->code,
'symbol' => $currency->symbol,
@@ -97,7 +97,7 @@ final class CurrencyController extends Controller
/** @var TransactionCurrency $currency */
foreach ($collection as $currency) {
$result[] = [
- 'id' => (string) $currency->id,
+ 'id' => (string)$currency->id,
'name' => sprintf('%s (%s)', $currency->name, $currency->code),
'code' => $currency->code,
'symbol' => $currency->symbol,
diff --git a/app/Api/V1/Controllers/Autocomplete/ObjectGroupController.php b/app/Api/V1/Controllers/Autocomplete/ObjectGroupController.php
index e015bd46c9..8a793e97be 100644
--- a/app/Api/V1/Controllers/Autocomplete/ObjectGroupController.php
+++ b/app/Api/V1/Controllers/Autocomplete/ObjectGroupController.php
@@ -38,9 +38,9 @@ use Override;
*/
final class ObjectGroupController extends Controller
{
- private ObjectGroupRepositoryInterface $repository;
#[Override]
- protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];
+ protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];
+ private ObjectGroupRepositoryInterface $repository;
/**
* CurrencyController constructor.
@@ -69,7 +69,7 @@ final class ObjectGroupController extends Controller
/** @var ObjectGroup $objectGroup */
foreach ($result as $objectGroup) {
- $return[] = ['id' => (string) $objectGroup->id, 'name' => $objectGroup->title, 'title' => $objectGroup->title];
+ $return[] = ['id' => (string)$objectGroup->id, 'name' => $objectGroup->title, 'title' => $objectGroup->title];
}
return response()->api($return);
diff --git a/app/Api/V1/Controllers/Autocomplete/PiggyBankController.php b/app/Api/V1/Controllers/Autocomplete/PiggyBankController.php
index 5c879b0f0b..d6ed095071 100644
--- a/app/Api/V1/Controllers/Autocomplete/PiggyBankController.php
+++ b/app/Api/V1/Controllers/Autocomplete/PiggyBankController.php
@@ -41,10 +41,10 @@ use Override;
*/
final class PiggyBankController extends Controller
{
- private AccountRepositoryInterface $accountRepository;
- private PiggyBankRepositoryInterface $piggyRepository;
#[Override]
- protected array $acceptedRoles = [UserRoleEnum::READ_PIGGY_BANKS];
+ protected array $acceptedRoles = [UserRoleEnum::READ_PIGGY_BANKS];
+ private AccountRepositoryInterface $accountRepository;
+ private PiggyBankRepositoryInterface $piggyRepository;
/**
* PiggyBankController constructor.
@@ -75,14 +75,14 @@ final class PiggyBankController extends Controller
$currency = $piggy->transactionCurrency;
$objectGroup = $piggy->objectGroups()->first();
$response[] = [
- 'id' => (string) $piggy->id,
+ 'id' => (string)$piggy->id,
'name' => $piggy->name,
- 'currency_id' => (string) $currency->id,
+ 'currency_id' => (string)$currency->id,
'currency_name' => $currency->name,
'currency_code' => $currency->code,
'currency_symbol' => $currency->symbol,
'currency_decimal_places' => $currency->decimal_places,
- 'object_group_id' => null === $objectGroup ? null : (string) $objectGroup->id,
+ 'object_group_id' => null === $objectGroup ? null : (string)$objectGroup->id,
'object_group_title' => $objectGroup?->title,
'object_group_order' => $objectGroup?->order,
];
@@ -103,7 +103,7 @@ final class PiggyBankController extends Controller
$currentAmount = $this->piggyRepository->getCurrentAmount($piggy);
$objectGroup = $piggy->objectGroups()->first();
$response[] = [
- 'id' => (string) $piggy->id,
+ 'id' => (string)$piggy->id,
'name' => $piggy->name,
'name_with_balance' => sprintf(
'%s (%s / %s)',
@@ -111,12 +111,12 @@ final class PiggyBankController extends Controller
Amount::formatAnything($currency, $currentAmount, false),
Amount::formatAnything($currency, $piggy->target_amount, false)
),
- 'currency_id' => (string) $currency->id,
+ 'currency_id' => (string)$currency->id,
'currency_name' => $currency->name,
'currency_code' => $currency->code,
'currency_symbol' => $currency->symbol,
'currency_decimal_places' => $currency->decimal_places,
- 'object_group_id' => null === $objectGroup ? null : (string) $objectGroup->id,
+ 'object_group_id' => null === $objectGroup ? null : (string)$objectGroup->id,
'object_group_title' => $objectGroup?->title,
'object_group_order' => $objectGroup?->order,
];
diff --git a/app/Api/V1/Controllers/Autocomplete/RecurrenceController.php b/app/Api/V1/Controllers/Autocomplete/RecurrenceController.php
index 29600b36fe..8de4f02291 100644
--- a/app/Api/V1/Controllers/Autocomplete/RecurrenceController.php
+++ b/app/Api/V1/Controllers/Autocomplete/RecurrenceController.php
@@ -38,9 +38,9 @@ use Override;
*/
final class RecurrenceController extends Controller
{
- private RecurringRepositoryInterface $repository;
#[Override]
- protected array $acceptedRoles = [UserRoleEnum::READ_RECURRING];
+ protected array $acceptedRoles = [UserRoleEnum::READ_RECURRING];
+ private RecurringRepositoryInterface $repository;
/**
* RecurrenceController constructor.
@@ -66,7 +66,7 @@ final class RecurrenceController extends Controller
/** @var Recurrence $recurrence */
foreach ($recurrences as $recurrence) {
$response[] = [
- 'id' => (string) $recurrence->id,
+ 'id' => (string)$recurrence->id,
'name' => $recurrence->title,
'description' => $recurrence->description,
'active' => $recurrence->active,
diff --git a/app/Api/V1/Controllers/Autocomplete/RuleController.php b/app/Api/V1/Controllers/Autocomplete/RuleController.php
index c371217df8..cf2a1e8d31 100644
--- a/app/Api/V1/Controllers/Autocomplete/RuleController.php
+++ b/app/Api/V1/Controllers/Autocomplete/RuleController.php
@@ -38,9 +38,9 @@ use Override;
*/
final class RuleController extends Controller
{
- private RuleRepositoryInterface $repository;
#[Override]
- protected array $acceptedRoles = [UserRoleEnum::READ_RULES];
+ protected array $acceptedRoles = [UserRoleEnum::READ_RULES];
+ private RuleRepositoryInterface $repository;
/**
* RuleController constructor.
@@ -66,7 +66,7 @@ final class RuleController extends Controller
/** @var Rule $rule */
foreach ($rules as $rule) {
$response[] = [
- 'id' => (string) $rule->id,
+ 'id' => (string)$rule->id,
'name' => $rule->title,
'description' => $rule->description,
'active' => $rule->active,
diff --git a/app/Api/V1/Controllers/Autocomplete/RuleGroupController.php b/app/Api/V1/Controllers/Autocomplete/RuleGroupController.php
index dd7f602580..a8b18c9d09 100644
--- a/app/Api/V1/Controllers/Autocomplete/RuleGroupController.php
+++ b/app/Api/V1/Controllers/Autocomplete/RuleGroupController.php
@@ -38,9 +38,9 @@ use Override;
*/
final class RuleGroupController extends Controller
{
- private RuleGroupRepositoryInterface $repository;
#[Override]
- protected array $acceptedRoles = [UserRoleEnum::READ_RULES];
+ protected array $acceptedRoles = [UserRoleEnum::READ_RULES];
+ private RuleGroupRepositoryInterface $repository;
/**
* RuleGroupController constructor.
@@ -66,7 +66,7 @@ final class RuleGroupController extends Controller
/** @var RuleGroup $group */
foreach ($groups as $group) {
$response[] = [
- 'id' => (string) $group->id,
+ 'id' => (string)$group->id,
'name' => $group->title,
'description' => $group->description,
'active' => $group->active,
diff --git a/app/Api/V1/Controllers/Autocomplete/TagController.php b/app/Api/V1/Controllers/Autocomplete/TagController.php
index a4f455c73e..af57b63832 100644
--- a/app/Api/V1/Controllers/Autocomplete/TagController.php
+++ b/app/Api/V1/Controllers/Autocomplete/TagController.php
@@ -38,9 +38,9 @@ use Override;
*/
final class TagController extends Controller
{
- private TagRepositoryInterface $repository;
#[Override]
- protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];
+ protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];
+ private TagRepositoryInterface $repository;
/**
* TagController constructor.
@@ -65,7 +65,7 @@ final class TagController extends Controller
/** @var Tag $tag */
foreach ($result as $tag) {
- $array[] = ['id' => (string) $tag->id, 'name' => $tag->tag, 'tag' => $tag->tag];
+ $array[] = ['id' => (string)$tag->id, 'name' => $tag->tag, 'tag' => $tag->tag];
}
return response()->api($array);
diff --git a/app/Api/V1/Controllers/Autocomplete/TransactionController.php b/app/Api/V1/Controllers/Autocomplete/TransactionController.php
index 746c0732fb..d8d4eb1f06 100644
--- a/app/Api/V1/Controllers/Autocomplete/TransactionController.php
+++ b/app/Api/V1/Controllers/Autocomplete/TransactionController.php
@@ -45,9 +45,9 @@ use Override;
final class TransactionController extends Controller
{
#[Override]
- protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];
+ protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];
private TransactionGroupRepositoryInterface $groupRepository;
- private JournalRepositoryInterface $repository;
+ private JournalRepositoryInterface $repository;
/**
* TransactionController constructor.
@@ -70,7 +70,7 @@ final class TransactionController extends Controller
public function transactions(AutocompleteTransactionApiRequest $request): JsonResponse
{
- $result = $this->repository->searchJournalDescriptions($request->attributes->get('query'), $request->attributes->get('limit'));
+ $result = $this->repository->searchJournalDescriptions($request->attributes->get('query'), $request->attributes->get('limit'));
// limit and unique
$filtered = $result->unique('description');
@@ -79,8 +79,8 @@ final class TransactionController extends Controller
/** @var TransactionJournal $journal */
foreach ($filtered as $journal) {
$array[] = [
- 'id' => (string) $journal->id,
- 'transaction_group_id' => (string) $journal->transaction_group_id,
+ 'id' => (string)$journal->id,
+ 'transaction_group_id' => (string)$journal->transaction_group_id,
'name' => $journal->description,
'description' => $journal->description,
];
@@ -94,7 +94,7 @@ final class TransactionController extends Controller
$result = new Collection();
if (is_numeric($request->attributes->get('query'))) {
// search for group, not journal.
- $firstResult = $this->groupRepository->find((int) $request->attributes->get('query'));
+ $firstResult = $this->groupRepository->find((int)$request->attributes->get('query'));
if ($firstResult instanceof TransactionGroup) {
// group may contain multiple journals, each a result:
foreach ($firstResult->transactionJournals as $journal) {
@@ -107,13 +107,13 @@ final class TransactionController extends Controller
}
// limit and unique
- $array = [];
+ $array = [];
/** @var TransactionJournal $journal */
foreach ($result as $journal) {
$array[] = [
- 'id' => (string) $journal->id,
- 'transaction_group_id' => (string) $journal->transaction_group_id,
+ 'id' => (string)$journal->id,
+ 'transaction_group_id' => (string)$journal->transaction_group_id,
'name' => sprintf('#%d: %s', $journal->transaction_group_id, $journal->description),
'description' => sprintf('#%d: %s', $journal->transaction_group_id, $journal->description),
];
@@ -127,7 +127,7 @@ final class TransactionController extends Controller
$result = new Collection();
if (is_numeric($request->attributes->get('query'))) {
// search for group, not journal.
- $firstResult = $this->groupRepository->find((int) $request->attributes->get('query'));
+ $firstResult = $this->groupRepository->find((int)$request->attributes->get('query'));
if ($firstResult instanceof TransactionGroup) {
// group may contain multiple journals, each a result:
foreach ($firstResult->transactionJournals as $journal) {
@@ -140,14 +140,14 @@ final class TransactionController extends Controller
}
// limit and unique
- $array = [];
+ $array = [];
/** @var TransactionJournal $journal */
foreach ($result as $journal) {
$currency = Amount::getCurrencyFromJournal($journal);
$array[] = [
- 'id' => (string) $journal->id,
- 'transaction_group_id' => (string) $journal->transaction_group_id,
+ 'id' => (string)$journal->id,
+ 'transaction_group_id' => (string)$journal->transaction_group_id,
'name' => $journal->description,
'description' => $journal->description,
'date' => $journal->date,
diff --git a/app/Api/V1/Controllers/Autocomplete/TransactionTypeController.php b/app/Api/V1/Controllers/Autocomplete/TransactionTypeController.php
index a21990d1ad..a950c1121d 100644
--- a/app/Api/V1/Controllers/Autocomplete/TransactionTypeController.php
+++ b/app/Api/V1/Controllers/Autocomplete/TransactionTypeController.php
@@ -38,9 +38,9 @@ use Override;
*/
final class TransactionTypeController extends Controller
{
- private TransactionTypeRepositoryInterface $repository;
#[Override]
- protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];
+ protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];
+ private TransactionTypeRepositoryInterface $repository;
/**
* TransactionTypeController constructor.
@@ -64,7 +64,7 @@ final class TransactionTypeController extends Controller
/** @var TransactionType $type */
foreach ($types as $type) {
// different key for consistency.
- $array[] = ['id' => (string) $type->id, 'name' => $type->type, 'type' => $type->type];
+ $array[] = ['id' => (string)$type->id, 'name' => $type->type, 'type' => $type->type];
}
return response()->api($array);
diff --git a/app/Api/V1/Controllers/Chart/AccountController.php b/app/Api/V1/Controllers/Chart/AccountController.php
index 06380836b0..4de0c90275 100644
--- a/app/Api/V1/Controllers/Chart/AccountController.php
+++ b/app/Api/V1/Controllers/Chart/AccountController.php
@@ -52,7 +52,7 @@ final class AccountController extends Controller
protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];
- private array $chartData = [];
+ private array $chartData = [];
private AccountRepositoryInterface $repository;
/**
@@ -100,28 +100,28 @@ final class AccountController extends Controller
private function renderAccountData(array $params, Account $account): void
{
Log::debug(sprintf('Now in %s(array, #%d)', __METHOD__, $account->id));
- $currency = $this->repository->getAccountCurrency($account);
- $currentStart = clone $params['start'];
- $range = Steam::finalAccountBalanceInRange($account, $params['start'], clone $params['end'], $this->convertToPrimary);
- $period = $params['period'] ?? '1D';
+ $currency = $this->repository->getAccountCurrency($account);
+ $currentStart = clone $params['start'];
+ $range = Steam::finalAccountBalanceInRange($account, $params['start'], clone $params['end'], $this->convertToPrimary);
+ $period = $params['period'] ?? '1D';
- $previous = array_values($range)[0]['balance'];
- $pcPrevious = null;
+ $previous = array_values($range)[0]['balance'];
+ $pcPrevious = null;
if (!$currency instanceof TransactionCurrency) {
$currency = $this->primaryCurrency;
}
- $currentSet = [
+ $currentSet = [
'label' => $account->name,
// the currency that belongs to the account.
- 'currency_id' => (string) $currency->id,
+ 'currency_id' => (string)$currency->id,
'currency_name' => $currency->name,
'currency_code' => $currency->code,
'currency_symbol' => $currency->symbol,
'currency_decimal_places' => $currency->decimal_places,
// the primary currency
- 'primary_currency_id' => (string) $this->primaryCurrency->id,
+ 'primary_currency_id' => (string)$this->primaryCurrency->id,
// the default currency of the user (could be the same!)
'date' => $params['start']->toAtomString(),
@@ -135,7 +135,7 @@ final class AccountController extends Controller
];
if ($this->convertToPrimary) {
$currentSet['pc_entries'] = [];
- $currentSet['primary_currency_id'] = (string) $this->primaryCurrency->id;
+ $currentSet['primary_currency_id'] = (string)$this->primaryCurrency->id;
$currentSet['primary_currency_code'] = $this->primaryCurrency->code;
$currentSet['primary_currency_symbol'] = $this->primaryCurrency->symbol;
$currentSet['primary_currency_decimal_places'] = $this->primaryCurrency->decimal_places;
@@ -143,13 +143,13 @@ final class AccountController extends Controller
}
// create array of values to collect.
- $rangeDates = array_map(static fn (string $d): Carbon => Carbon::createFromFormat('Y-m-d', $d)->startOfDay(), array_keys($range));
- $rangeVals = array_values($range);
- $rangeIdx = 0;
- $rangeCount = count($rangeDates);
+ $rangeDates = array_map(static fn(string $d): Carbon => Carbon::createFromFormat('Y-m-d', $d)->startOfDay(), array_keys($range));
+ $rangeVals = array_values($range);
+ $rangeIdx = 0;
+ $rangeCount = count($rangeDates);
while ($currentStart <= $params['end']) {
- $label = $currentStart->toAtomString();
+ $label = $currentStart->toAtomString();
// Advance through all range entries up to current chart date
while ($rangeIdx < $rangeCount && $rangeDates[$rangeIdx] <= $currentStart) {
@@ -165,7 +165,7 @@ final class AccountController extends Controller
$currentSet['pc_entries'][$label] = $pcPrevious;
}
- $currentStart = Navigation::addPeriod($currentStart, $period);
+ $currentStart = Navigation::addPeriod($currentStart, $period);
}
$this->chartData[] = $currentSet;
}
diff --git a/app/Api/V1/Controllers/Chart/BalanceController.php b/app/Api/V1/Controllers/Chart/BalanceController.php
index 7885bab44a..7da7585bbe 100644
--- a/app/Api/V1/Controllers/Chart/BalanceController.php
+++ b/app/Api/V1/Controllers/Chart/BalanceController.php
@@ -49,8 +49,8 @@ final class BalanceController extends Controller
#[Override]
protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];
- private array $chartData = [];
- private GroupCollectorInterface $collector;
+ private array $chartData = [];
+ private GroupCollectorInterface $collector;
private AccountRepositoryInterface $repository;
// private TransactionCurrency $default;
@@ -90,18 +90,17 @@ final class BalanceController extends Controller
// get journals for entire period:
$this->collector->setRange($queryParameters['start'], $queryParameters['end'])
- ->withAccountInformation()
- ->setXorAccounts($accounts)
- ->setTypes([
- TransactionTypeEnum::WITHDRAWAL->value,
- TransactionTypeEnum::DEPOSIT->value,
- TransactionTypeEnum::RECONCILIATION->value,
- TransactionTypeEnum::TRANSFER->value,
- ])
- ;
- $journals = $this->collector->getExtractedJournals();
+ ->withAccountInformation()
+ ->setXorAccounts($accounts)
+ ->setTypes([
+ TransactionTypeEnum::WITHDRAWAL->value,
+ TransactionTypeEnum::DEPOSIT->value,
+ TransactionTypeEnum::RECONCILIATION->value,
+ TransactionTypeEnum::TRANSFER->value,
+ ]);
+ $journals = $this->collector->getExtractedJournals();
- $object = new AccountBalanceGrouped();
+ $object = new AccountBalanceGrouped();
$object->setPreferredRange($queryParameters['period']);
$object->setPrimary($this->primaryCurrency);
$object->setAccounts($accounts);
@@ -109,7 +108,7 @@ final class BalanceController extends Controller
$object->setStart($queryParameters['start']);
$object->setEnd($queryParameters['end']);
$object->groupByCurrencyAndPeriod();
- $data = $object->convertToChartData();
+ $data = $object->convertToChartData();
foreach ($data as $entry) {
$this->chartData[] = $entry;
}
diff --git a/app/Api/V1/Controllers/Chart/BudgetController.php b/app/Api/V1/Controllers/Chart/BudgetController.php
index bad1304a1d..c163e62e94 100644
--- a/app/Api/V1/Controllers/Chart/BudgetController.php
+++ b/app/Api/V1/Controllers/Chart/BudgetController.php
@@ -57,9 +57,9 @@ final class BudgetController extends Controller
protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];
protected OperationsRepositoryInterface $opsRepository;
- private BudgetLimitRepositoryInterface $blRepository;
- private array $currencies = [];
- private BudgetRepositoryInterface $repository;
+ private BudgetLimitRepositoryInterface $blRepository;
+ private array $currencies = [];
+ private BudgetRepositoryInterface $repository;
public function __construct()
{
@@ -88,10 +88,10 @@ final class BudgetController extends Controller
public function overview(DateRangeRequest $request): JsonResponse
{
/** @var Carbon $start */
- $start = $request->attributes->get('start');
+ $start = $request->attributes->get('start');
/** @var Carbon $end */
- $end = $request->attributes->get('end');
+ $end = $request->attributes->get('end');
// code from FrontpageChartGenerator, but not in separate class
$budgets = $this->repository->getActiveBudgets();
@@ -117,7 +117,7 @@ final class BudgetController extends Controller
if ($this->convertToPrimary) {
if ($current->transaction_currency_id === $this->primaryCurrency->id) {
// simply add it.
- $amount = bcadd($amount, (string) $current->amount);
+ $amount = bcadd($amount, (string)$current->amount);
Log::debug(sprintf('Set amount in limit to %s', $amount));
}
if ($current->transaction_currency_id !== $this->primaryCurrency->id) {
@@ -125,13 +125,13 @@ final class BudgetController extends Controller
$converted = $converter->convert($current->transactionCurrency, $this->primaryCurrency, $current->start_date, $current->amount);
$amount = bcadd($amount, $converted);
Log::debug(sprintf(
- 'Budgeted in limit #%d: %s %s, converted to %s %s',
- $current->id,
- $current->transactionCurrency->code,
- $current->amount,
- $this->primaryCurrency->code,
- $converted
- ));
+ 'Budgeted in limit #%d: %s %s, converted to %s %s',
+ $current->id,
+ $current->transactionCurrency->code,
+ $current->amount,
+ $this->primaryCurrency->code,
+ $converted
+ ));
Log::debug(sprintf('Set amount in limit to %s', $amount));
}
}
@@ -167,7 +167,7 @@ final class BudgetController extends Controller
*/
foreach ($expenses as $currencyId => $row) {
// budgeted, left and overspent are now 0.
- $limit = $this->filterLimit($currencyId, $limits);
+ $limit = $this->filterLimit($currencyId, $limits);
// primary currency entries
$row['pc_budgeted'] = '0';
@@ -177,7 +177,7 @@ final class BudgetController extends Controller
if ($limit instanceof BudgetLimit) {
$row['budgeted'] = $limit->amount;
- $row['left'] = bcsub((string) $row['budgeted'], bcmul((string) $row['spent'], '-1'));
+ $row['left'] = bcsub((string)$row['budgeted'], bcmul((string)$row['spent'], '-1'));
$row['overspent'] = bcmul($row['left'], '-1');
$row['left'] = 1 === bccomp($row['left'], '0') ? $row['left'] : '0';
$row['overspent'] = 1 === bccomp($row['overspent'], '0') ? $row['overspent'] : '0';
@@ -186,10 +186,10 @@ final class BudgetController extends Controller
// convert data if necessary.
if ($this->convertToPrimary && $currencyId !== $this->primaryCurrency->id) {
$currencies[$currencyId] ??= Amount::getTransactionCurrencyById($currencyId);
- $row['pc_budgeted'] = $converter->convert($currencies[$currencyId], $this->primaryCurrency, $start, $row['budgeted']);
- $row['pc_spent'] = $converter->convert($currencies[$currencyId], $this->primaryCurrency, $start, $row['spent']);
- $row['pc_left'] = $converter->convert($currencies[$currencyId], $this->primaryCurrency, $start, $row['left']);
- $row['pc_overspent'] = $converter->convert($currencies[$currencyId], $this->primaryCurrency, $start, $row['overspent']);
+ $row['pc_budgeted'] = $converter->convert($currencies[$currencyId], $this->primaryCurrency, $start, $row['budgeted']);
+ $row['pc_spent'] = $converter->convert($currencies[$currencyId], $this->primaryCurrency, $start, $row['spent']);
+ $row['pc_left'] = $converter->convert($currencies[$currencyId], $this->primaryCurrency, $start, $row['left']);
+ $row['pc_overspent'] = $converter->convert($currencies[$currencyId], $this->primaryCurrency, $start, $row['overspent']);
}
if ($this->convertToPrimary && $currencyId === $this->primaryCurrency->id) {
$row['pc_budgeted'] = $row['budgeted'];
@@ -197,33 +197,33 @@ final class BudgetController extends Controller
$row['pc_left'] = $row['left'];
$row['pc_overspent'] = $row['overspent'];
}
- $rows[] = $row;
+ $rows[] = $row;
}
// is always an array
- $return = [];
+ $return = [];
foreach ($rows as $row) {
$current = [
- 'label' => $budget->name,
- 'currency_id' => (string) $row['currency_id'],
- 'currency_name' => $row['currency_name'],
- 'currency_code' => $row['currency_code'],
- 'currency_decimal_places' => $row['currency_decimal_places'],
+ 'label' => $budget->name,
+ 'currency_id' => (string)$row['currency_id'],
+ 'currency_name' => $row['currency_name'],
+ 'currency_code' => $row['currency_code'],
+ 'currency_decimal_places' => $row['currency_decimal_places'],
- 'primary_currency_id' => (string) $this->primaryCurrency->id,
+ 'primary_currency_id' => (string)$this->primaryCurrency->id,
'primary_currency_name' => $this->primaryCurrency->name,
'primary_currency_code' => $this->primaryCurrency->code,
'primary_currency_symbol' => $this->primaryCurrency->symbol,
'primary_currency_decimal_places' => $this->primaryCurrency->decimal_places,
- 'period' => null,
- 'date' => $row['start'],
- 'start_date' => $row['start'],
- 'end_date' => $row['end'],
- 'yAxisID' => 0,
- 'type' => 'bar',
- 'entries' => ['budgeted' => $row['budgeted'], 'spent' => $row['spent'], 'left' => $row['left'], 'overspent' => $row['overspent']],
- 'pc_entries' => [
+ 'period' => null,
+ 'date' => $row['start'],
+ 'start_date' => $row['start'],
+ 'end_date' => $row['end'],
+ 'yAxisID' => 0,
+ 'type' => 'bar',
+ 'entries' => ['budgeted' => $row['budgeted'], 'spent' => $row['spent'], 'left' => $row['left'], 'overspent' => $row['overspent']],
+ 'pc_entries' => [
'budgeted' => $row['pc_budgeted'],
'spent' => $row['pc_spent'],
'left' => $row['pc_left'],
@@ -269,11 +269,11 @@ final class BudgetController extends Controller
foreach ($spent as $currencyId => $block) {
$this->currencies[$currencyId] ??= Amount::getTransactionCurrencyById($currencyId);
$return[$currencyId] ??= [
- 'currency_id' => (string) $currencyId,
+ 'currency_id' => (string)$currencyId,
'currency_code' => $block['currency_code'],
'currency_name' => $block['currency_name'],
'currency_symbol' => $block['currency_symbol'],
- 'currency_decimal_places' => (int) $block['currency_decimal_places'],
+ 'currency_decimal_places' => (int)$block['currency_decimal_places'],
'start' => $start->toAtomString(),
'end' => $end->toAtomString(),
'budgeted' => '0',
@@ -281,13 +281,13 @@ final class BudgetController extends Controller
'left' => '0',
'overspent' => '0',
];
- $currentBudgetArray = $block['budgets'][$budgetId];
+ $currentBudgetArray = $block['budgets'][$budgetId];
// var_dump($return);
/** @var array $journal */
foreach ($currentBudgetArray['transaction_journals'] as $journal) {
/** @var numeric-string $amount */
- $amount = (string) $journal['amount'];
+ $amount = (string)$journal['amount'];
$return[$currencyId]['spent'] = bcadd($return[$currencyId]['spent'], $amount);
}
}
diff --git a/app/Api/V1/Controllers/Chart/CategoryController.php b/app/Api/V1/Controllers/Chart/CategoryController.php
index f2c96f179d..45650e28ec 100644
--- a/app/Api/V1/Controllers/Chart/CategoryController.php
+++ b/app/Api/V1/Controllers/Chart/CategoryController.php
@@ -54,7 +54,7 @@ final class CategoryController extends Controller
#[Override]
protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];
- private AccountRepositoryInterface $accountRepos;
+ private AccountRepositoryInterface $accountRepos;
private CurrencyRepositoryInterface $currencyRepos;
public function __construct()
@@ -84,32 +84,32 @@ final class CategoryController extends Controller
public function overview(DateRangeRequest $request): JsonResponse
{
/** @var Carbon $start */
- $start = $request->attributes->get('start');
+ $start = $request->attributes->get('start');
/** @var Carbon $end */
$end = $request->attributes->get('end');
$accounts = $this->accountRepos->getAccountsByType([
- AccountTypeEnum::DEBT->value,
- AccountTypeEnum::LOAN->value,
- AccountTypeEnum::MORTGAGE->value,
- AccountTypeEnum::ASSET->value,
- ]);
+ AccountTypeEnum::DEBT->value,
+ AccountTypeEnum::LOAN->value,
+ AccountTypeEnum::MORTGAGE->value,
+ AccountTypeEnum::ASSET->value,
+ ]);
$currencies = [];
$return = [];
$converter = new ExchangeRateConverter();
// get journals for entire period:
/** @var GroupCollectorInterface $collector */
- $collector = app(GroupCollectorInterface::class);
+ $collector = app(GroupCollectorInterface::class);
$collector->setRange($start, $end)->withAccountInformation();
$collector->setXorAccounts($accounts)->withCategoryInformation();
$collector->setTypes([TransactionTypeEnum::WITHDRAWAL->value, TransactionTypeEnum::DEPOSIT->value]);
- $journals = $collector->getExtractedJournals();
+ $journals = $collector->getExtractedJournals();
/** @var array $journal */
foreach ($journals as $journal) {
// find journal:
- $journalCurrencyId = (int) $journal['currency_id'];
+ $journalCurrencyId = (int)$journal['currency_id'];
$type = $journal['transaction_type_type'];
$currency = $currencies[$journalCurrencyId] ?? $this->currencyRepos->find($journalCurrencyId);
$currencies[$journalCurrencyId] = $currency;
@@ -118,7 +118,7 @@ final class CategoryController extends Controller
$currencyCode = $currency->code;
$currencySymbol = $currency->symbol;
$currencyDecimalPlaces = $currency->decimal_places;
- $amount = Steam::positive((string) $journal['amount']);
+ $amount = Steam::positive((string)$journal['amount']);
$pcAmount = null;
// overrule if necessary:
@@ -135,17 +135,17 @@ final class CategoryController extends Controller
Log::debug(sprintf('Converted %s %s to %s %s', $journal['currency_code'], $amount, $this->primaryCurrency->code, $pcAmount));
}
- $categoryName = $journal['category_name'] ?? (string) trans('firefly.no_category');
- $key = sprintf('%s-%s', $categoryName, $currencyCode);
+ $categoryName = $journal['category_name'] ?? (string)trans('firefly.no_category');
+ $key = sprintf('%s-%s', $categoryName, $currencyCode);
// create arrays
$return[$key] ??= [
'label' => $categoryName,
- 'currency_id' => (string) $currencyId,
+ 'currency_id' => (string)$currencyId,
'currency_name' => $currencyName,
'currency_code' => $currencyCode,
'currency_symbol' => $currencySymbol,
'currency_decimal_places' => $currencyDecimalPlaces,
- 'primary_currency_id' => (string) $this->primaryCurrency->id,
+ 'primary_currency_id' => (string)$this->primaryCurrency->id,
'primary_currency_name' => $this->primaryCurrency->name,
'primary_currency_code' => $this->primaryCurrency->code,
'primary_currency_symbol' => $this->primaryCurrency->symbol,
@@ -177,13 +177,13 @@ final class CategoryController extends Controller
}
}
}
- $return = array_values($return);
+ $return = array_values($return);
// order by amount
- usort($return, static fn (array $a, array $b): int => ((float) $a['entries']['spent'] + (float) $a['entries']['earned'])
- < ((float) $b['entries']['spent'] + (float) $b['entries']['earned'])
- ? 1
- : -1);
+ usort($return, static fn(array $a, array $b): int => ((float)$a['entries']['spent'] + (float)$a['entries']['earned'])
+ < ((float)$b['entries']['spent'] + (float)$b['entries']['earned'])
+ ? 1
+ : -1);
return response()->json($this->clean($return));
}
diff --git a/app/Api/V1/Controllers/Controller.php b/app/Api/V1/Controllers/Controller.php
index f43efe0238..399b03ab1b 100644
--- a/app/Api/V1/Controllers/Controller.php
+++ b/app/Api/V1/Controllers/Controller.php
@@ -63,18 +63,15 @@ abstract class Controller extends BaseController
use ValidatesRequests;
use ValidatesUserGroupTrait;
- protected array $acceptedRoles = [];
-
protected const string CONTENT_TYPE = 'application/vnd.api+json';
protected const string JSON_CONTENT_TYPE = 'application/json';
+ protected array $acceptedRoles = [];
+ protected array $accepts = ['application/json', 'application/vnd.api+json'];
- protected array $accepts = ['application/json', 'application/vnd.api+json'];
-
- protected bool $convertToPrimary = false;
- protected TransactionCurrency $primaryCurrency;
-
+ protected bool $convertToPrimary = false;
/** @deprecated use Request classes */
protected ParameterBag $parameters;
+ protected TransactionCurrency $primaryCurrency;
/**
* Controller constructor.
@@ -119,14 +116,14 @@ abstract class Controller extends BaseController
$params[$key] = $value;
}
- return $return.http_build_query($params);
+ return $return . http_build_query($params);
}
final protected function getManager(): Manager
{
// create some objects:
$manager = new Manager();
- $baseUrl = request()->getSchemeAndHttpHost().'/api/v1';
+ $baseUrl = request()->getSchemeAndHttpHost() . '/api/v1';
$manager->setSerializer(new JsonApiSerializer($baseUrl));
return $manager;
@@ -134,14 +131,14 @@ abstract class Controller extends BaseController
final protected function jsonApiList(string $key, LengthAwarePaginator $paginator, AbstractTransformer $transformer): array
{
- $manager = new Manager();
- $baseUrl = sprintf('%s/api/v1/', request()->getSchemeAndHttpHost());
+ $manager = new Manager();
+ $baseUrl = sprintf('%s/api/v1/', request()->getSchemeAndHttpHost());
// TODO add stuff to path?
$manager->setSerializer(new JsonApiSerializer($baseUrl));
- $objects = $paginator->getCollection();
+ $objects = $paginator->getCollection();
// the transformer, at this point, needs to collect information that ALL items in the collection
// require, like meta-data and stuff like that, and save it for later.
@@ -159,11 +156,11 @@ abstract class Controller extends BaseController
*
* @param array<int, mixed>|Model $object
*/
- final protected function jsonApiObject(string $key, array|Model $object, AbstractTransformer $transformer): array
+ final protected function jsonApiObject(string $key, array | Model $object, AbstractTransformer $transformer): array
{
// create some objects:
- $manager = new Manager();
- $baseUrl = sprintf('%s/api/v1', request()->getSchemeAndHttpHost());
+ $manager = new Manager();
+ $baseUrl = sprintf('%s/api/v1', request()->getSchemeAndHttpHost());
$manager->setSerializer(new JsonApiSerializer($baseUrl));
$resource = new Item($object, $transformer, $key);
@@ -174,16 +171,17 @@ abstract class Controller extends BaseController
#[Deprecated(message: <<<'TXT'
use Request classes
Method to grab all parameters from the URL
- TXT)]
+ TXT
+ )]
private function getParameters(): ParameterBag
{
- $bag = new ParameterBag();
- $page = (int) request()->get('page');
- $page = clamp(value: $page, min: 1, max: 2 ** 16);
+ $bag = new ParameterBag();
+ $page = (int)request()->get('page');
+ $page = clamp(value: $page, min: 1, max: 2 ** 16);
$bag->set('page', $page);
// some date fields:
- $dates = ['start', 'end', 'date'];
+ $dates = ['start', 'end', 'date'];
foreach ($dates as $field) {
$date = null;
@@ -194,13 +192,13 @@ abstract class Controller extends BaseController
Log::error($e->getMessage());
Log::error($e->getTraceAsString());
}
- $obj = null;
+ $obj = null;
if (null !== $date) {
try {
- $obj = Carbon::parse((string) $date, config('app.timezone'));
+ $obj = Carbon::parse((string)$date, config('app.timezone'));
} catch (InvalidFormatException $e) {
// don't care
- Log::warning(sprintf('Ignored invalid date "%s" in API controller parameter check: %s', substr((string) $date, 0, 20), $e->getMessage()));
+ Log::warning(sprintf('Ignored invalid date "%s" in API controller parameter check: %s', substr((string)$date, 0, 20), $e->getMessage()));
}
}
if ($obj instanceof Carbon) {
@@ -220,7 +218,7 @@ abstract class Controller extends BaseController
$value = null;
}
if (null !== $value) {
- $value = (int) $value;
+ $value = (int)$value;
$value = clamp($value, 1, 2 ** 16);
$bag->set($integer, $value);
}
@@ -228,9 +226,9 @@ abstract class Controller extends BaseController
if (null === $value && auth()->check()) {
// set default for user:
/** @var User $user */
- $user = auth()->user();
+ $user = auth()->user();
- $pageSize = (int) Preferences::getForUser($user, 'listPageSize', 50)->data;
+ $pageSize = (int)Preferences::getForUser($user, 'listPageSize', 50)->data;
$bag->set($integer, $pageSize);
}
}
diff --git a/app/Api/V1/Controllers/Data/Bulk/TransactionController.php b/app/Api/V1/Controllers/Data/Bulk/TransactionController.php
index 8e2b194e93..f8d4f7bdd8 100644
--- a/app/Api/V1/Controllers/Data/Bulk/TransactionController.php
+++ b/app/Api/V1/Controllers/Data/Bulk/TransactionController.php
@@ -45,10 +45,9 @@ use Override;
*/
final class TransactionController extends Controller
{
- private AccountRepositoryInterface $repository;
-
#[Override]
protected array $acceptedRoles = [UserRoleEnum::MANAGE_TRANSACTIONS];
+ private AccountRepositoryInterface $repository;
public function __construct()
{
@@ -72,11 +71,11 @@ final class TransactionController extends Controller
// to respond to what is in the $query.
// this is OK because only one thing can be in the query at the moment.
if ($this->isUpdateTransactionAccount($params)) {
- $original = $this->repository->find((int) $params['where']['account_id']);
- $destination = $this->repository->find((int) $params['update']['account_id']);
+ $original = $this->repository->find((int)$params['where']['account_id']);
+ $destination = $this->repository->find((int)$params['update']['account_id']);
/** @var AccountDestroyService $service */
- $service = app(AccountDestroyService::class);
+ $service = app(AccountDestroyService::class);
$service->moveTransactions($original, $destination);
}
diff --git a/app/Api/V1/Controllers/Data/DestroyController.php b/app/Api/V1/Controllers/Data/DestroyController.php
index 494f1a91b3..6544adf48f 100644
--- a/app/Api/V1/Controllers/Data/DestroyController.php
+++ b/app/Api/V1/Controllers/Data/DestroyController.php
@@ -57,10 +57,9 @@ use Override;
*/
final class DestroyController extends Controller
{
- private bool $unused;
-
#[Override]
protected array $acceptedRoles = [UserRoleEnum::FULL];
+ private bool $unused;
public function __construct()
{
@@ -74,8 +73,8 @@ final class DestroyController extends Controller
public function destroy(DestroyRequest $request): JsonResponse
{
- $objects = $request->getObjects();
- $this->unused = $request->boolean('unused');
+ $objects = $request->getObjects();
+ $this->unused = $request->boolean('unused');
$allExceptAssets = [
AccountTypeEnum::BENEFICIARY->value,
@@ -177,11 +176,11 @@ final class DestroyController extends Controller
private function destroyBudgets(): void
{
/** @var AvailableBudgetRepositoryInterface $abRepository */
- $abRepository = app(AvailableBudgetRepositoryInterface::class);
+ $abRepository = app(AvailableBudgetRepositoryInterface::class);
$abRepository->destroyAll();
/** @var BudgetLimitRepositoryInterface $blRepository */
- $blRepository = app(BudgetLimitRepositoryInterface::class);
+ $blRepository = app(BudgetLimitRepositoryInterface::class);
$blRepository->destroyAll();
/** @var BudgetRepositoryInterface $budgetRepository */
diff --git a/app/Api/V1/Controllers/Data/Export/ExportController.php b/app/Api/V1/Controllers/Data/Export/ExportController.php
index c3c7ce42e7..a71b867273 100644
--- a/app/Api/V1/Controllers/Data/Export/ExportController.php
+++ b/app/Api/V1/Controllers/Data/Export/ExportController.php
@@ -33,7 +33,6 @@ use Illuminate\Http\Request;
use Illuminate\Http\Response as LaravelResponse;
use Override;
use Safe\Exceptions\DatetimeException;
-
use function Safe\date;
/**
@@ -41,9 +40,9 @@ use function Safe\date;
*/
final class ExportController extends Controller
{
- private ExportDataGenerator $exporter;
#[Override]
- protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];
+ protected array $acceptedRoles = [UserRoleEnum::READ_ONLY];
+ private ExportDataGenerator $exporter;
/**
* ExportController constructor.
@@ -195,14 +194,13 @@ final class ExportController extends Controller
$response
->header('Content-Description', 'File Transfer')
->header('Content-Type', 'application/octet-stream')
- ->header('Content-Disposition', 'attachment; filename='.$fileName)
+ ->header('Content-Disposition', 'attachment; filename=' . $fileName)
->header('Content-Transfer-Encoding', 'binary')
->header('Connection', 'Keep-Alive')
->header('Expires', '0')
->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0')
->header('Pragma', 'public')
- ->header('Content-Length', (string) strlen((string) $data[$key]))
- ;
+ ->header('Content-Length', (string)strlen((string)$data[$key]));
return $response;
}
diff --git a/app/Api/V1/Controllers/Data/PurgeController.php b/app/Api/V1/Controllers/Data/PurgeController.php
index 19d39520f8..7acb778639 100644
--- a/app/Api/V1/Controllers/Data/PurgeController.php
+++ b/app/Api/V1/Controllers/Data/PurgeController.php
@@ -67,7 +67,7 @@ final class PurgeController extends Controller
public function purge(): JsonResponse
{
/** @var User $user */
- $user = auth()->user();
+ $user = auth()->user();
// some manual code, too lazy to call all repositories.
diff --git a/app/Api/V1/Controllers/Insight/Expense/AccountController.php b/app/Api/V1/Controllers/Insight/Expense/AccountController.php
index eea69b2355..0313b859cc 100644
--- a/app/Api/V1/Controllers/Insight/Expense/AccountController.php
+++ b/app/Api/V1/Controllers/Insight/Expense/AccountController.php
@@ -42,7 +42,7 @@ final class AccountController extends Controller
use ApiSupport;
private OperationsRepositoryInterface $opsRepository;
- private AccountRepositoryInterface $repository;
+ private AccountRepositoryInterface $repository;
/**
* AccountController constructor.
@@ -51,8 +51,8 @@ final class AccountController extends Controller
{
parent::__construct();
$this->middleware(function ($request, $next) {
- $user = auth()->user();
- $this->repository = app(AccountRepositoryInterface::class);
+ $user = auth()->user();
+ $this->repository = app(AccountRepositoryInterface::class);
$this->repository->setUser($user);
$this->opsRepository = app(OperationsRepositoryInterface::class);
@@ -73,11 +73,11 @@ final class AccountController extends Controller
/** @var array $expense */
foreach ($expenses as $expense) {
$result[] = [
- 'id' => (string) $expense['id'],
+ 'id' => (string)$expense['id'],
'name' => $expense['name'],
'difference' => $expense['sum'],
- 'difference_float' => (float) $expense['sum'], // intentional float
- 'currency_id' => (string) $expense['currency_id'],
+ 'difference_float' => (float)$expense['sum'], // intentional float
+ 'currency_id' => (string)$expense['currency_id'],
'currency_code' => $expense['currency_code'],
];
}
@@ -97,11 +97,11 @@ final class AccountController extends Controller
/** @var array $expense */
foreach ($expenses as $expense) {
$result[] = [
- 'id' => (string) $expense['id'],
+ 'id' => (string)$expense['id'],
'name' => $expense['name'],
'difference' => $expense['sum'],
- 'difference_float' => (float) $expense['sum'], // intentional float
- 'currency_id' => (string) $expense['currency_id'],
+ 'difference_float' => (float)$expense['sum'], // intentional float
+ 'currency_id' => (string)$expense['currency_id'],
'currency_code' => $expense['currency_code'],
];
}
diff --git a/app/Api/V1/Controllers/Insight/Expense/BillController.php b/app/Api/V1/Controllers/Insight/Expense/BillController.php
index 8680b38dbc..d4497cb76c 100644
--- a/app/Api/V1/Controllers/Insight/Expense/BillController.php
+++ b/app/Api/V1/Controllers/Insight/Expense/BillController.php
@@ -74,14 +74,14 @@ final class BillController extends Controller
}
// collect all expenses in this period (regardless of type) by the given bills and accounts.
- $collector = app(GroupCollectorInterface::class);
+ $collector = app(GroupCollectorInterface::class);
$collector->setTypes([TransactionTypeEnum::WITHDRAWAL->value])->setRange($start, $end)->setSourceAccounts($accounts);
$collector->setBills($bills);
- $genericSet = $collector->getExtractedJournals();
+ $genericSet = $collector->getExtractedJournals();
foreach ($genericSet as $journal) {
- $billId = (int) $journal['bill_id'];
- $currencyId = (int) $journal['currency_id'];
+ $billId = (int)$journal['bill_id'];
+ $currencyId = (int)$journal['currency_id'];
$currencyCode = $journal['currency_code'];
$field = 'amount';
@@ -96,27 +96,27 @@ final class BillController extends Controller
$field = 'foreign_amount';
}
Log::debug(sprintf(
- 'Journal #%d in bill #%d will use %s (%s %s)',
- $journal['transaction_group_id'],
- $billId,
- $field,
- $currencyCode,
- $journal[$field] ?? '0'
- ));
+ 'Journal #%d in bill #%d will use %s (%s %s)',
+ $journal['transaction_group_id'],
+ $billId,
+ $field,
+ $currencyCode,
+ $journal[$field] ?? '0'
+ ));
- $key = sprintf('%d-%d', $billId, $currencyId);
+ $key = sprintf('%d-%d', $billId, $currencyId);
if (0 !== $currencyId) {
- $response[$key] ??= [
- 'id' => (string) $billId,
+ $response[$key] ??= [
+ 'id' => (string)$billId,
'name' => $journal['bill_name'],
'difference' => '0',
'difference_float' => 0,
- 'currency_id' => (string) $currencyId,
+ 'currency_id' => (string)$currencyId,
'currency_code' => $currencyCode,
];
- $response[$key]['difference'] = bcadd($response[$key]['difference'], (string) ($journal[$field] ?? '0'));
- $response[$key]['difference_float'] = (float) $response[$key]['difference']; // intentional float
+ $response[$key]['difference'] = bcadd($response[$key]['difference'], (string)($journal[$field] ?? '0'));
+ $response[$key]['difference_float'] = (float)$response[$key]['difference']; // intentional float
}
}
@@ -136,14 +136,14 @@ final class BillController extends Controller
$response = [];
// collect all expenses in this period (regardless of type) by the given bills and accounts.
- $collector = app(GroupCollectorInterface::class);
+ $collector = app(GroupCollectorInterface::class);
$collector->setTypes([TransactionTypeEnum::WITHDRAWAL->value])->setRange($start, $end)->setSourceAccounts($accounts);
$collector->withoutBill();
- $genericSet = $collector->getExtractedJournals();
+ $genericSet = $collector->getExtractedJournals();
foreach ($genericSet as $journal) {
- $currencyId = (int) $journal['currency_id'];
+ $currencyId = (int)$journal['currency_id'];
$currencyCode = $journal['currency_code'];
$field = 'amount';
@@ -160,14 +160,14 @@ final class BillController extends Controller
Log::debug(sprintf('Journal #%d will use %s (%s %s)', $journal['transaction_group_id'], $field, $currencyCode, $journal[$field] ?? '0'));
if (0 !== $currencyId) {
- $response[$currencyId] ??= [
+ $response[$currencyId] ??= [
'difference' => '0',
'difference_float' => 0,
- 'currency_id' => (string) $currencyId,
+ 'currency_id' => (string)$currencyId,
'currency_code' => $currencyCode,
];
- $response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], (string) ($journal[$field] ?? '0'));
- $response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference']; // intentional float
+ $response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], (string)($journal[$field] ?? '0'));
+ $response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference']; // intentional float
}
}
diff --git a/app/Api/V1/Controllers/Insight/Expense/BudgetController.php b/app/Api/V1/Controllers/Insight/Expense/BudgetController.php
index 0d6c227707..68326da1e6 100644
--- a/app/Api/V1/Controllers/Insight/Expense/BudgetController.php
+++ b/app/Api/V1/Controllers/Insight/Expense/BudgetController.php
@@ -38,9 +38,9 @@ use Illuminate\Support\Collection;
*/
final class BudgetController extends Controller
{
- private NoBudgetRepositoryInterface $noRepository;
+ private NoBudgetRepositoryInterface $noRepository;
private OperationsRepositoryInterface $opsRepository;
- private BudgetRepositoryInterface $repository;
+ private BudgetRepositoryInterface $repository;
/**
* AccountController constructor.
@@ -79,11 +79,11 @@ final class BudgetController extends Controller
/** @var array $expense */
foreach ($expenses as $expense) {
$result[] = [
- 'id' => (string) $budget->id,
+ 'id' => (string)$budget->id,
'name' => $budget->name,
'difference' => $expense['sum'],
- 'difference_float' => (float) $expense['sum'], // intentional float
- 'currency_id' => (string) $expense['currency_id'],
+ 'difference_float' => (float)$expense['sum'], // intentional float
+ 'currency_id' => (string)$expense['currency_id'],
'currency_code' => $expense['currency_code'],
];
}
@@ -104,8 +104,8 @@ final class BudgetController extends Controller
foreach ($expenses as $expense) {
$result[] = [
'difference' => $expense['sum'],
- 'difference_float' => (float) $expense['sum'], // intentional float
- 'currency_id' => (string) $expense['currency_id'],
+ 'difference_float' => (float)$expense['sum'], // intentional float
+ 'currency_id' => (string)$expense['currency_id'],
'currency_code' => $expense['currency_code'],
];
}
diff --git a/app/Api/V1/Controllers/Insight/Expense/CategoryController.php b/app/Api/V1/Controllers/Insight/Expense/CategoryController.php
index a5e546ea0b..9adfd7ee4a 100644
--- a/app/Api/V1/Controllers/Insight/Expense/CategoryController.php
+++ b/app/Api/V1/Controllers/Insight/Expense/CategoryController.php
@@ -40,7 +40,7 @@ final class CategoryController extends Controller
{
private NoCategoryRepositoryInterface $noRepository;
private OperationsRepositoryInterface $opsRepository;
- private CategoryRepositoryInterface $repository;
+ private CategoryRepositoryInterface $repository;
/**
* AccountController constructor.
@@ -79,11 +79,11 @@ final class CategoryController extends Controller
/** @var array $expense */
foreach ($expenses as $expense) {
$result[] = [
- 'id' => (string) $category->id,
+ 'id' => (string)$category->id,
'name' => $category->name,
'difference' => $expense['sum'],
- 'difference_float' => (float) $expense['sum'], // intentional float
- 'currency_id' => (string) $expense['currency_id'],
+ 'difference_float' => (float)$expense['sum'], // intentional float
+ 'currency_id' => (string)$expense['currency_id'],
'currency_code' => $expense['currency_code'],
];
}
@@ -104,8 +104,8 @@ final class CategoryController extends Controller
foreach ($expenses as $expense) {
$result[] = [
'difference' => $expense['sum'],
- 'difference_float' => (float) $expense['sum'], // intentional float
- 'currency_id' => (string) $expense['currency_id'],
+ 'difference_float' => (float)$expense['sum'], // intentional float
+ 'currency_id' => (string)$expense['currency_id'],
'currency_code' => $expense['currency_code'],
];
}
diff --git a/app/Api/V1/Controllers/Insight/Expense/PeriodController.php b/app/Api/V1/Controllers/Insight/Expense/PeriodController.php
index 5ab2c350fd..0bbd4b2181 100644
--- a/app/Api/V1/Controllers/Insight/Expense/PeriodController.php
+++ b/app/Api/V1/Controllers/Insight/Expense/PeriodController.php
@@ -47,21 +47,21 @@ final class PeriodController extends Controller
$primary = Amount::getPrimaryCurrency();
// collect all expenses in this period (regardless of type)
- $collector = app(GroupCollectorInterface::class);
+ $collector = app(GroupCollectorInterface::class);
$collector->setTypes([TransactionTypeEnum::WITHDRAWAL->value])->setRange($start, $end)->setSourceAccounts($accounts);
- $genericSet = $collector->getExtractedJournals();
+ $genericSet = $collector->getExtractedJournals();
foreach ($genericSet as $journal) {
// same code as many other sumExpense methods. I think this needs some kind of generic method.
- $amount = '0';
- $currencyId = (int) $journal['currency_id'];
- $currencyCode = $journal['currency_code'];
+ $amount = '0';
+ $currencyId = (int)$journal['currency_id'];
+ $currencyCode = $journal['currency_code'];
if ($convertToPrimary) {
$amount = Amount::getAmountFromJournal($journal);
- if ($primary->id !== (int) $journal['currency_id'] && $primary->id !== (int) $journal['foreign_currency_id']) {
+ if ($primary->id !== (int)$journal['currency_id'] && $primary->id !== (int)$journal['foreign_currency_id']) {
$currencyId = $primary->id;
$currencyCode = $primary->code;
}
- if ($primary->id !== (int) $journal['currency_id'] && $primary->id === (int) $journal['foreign_currency_id']) {
+ if ($primary->id !== (int)$journal['currency_id'] && $primary->id === (int)$journal['foreign_currency_id']) {
$currencyId = $journal['foreign_currency_id'];
$currencyCode = $journal['foreign_currency_code'];
}
@@ -73,14 +73,14 @@ final class PeriodController extends Controller
$amount = $journal['amount'];
}
- $response[$currencyId] ??= [
+ $response[$currencyId] ??= [
'difference' => '0',
'difference_float' => 0,
- 'currency_id' => (string) $currencyId,
+ 'currency_id' => (string)$currencyId,
'currency_code' => $currencyCode,
];
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], $amount);
- $response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference']; // intentional float
+ $response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference']; // intentional float
}
return response()->json(array_values($response));
diff --git a/app/Api/V1/Controllers/Insight/Expense/TagController.php b/app/Api/V1/Controllers/Insight/Expense/TagController.php
index ad399ccb65..9a3c11e7e6 100644
--- a/app/Api/V1/Controllers/Insight/Expense/TagController.php
+++ b/app/Api/V1/Controllers/Insight/Expense/TagController.php
@@ -67,24 +67,24 @@ final class TagController extends Controller
$primary = Amount::getPrimaryCurrency();
// collect all expenses in this period (regardless of type) by the given bills and accounts.
- $collector = app(GroupCollectorInterface::class);
+ $collector = app(GroupCollectorInterface::class);
$collector->setTypes([TransactionTypeEnum::WITHDRAWAL->value])->setRange($start, $end)->setSourceAccounts($accounts);
$collector->withoutTags();
- $genericSet = $collector->getExtractedJournals();
+ $genericSet = $collector->getExtractedJournals();
foreach ($genericSet as $journal) {
// same code as many other sumExpense methods. I think this needs some kind of generic method.
- $amount = '0';
- $currencyId = (int) $journal['currency_id'];
- $currencyCode = $journal['currency_code'];
+ $amount = '0';
+ $currencyId = (int)$journal['currency_id'];
+ $currencyCode = $journal['currency_code'];
if ($convertToPrimary) {
$amount = Amount::getAmountFromJournal($journal);
- if ($primary->id !== (int) $journal['currency_id'] && $primary->id !== (int) $journal['foreign_currency_id']) {
+ if ($primary->id !== (int)$journal['currency_id'] && $primary->id !== (int)$journal['foreign_currency_id']) {
$currencyId = $primary->id;
$currencyCode = $primary->code;
}
- if ($primary->id !== (int) $journal['currency_id'] && $primary->id === (int) $journal['foreign_currency_id']) {
+ if ($primary->id !== (int)$journal['currency_id'] && $primary->id === (int)$journal['foreign_currency_id']) {
$currencyId = $journal['foreign_currency_id'];
$currencyCode = $journal['foreign_currency_code'];
}
@@ -96,14 +96,14 @@ final class TagController extends Controller
$amount = $journal['amount'];
}
- $response[$currencyId] ??= [
+ $response[$currencyId] ??= [
'difference' => '0',
'difference_float' => 0,
- 'currency_id' => (string) $currencyId,
+ 'currency_id' => (string)$currencyId,
'currency_code' => $currencyCode,
];
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], $amount);
- $response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference']; // float but on purpose.
+ $response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference']; // float but on purpose.
}
return response()->json(array_values($response));
@@ -114,11 +114,11 @@ final class TagController extends Controller
*/
public function tag(GenericRequest $request): JsonResponse
{
- $accounts = $request->getAssetAccounts();
- $tags = $request->getTags();
- $start = $request->getStart();
- $end = $request->getEnd();
- $response = [];
+ $accounts = $request->getAssetAccounts();
+ $tags = $request->getTags();
+ $start = $request->getStart();
+ $end = $request->getEnd();
+ $response = [];
// get all tags:
if (0 === $tags->count()) {
@@ -126,15 +126,15 @@ final class TagController extends Controller
}
// collect all expenses in this period (regardless of type) by the given bills and accounts.
- $collector = app(GroupCollectorInterface::class);
+ $collector = app(GroupCollectorInterface::class);
$collector->setTypes([TransactionTypeEnum::WITHDRAWAL->value])->setRange($start, $end)->setSourceAccounts($accounts);
$collector->setTags($tags);
$genericSet = $collector->getExtractedJournals();
/** @var array $journal */
foreach ($genericSet as $journal) {
- $currencyId = (int) $journal['currency_id'];
- $foreignCurrencyId = (int) $journal['foreign_currency_id'];
+ $currencyId = (int)$journal['currency_id'];
+ $foreignCurrencyId = (int)$journal['foreign_currency_id'];
/** @var array $tag */
foreach ($journal['tags'] as $tag) {
@@ -144,16 +144,16 @@ final class TagController extends Controller
// on currency ID
if (0 !== $currencyId) {
- $response[$key] ??= [
- 'id' => (string) $tagId,
+ $response[$key] ??= [
+ 'id' => (string)$tagId,
'name' => $tag['name'],
'difference' => '0',
'difference_float' => 0,
- 'currency_id' => (string) $currencyId,
+ 'currency_id' => (string)$currencyId,
'currency_code' => $journal['currency_code'],
];
- $response[$key]['difference'] = bcadd((string) $response[$key]['difference'], (string) $journal['amount']);
- $response[$key]['difference_float'] = (float) $response[$key]['difference']; // float but on purpose.
+ $response[$key]['difference'] = bcadd((string)$response[$key]['difference'], (string)$journal['amount']);
+ $response[$key]['difference_float'] = (float)$response[$key]['difference']; // float but on purpose.
}
// on foreign ID
@@ -161,11 +161,11 @@ final class TagController extends Controller
$response[$foreignKey] = $journal[$foreignKey] ?? [
'difference' => '0',
'difference_float' => 0,
- 'currency_id' => (string) $foreignCurrencyId,
+ 'currency_id' => (string)$foreignCurrencyId,
'currency_code' => $journal['foreign_currency_code'],
];
- $response[$foreignKey]['difference'] = bcadd((string) $response[$foreignKey]['difference'], (string) $journal['foreign_amount']);
- $response[$foreignKey]['difference_float'] = (float) $response[$foreignKey]['difference']; // float but on purpose.
+ $response[$foreignKey]['difference'] = bcadd((string)$response[$foreignKey]['difference'], (string)$journal['foreign_amount']);
+ $response[$foreignKey]['difference_float'] = (float)$response[$foreignKey]['difference']; // float but on purpose.
}
}
}
diff --git a/app/Api/V1/Controllers/Insight/Income/AccountController.php b/app/Api/V1/Controllers/Insight/Income/AccountController.php
index 66fe0807b8..61c737e937 100644
--- a/app/Api/V1/Controllers/Insight/Income/AccountController.php
+++ b/app/Api/V1/Controllers/Insight/Income/AccountController.php
@@ -42,7 +42,7 @@ final class AccountController extends Controller
use ApiSupport;
private OperationsRepositoryInterface $opsRepository;
- private AccountRepositoryInterface $repository;
+ private AccountRepositoryInterface $repository;
/**
* AccountController constructor.
@@ -51,8 +51,8 @@ final class AccountController extends Controller
{
parent::__construct();
$this->middleware(function ($request, $next) {
- $user = auth()->user();
- $this->repository = app(AccountRepositoryInterface::class);
+ $user = auth()->user();
+ $this->repository = app(AccountRepositoryInterface::class);
$this->repository->setUser($user);
$this->opsRepository = app(OperationsRepositoryInterface::class);
@@ -68,17 +68,17 @@ final class AccountController extends Controller
$end = $request->getEnd();
$assetAccounts = $request->getAssetAccounts();
- $income = $this->opsRepository->sumIncomeByDestination($start, $end, $assetAccounts);
- $result = [];
+ $income = $this->opsRepository->sumIncomeByDestination($start, $end, $assetAccounts);
+ $result = [];
/** @var array $entry */
foreach ($income as $entry) {
$result[] = [
- 'id' => (string) $entry['id'],
+ 'id' => (string)$entry['id'],
'name' => $entry['name'],
'difference' => $entry['sum'],
- 'difference_float' => (float) $entry['sum'], // float but on purpose.
- 'currency_id' => (string) $entry['currency_id'],
+ 'difference_float' => (float)$entry['sum'], // float but on purpose.
+ 'currency_id' => (string)$entry['currency_id'],
'currency_code' => $entry['currency_code'],
];
}
@@ -98,11 +98,11 @@ final class AccountController extends Controller
/** @var array $entry */
foreach ($income as $entry) {
$result[] = [
- 'id' => (string) $entry['id'],
+ 'id' => (string)$entry['id'],
'name' => $entry['name'],
'difference' => $entry['sum'],
- 'difference_float' => (float) $entry['sum'], // float but on purpose.
- 'currency_id' => (string) $entry['currency_id'],
+ 'difference_float' => (float)$entry['sum'], // float but on purpose.
+ 'currency_id' => (string)$entry['currency_id'],
'currency_code' => $entry['currency_code'],
];
}
diff --git a/app/Api/V1/Controllers/Insight/Income/CategoryController.php b/app/Api/V1/Controllers/Insight/Income/CategoryController.php
index a81bf91be9..345cb1d39d 100644
--- a/app/Api/V1/Controllers/Insight/Income/CategoryController.php
+++ b/app/Api/V1/Controllers/Insight/Income/CategoryController.php
@@ -40,7 +40,7 @@ final class CategoryController extends Controller
{
private NoCategoryRepositoryInterface $noRepository;
private OperationsRepositoryInterface $opsRepository;
- private CategoryRepositoryInterface $repository;
+ private CategoryRepositoryInterface $repository;
/**
* AccountController constructor.
@@ -79,11 +79,11 @@ final class CategoryController extends Controller
/** @var array $expense */
foreach ($expenses as $expense) {
$result[] = [
- 'id' => (string) $category->id,
+ 'id' => (string)$category->id,
'name' => $category->name,
'difference' => $expense['sum'],
- 'difference_float' => (float) $expense['sum'], // float but on purpose.
- 'currency_id' => (string) $expense['currency_id'],
+ 'difference_float' => (float)$expense['sum'], // float but on purpose.
+ 'currency_id' => (string)$expense['currency_id'],
'currency_code' => $expense['currency_code'],
];
}
@@ -104,8 +104,8 @@ final class CategoryController extends Controller
foreach ($expenses as $expense) {
$result[] = [
'difference' => $expense['sum'],
- 'difference_float' => (float) $expense['sum'], // float but on purpose.
- 'currency_id' => (string) $expense['currency_id'],
+ 'difference_float' => (float)$expense['sum'], // float but on purpose.
+ 'currency_id' => (string)$expense['currency_id'],
'currency_code' => $expense['currency_code'],
];
}
diff --git a/app/Api/V1/Controllers/Insight/Income/PeriodController.php b/app/Api/V1/Controllers/Insight/Income/PeriodController.php
index b972335a4c..c4ba659ea0 100644
--- a/app/Api/V1/Controllers/Insight/Income/PeriodController.php
+++ b/app/Api/V1/Controllers/Insight/Income/PeriodController.php
@@ -47,14 +47,14 @@ final class PeriodController extends Controller
$primary = Amount::getPrimaryCurrency();
// collect all expenses in this period (regardless of type)
- $collector = app(GroupCollectorInterface::class);
+ $collector = app(GroupCollectorInterface::class);
$collector->setTypes([TransactionTypeEnum::DEPOSIT->value])->setRange($start, $end)->setDestinationAccounts($accounts);
- $genericSet = $collector->getExtractedJournals();
+ $genericSet = $collector->getExtractedJournals();
foreach ($genericSet as $journal) {
// currency
- $currencyId = $journal['currency_id'];
- $currencyCode = $journal['currency_code'];
- $field = $convertToPrimary && $currencyId !== $primary->id ? 'pc_amount' : 'amount';
+ $currencyId = $journal['currency_id'];
+ $currencyCode = $journal['currency_code'];
+ $field = $convertToPrimary && $currencyId !== $primary->id ? 'pc_amount' : 'amount';
// perhaps use default currency instead?
if ($convertToPrimary && $journal['currency_id'] !== $primary->id) {
@@ -66,14 +66,14 @@ final class PeriodController extends Controller
$field = 'foreign_amount';
}
- $response[$currencyId] ??= [
+ $response[$currencyId] ??= [
'difference' => '0',
'difference_float' => 0,
- 'currency_id' => (string) $currencyId,
+ 'currency_id' => (string)$currencyId,
'currency_code' => $currencyCode,
];
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], Steam::positive($journal[$field]));
- $response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference']; // float but on purpose.
+ $response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference']; // float but on purpose.
}
return response()->json(array_values($response));
diff --git a/app/Api/V1/Controllers/Insight/Income/TagController.php b/app/Api/V1/Controllers/Insight/Income/TagController.php
index df99eef909..ca1576cd14 100644
--- a/app/Api/V1/Controllers/Insight/Income/TagController.php
+++ b/app/Api/V1/Controllers/Insight/Income/TagController.php
@@ -68,17 +68,17 @@ final class TagController extends Controller
$primary = Amount::getPrimaryCurrency();
// collect all expenses in this period (regardless of type) by the given bills and accounts.
- $collector = app(GroupCollectorInterface::class);
+ $collector = app(GroupCollectorInterface::class);
$collector->setTypes([TransactionTypeEnum::DEPOSIT->value])->setRange($start, $end)->setDestinationAccounts($accounts);
$collector->withoutTags();
- $genericSet = $collector->getExtractedJournals();
+ $genericSet = $collector->getExtractedJournals();
foreach ($genericSet as $journal) {
// currency
- $currencyId = $journal['currency_id'];
- $currencyCode = $journal['currency_code'];
- $field = $convertToPrimary && $currencyId !== $primary->id ? 'pc_amount' : 'amount';
+ $currencyId = $journal['currency_id'];
+ $currencyCode = $journal['currency_code'];
+ $field = $convertToPrimary && $currencyId !== $primary->id ? 'pc_amount' : 'amount';
// perhaps use default currency instead?
if ($convertToPrimary && $journal['currency_id'] !== $primary->id) {
@@ -90,14 +90,14 @@ final class TagController extends Controller
$field = 'foreign_amount';
}
- $response[$currencyId] ??= [
+ $response[$currencyId] ??= [
'difference' => '0',
'difference_float' => 0,
- 'currency_id' => (string) $currencyId,
+ 'currency_id' => (string)$currencyId,
'currency_code' => $currencyCode,
];
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], Steam::positive($journal[$field]));
- $response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference'];
+ $response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference'];
}
return response()->json(array_values($response));
@@ -108,11 +108,11 @@ final class TagController extends Controller
*/
public function tag(GenericRequest $request): JsonResponse
{
- $accounts = $request->getAssetAccounts();
- $tags = $request->getTags();
- $start = $request->getStart();
- $end = $request->getEnd();
- $response = [];
+ $accounts = $request->getAssetAccounts();
+ $tags = $request->getTags();
+ $start = $request->getStart();
+ $end = $request->getEnd();
+ $response = [];
// get all tags:
if (0 === $tags->count()) {
@@ -120,15 +120,15 @@ final class TagController extends Controller
}
// collect all expenses in this period (regardless of type) by the given bills and accounts.
- $collector = app(GroupCollectorInterface::class);
+ $collector = app(GroupCollectorInterface::class);
$collector->setTypes([TransactionTypeEnum::DEPOSIT->value])->setRange($start, $end)->setDestinationAccounts($accounts);
$collector->setTags($tags);
$genericSet = $collector->getExtractedJournals();
/** @var array $journal */
foreach ($genericSet as $journal) {
- $currencyId = (int) $journal['currency_id'];
- $foreignCurrencyId = (int) $journal['foreign_currency_id'];
+ $currencyId = (int)$journal['currency_id'];
+ $foreignCurrencyId = (int)$journal['foreign_currency_id'];
/** @var array $tag */
foreach ($journal['tags'] as $tag) {
@@ -138,16 +138,16 @@ final class TagController extends Controller
// on currency ID
if (0 !== $currencyId) {
- $response[$key] ??= [
- 'id' => (string) $tagId,
+ $response[$key] ??= [
+ 'id' => (string)$tagId,
'name' => $tag['name'],
'difference' => '0',
'difference_float' => 0,
- 'currency_id' => (string) $currencyId,
+ 'currency_id' => (string)$currencyId,
'currency_code' => $journal['currency_code'],
];
- $response[$key]['difference'] = bcadd((string) $response[$key]['difference'], Steam::positive($journal['amount']));
- $response[$key]['difference_float'] = (float) $response[$key]['difference'];
+ $response[$key]['difference'] = bcadd((string)$response[$key]['difference'], Steam::positive($journal['amount']));
+ $response[$key]['difference_float'] = (float)$response[$key]['difference'];
}
// on foreign ID
@@ -155,11 +155,11 @@ final class TagController extends Controller
$response[$foreignKey] = $journal[$foreignKey] ?? [
'difference' => '0',
'difference_float' => 0,
- 'currency_id' => (string) $foreignCurrencyId,
+ 'currency_id' => (string)$foreignCurrencyId,
'currency_code' => $journal['foreign_currency_code'],
];
- $response[$foreignKey]['difference'] = bcadd((string) $response[$foreignKey]['difference'], Steam::positive($journal['foreign_amount']));
- $response[$foreignKey]['difference_float'] = (float) $response[$foreignKey]['difference'];
+ $response[$foreignKey]['difference'] = bcadd((string)$response[$foreignKey]['difference'], Steam::positive($journal['foreign_amount']));
+ $response[$foreignKey]['difference_float'] = (float)$response[$foreignKey]['difference'];
}
}
}
diff --git a/app/Api/V1/Controllers/Insight/Transfer/CategoryController.php b/app/Api/V1/Controllers/Insight/Transfer/CategoryController.php
index 2fc72229d3..1f87e9ba0c 100644
--- a/app/Api/V1/Controllers/Insight/Transfer/CategoryController.php
+++ b/app/Api/V1/Controllers/Insight/Transfer/CategoryController.php
@@ -40,7 +40,7 @@ final class CategoryController extends Controller
{
private NoCategoryRepositoryInterface $noRepository;
private OperationsRepositoryInterface $opsRepository;
- private CategoryRepositoryInterface $repository;
+ private CategoryRepositoryInterface $repository;
/**
* AccountController constructor.
@@ -79,11 +79,11 @@ final class CategoryController extends Controller
/** @var array $expense */
foreach ($expenses as $expense) {
$result[] = [
- 'id' => (string) $category->id,
+ 'id' => (string)$category->id,
'name' => $category->name,
'difference' => $expense['sum'],
- 'difference_float' => (float) $expense['sum'],
- 'currency_id' => (string) $expense['currency_id'],
+ 'difference_float' => (float)$expense['sum'],
+ 'currency_id' => (string)$expense['currency_id'],
'currency_code' => $expense['currency_code'],
];
}
@@ -104,8 +104,8 @@ final class CategoryController extends Controller
foreach ($expenses as $expense) {
$result[] = [
'difference' => $expense['sum'],
- 'difference_float' => (float) $expense['sum'],
- 'currency_id' => (string) $expense['currency_id'],
+ 'difference_float' => (float)$expense['sum'],
+ 'currency_id' => (string)$expense['currency_id'],
'currency_code' => $expense['currency_code'],
];
}
diff --git a/app/Api/V1/Controllers/Insight/Transfer/PeriodController.php b/app/Api/V1/Controllers/Insight/Transfer/PeriodController.php
index cdae02e939..5b034fbe85 100644
--- a/app/Api/V1/Controllers/Insight/Transfer/PeriodController.php
+++ b/app/Api/V1/Controllers/Insight/Transfer/PeriodController.php
@@ -47,14 +47,14 @@ final class PeriodController extends Controller
$primary = Amount::getPrimaryCurrency();
// collect all expenses in this period (regardless of type)
- $collector = app(GroupCollectorInterface::class);
+ $collector = app(GroupCollectorInterface::class);
$collector->setTypes([TransactionTypeEnum::TRANSFER->value])->setRange($start, $end)->setDestinationAccounts($accounts);
- $genericSet = $collector->getExtractedJournals();
+ $genericSet = $collector->getExtractedJournals();
foreach ($genericSet as $journal) {
// currency
- $currencyId = $journal['currency_id'];
- $currencyCode = $journal['currency_code'];
- $field = $convertToPrimary && $currencyId !== $primary->id ? 'pc_amount' : 'amount';
+ $currencyId = $journal['currency_id'];
+ $currencyCode = $journal['currency_code'];
+ $field = $convertToPrimary && $currencyId !== $primary->id ? 'pc_amount' : 'amount';
// perhaps use default currency instead?
if ($convertToPrimary && $journal['currency_id'] !== $primary->id) {
@@ -66,14 +66,14 @@ final class PeriodController extends Controller
$field = 'foreign_amount';
}
- $response[$currencyId] ??= [
+ $response[$currencyId] ??= [
'difference' => '0',
'difference_float' => 0,
- 'currency_id' => (string) $currencyId,
+ 'currency_id' => (string)$currencyId,
'currency_code' => $currencyCode,
];
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], Steam::positive($journal[$field]));
- $response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference'];
+ $response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference'];
}
return response()->json(array_values($response));
diff --git a/app/Api/V1/Controllers/Insight/Transfer/TagController.php b/app/Api/V1/Controllers/Insight/Transfer/TagController.php
index f92a7aa9f0..53d45457ba 100644
--- a/app/Api/V1/Controllers/Insight/Transfer/TagController.php
+++ b/app/Api/V1/Controllers/Insight/Transfer/TagController.php
@@ -65,17 +65,17 @@ final class TagController extends Controller
$primary = Amount::getPrimaryCurrency();
// collect all expenses in this period (regardless of type) by the given bills and accounts.
- $collector = app(GroupCollectorInterface::class);
+ $collector = app(GroupCollectorInterface::class);
$collector->setTypes([TransactionTypeEnum::TRANSFER->value])->setRange($start, $end)->setDestinationAccounts($accounts);
$collector->withoutTags();
- $genericSet = $collector->getExtractedJournals();
+ $genericSet = $collector->getExtractedJournals();
foreach ($genericSet as $journal) {
// currency
- $currencyId = $journal['currency_id'];
- $currencyCode = $journal['currency_code'];
- $field = $convertToPrimary && $currencyId !== $primary->id ? 'pc_amount' : 'amount';
+ $currencyId = $journal['currency_id'];
+ $currencyCode = $journal['currency_code'];
+ $field = $convertToPrimary && $currencyId !== $primary->id ? 'pc_amount' : 'amount';
// perhaps use default currency instead?
if ($convertToPrimary && $journal['currency_id'] !== $primary->id) {
@@ -87,14 +87,14 @@ final class TagController extends Controller
$field = 'foreign_amount';
}
- $response[$currencyId] ??= [
+ $response[$currencyId] ??= [
'difference' => '0',
'difference_float' => 0,
- 'currency_id' => (string) $currencyId,
+ 'currency_id' => (string)$currencyId,
'currency_code' => $currencyCode,
];
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], Steam::positive($journal[$field]));
- $response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference'];
+ $response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference'];
}
return response()->json(array_values($response));
@@ -105,11 +105,11 @@ final class TagController extends Controller
*/
public function tag(GenericRequest $request): JsonResponse
{
- $accounts = $request->getAssetAccounts();
- $tags = $request->getTags();
- $start = $request->getStart();
- $end = $request->getEnd();
- $response = [];
+ $accounts = $request->getAssetAccounts();
+ $tags = $request->getTags();
+ $start = $request->getStart();
+ $end = $request->getEnd();
+ $response = [];
// get all tags:
if (0 === $tags->count()) {
@@ -117,15 +117,15 @@ final class TagController extends Controller
}
// collect all expenses in this period (regardless of type) by the given bills and accounts.
- $collector = app(GroupCollectorInterface::class);
+ $collector = app(GroupCollectorInterface::class);
$collector->setTypes([TransactionTypeEnum::TRANSFER->value])->setRange($start, $end)->setDestinationAccounts($accounts);
$collector->setTags($tags);
$genericSet = $collector->getExtractedJournals();
/** @var array $journal */
foreach ($genericSet as $journal) {
- $currencyId = (int) $journal['currency_id'];
- $foreignCurrencyId = (int) $journal['foreign_currency_id'];
+ $currencyId = (int)$journal['currency_id'];
+ $foreignCurrencyId = (int)$journal['foreign_currency_id'];
/** @var array $tag */
foreach ($journal['tags'] as $tag) {
@@ -135,16 +135,16 @@ final class TagController extends Controller
// on currency ID
if (0 !== $currencyId) {
- $response[$key] ??= [
- 'id' => (string) $tagId,
+ $response[$key] ??= [
+ 'id' => (string)$tagId,
'name' => $tag['name'],
'difference' => '0',
'difference_float' => 0,
- 'currency_id' => (string) $currencyId,
+ 'currency_id' => (string)$currencyId,
'currency_code' => $journal['currency_code'],
];
- $response[$key]['difference'] = bcadd((string) $response[$key]['difference'], Steam::positive($journal['amount']));
- $response[$key]['difference_float'] = (float) $response[$key]['difference'];
+ $response[$key]['difference'] = bcadd((string)$response[$key]['difference'], Steam::positive($journal['amount']));
+ $response[$key]['difference_float'] = (float)$response[$key]['difference'];
}
// on foreign ID
@@ -152,11 +152,11 @@ final class TagController extends Controller
$response[$foreignKey] = $journal[$foreignKey] ?? [
'difference' => '0',
'difference_float' => 0,
- 'currency_id' => (string) $foreignCurrencyId,
+ 'currency_id' => (string)$foreignCurrencyId,
'currency_code' => $journal['foreign_currency_code'],
];
- $response[$foreignKey]['difference'] = bcadd((string) $response[$foreignKey]['difference'], Steam::positive($journal['foreign_amount']));
- $response[$foreignKey]['difference_float'] = (float) $response[$foreignKey]['difference']; // intentional float
+ $response[$foreignKey]['difference'] = bcadd((string)$response[$foreignKey]['difference'], Steam::positive($journal['foreign_amount']));
+ $response[$foreignKey]['difference_float'] = (float)$response[$foreignKey]['difference']; // intentional float
}
}
}
diff --git a/app/Api/V1/Controllers/Models/Account/ListController.php b/app/Api/V1/Controllers/Models/Account/ListController.php
index a6ec7bf804..42fa092486 100644
--- a/app/Api/V1/Controllers/Models/Account/ListController.php
+++ b/app/Api/V1/Controllers/Models/Account/ListController.php
@@ -70,21 +70,21 @@ final class ListController extends Controller
public function attachments(PaginationRequest $request, Account $account): JsonResponse
{
- $manager = $this->getManager();
+ $manager = $this->getManager();
['limit' => $limit, 'offset' => $offset, 'page' => $page] = $request->attributes->all();
- $collection = $this->repository->getAttachments($account);
+ $collection = $this->repository->getAttachments($account);
- $count = $collection->count();
- $attachments = $collection->slice($offset, $limit);
+ $count = $collection->count();
+ $attachments = $collection->slice($offset, $limit);
// make paginator:
- $paginator = new LengthAwarePaginator($attachments, $count, $limit, $page);
- $paginator->setPath(route('api.v1.accounts.attachments', [$account->id]).$this->buildParams());
+ $paginator = new LengthAwarePaginator($attachments, $count, $limit, $page);
+ $paginator->setPath(route('api.v1.accounts.attachments', [$account->id]) . $this->buildParams());
/** @var AttachmentTransformer $transformer */
- $transformer = app(AttachmentTransformer::class);
+ $transformer = app(AttachmentTransformer::class);
- $resource = new FractalCollection($attachments, $transformer, 'attachments');
+ $resource = new FractalCollection($attachments, $transformer, 'attachments');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -93,31 +93,31 @@ final class ListController extends Controller
public function piggyBanks(PaginationRequest $request, Account $account): JsonResponse
{
// create some objects:
- $manager = $this->getManager();
+ $manager = $this->getManager();
['limit' => $limit, 'offset' => $offset, 'page' => $page] = $request->attributes->all();
// get list of piggy banks. Count it and split it.
- $collection = $this->repository->getPiggyBanks($account);
- $count = $collection->count();
- $piggyBanks = $collection->slice($offset, $limit);
+ $collection = $this->repository->getPiggyBanks($account);
+ $count = $collection->count();
+ $piggyBanks = $collection->slice($offset, $limit);
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new PiggyBankEnrichment();
+ $admin = auth()->user();
+ $enrichment = new PiggyBankEnrichment();
$enrichment->setUser($admin);
- $piggyBanks = $enrichment->enrich($piggyBanks);
+ $piggyBanks = $enrichment->enrich($piggyBanks);
// make paginator:
- $paginator = new LengthAwarePaginator($piggyBanks, $count, $limit, $page);
- $paginator->setPath(route('api.v1.accounts.piggy-banks', [$account->id]).$this->buildParams());
+ $paginator = new LengthAwarePaginator($piggyBanks, $count, $limit, $page);
+ $paginator->setPath(route('api.v1.accounts.piggy-banks', [$account->id]) . $this->buildParams());
/** @var PiggyBankTransformer $transformer */
- $transformer = app(PiggyBankTransformer::class);
+ $transformer = app(PiggyBankTransformer::class);
// $transformer->setParameters($this->parameters);
- $resource = new FractalCollection($piggyBanks, $transformer, 'piggy-banks');
+ $resource = new FractalCollection($piggyBanks, $transformer, 'piggy-banks');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -129,15 +129,15 @@ final class ListController extends Controller
public function transactions(PaginationDateRangeRequest $request, Account $account): JsonResponse
{
['limit' => $limit, 'page' => $page, 'start' => $start, 'end' => $end, 'type' => $type] = $request->attributes->all();
- $types = $this->mapTransactionTypes($type ?? 'default');
- $manager = $this->getManager();
+ $types = $this->mapTransactionTypes($type ?? 'default');
+ $manager = $this->getManager();
/** @var User $admin */
- $admin = auth()->user();
+ $admin = auth()->user();
// use new group collector:
/** @var GroupCollectorInterface $collector */
- $collector = app(GroupCollectorInterface::class);
+ $collector = app(GroupCollectorInterface::class);
$collector->setUser($admin)->setAccounts(new Collection()->push($account))->withAPIInformation()->setLimit($limit)->setPage($page)->setTypes($types);
if (null !== $start) {
$collector->setStart($start);
@@ -146,18 +146,18 @@ final class ListController extends Controller
$collector->setEnd($end);
}
- $paginator = $collector->getPaginatedGroups();
- $paginator->setPath(route('api.v1.accounts.transactions', [$account->id]).$this->buildParams());
+ $paginator = $collector->getPaginatedGroups();
+ $paginator->setPath(route('api.v1.accounts.transactions', [$account->id]) . $this->buildParams());
// enrich
- $enrichment = new TransactionGroupEnrichment();
+ $enrichment = new TransactionGroupEnrichment();
$enrichment->setUser($admin);
- $transactions = $enrichment->enrich($paginator->getCollection());
+ $transactions = $enrichment->enrich($paginator->getCollection());
/** @var TransactionGroupTransformer $transformer */
- $transformer = app(TransactionGroupTransformer::class);
+ $transformer = app(TransactionGroupTransformer::class);
- $resource = new FractalCollection($transactions, $transformer, 'transactions');
+ $resource = new FractalCollection($transactions, $transformer, 'transactions');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
diff --git a/app/Api/V1/Controllers/Models/Account/ShowController.php b/app/Api/V1/Controllers/Models/Account/ShowController.php
index ef115a720f..c7ff8a4b5f 100644
--- a/app/Api/V1/Controllers/Models/Account/ShowController.php
+++ b/app/Api/V1/Controllers/Models/Account/ShowController.php
@@ -68,7 +68,7 @@ final class ShowController extends Controller
*/
public function index(ShowRequest $request): JsonResponse
{
- $manager = $this->getManager();
+ $manager = $this->getManager();
[
'types' => $types,
'page' => $page,
@@ -78,36 +78,37 @@ final class ShowController extends Controller
'start' => $start,
'end' => $end,
'date' => $date,
- ] = $request->attributes->all();
+ ]
+ = $request->attributes->all();
// get list of accounts. Count it and split it.
$this->repository->resetAccountOrder();
- $collection = $this->repository->getAccountsByType($types, $sort);
- $count = $collection->count();
+ $collection = $this->repository->getAccountsByType($types, $sort);
+ $count = $collection->count();
// continue sort:
// TODO if the user sorts on DB dependent field there must be no slice before enrichment, only after.
// TODO still need to figure out how to do this easily.
- $accounts = $collection->slice($offset, $limit);
+ $accounts = $collection->slice($offset, $limit);
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new AccountEnrichment();
+ $admin = auth()->user();
+ $enrichment = new AccountEnrichment();
$enrichment->setSort($sort);
$enrichment->setDate($date);
$enrichment->setStart($start);
$enrichment->setEnd($end);
$enrichment->setUser($admin);
- $accounts = $enrichment->enrich($accounts);
+ $accounts = $enrichment->enrich($accounts);
// make paginator:
- $paginator = new LengthAwarePaginator($accounts, $count, $limit, $page);
- $paginator->setPath(route('api.v1.accounts.index').$this->buildParams());
+ $paginator = new LengthAwarePaginator($accounts, $count, $limit, $page);
+ $paginator->setPath(route('api.v1.accounts.index') . $this->buildParams());
/** @var AccountTransformer $transformer */
$transformer = app(AccountTransformer::class);
- $resource = new FractalCollection($accounts, $transformer, self::RESOURCE_KEY);
+ $resource = new FractalCollection($accounts, $transformer, self::RESOURCE_KEY);
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -124,22 +125,22 @@ final class ShowController extends Controller
// get list of accounts. Count it and split it.
$this->repository->resetAccountOrder();
$account->refresh();
- $manager = $this->getManager();
+ $manager = $this->getManager();
['start' => $start, 'end' => $end, 'date' => $date] = $request->attributes->all();
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new AccountEnrichment();
+ $admin = auth()->user();
+ $enrichment = new AccountEnrichment();
$enrichment->setDate($date);
$enrichment->setStart($start);
$enrichment->setEnd($end);
$enrichment->setUser($admin);
- $account = $enrichment->enrichSingle($account);
+ $account = $enrichment->enrichSingle($account);
/** @var AccountTransformer $transformer */
- $transformer = app(AccountTransformer::class);
- $resource = new Item($account, $transformer, self::RESOURCE_KEY);
+ $transformer = app(AccountTransformer::class);
+ $resource = new Item($account, $transformer, self::RESOURCE_KEY);
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/Account/StoreController.php b/app/Api/V1/Controllers/Models/Account/StoreController.php
index 2e97ee1f24..e5a245b85a 100644
--- a/app/Api/V1/Controllers/Models/Account/StoreController.php
+++ b/app/Api/V1/Controllers/Models/Account/StoreController.php
@@ -64,23 +64,23 @@ final class StoreController extends Controller
*/
public function store(StoreRequest $request): JsonResponse
{
- $data = $request->getAllAccountData();
+ $data = $request->getAllAccountData();
$this->repository->resetAccountOrder();
- $account = $this->repository->store($data);
- $manager = $this->getManager();
+ $account = $this->repository->store($data);
+ $manager = $this->getManager();
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new AccountEnrichment();
+ $admin = auth()->user();
+ $enrichment = new AccountEnrichment();
$enrichment->setDate(null);
$enrichment->setUser($admin);
- $account = $enrichment->enrichSingle($account);
+ $account = $enrichment->enrichSingle($account);
/** @var AccountTransformer $transformer */
$transformer = app(AccountTransformer::class);
- $resource = new Item($account, $transformer, self::RESOURCE_KEY);
+ $resource = new Item($account, $transformer, self::RESOURCE_KEY);
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/Account/UpdateController.php b/app/Api/V1/Controllers/Models/Account/UpdateController.php
index 0c683b7fe9..95cdcb6535 100644
--- a/app/Api/V1/Controllers/Models/Account/UpdateController.php
+++ b/app/Api/V1/Controllers/Models/Account/UpdateController.php
@@ -69,7 +69,7 @@ final class UpdateController extends Controller
{
Log::debug(sprintf('Now in %s', __METHOD__));
$data = $request->getUpdateData();
- $data['type'] = config('firefly.shortNamesByFullName.'.$account->accountType->type);
+ $data['type'] = config('firefly.shortNamesByFullName.' . $account->accountType->type);
$account = $this->repository->update($account, $data);
$manager = $this->getManager();
$account->refresh();
@@ -77,15 +77,15 @@ final class UpdateController extends Controller
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new AccountEnrichment();
+ $admin = auth()->user();
+ $enrichment = new AccountEnrichment();
$enrichment->setDate(null);
$enrichment->setUser($admin);
- $account = $enrichment->enrichSingle($account);
+ $account = $enrichment->enrichSingle($account);
/** @var AccountTransformer $transformer */
- $transformer = app(AccountTransformer::class);
- $resource = new Item($account, $transformer, self::RESOURCE_KEY);
+ $transformer = app(AccountTransformer::class);
+ $resource = new Item($account, $transformer, self::RESOURCE_KEY);
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/Attachment/ShowController.php b/app/Api/V1/Controllers/Models/Attachment/ShowController.php
index 10e971d6eb..3bc95b289a 100644
--- a/app/Api/V1/Controllers/Models/Attachment/ShowController.php
+++ b/app/Api/V1/Controllers/Models/Attachment/ShowController.php
@@ -87,25 +87,24 @@ final class ShowController extends Controller
throw new FireflyException('200000: File has not been uploaded (yet).');
}
if ($this->repository->exists($attachment)) {
- $content = $this->repository->getContent($attachment);
+ $content = $this->repository->getContent($attachment);
if ('' === $content) {
throw new FireflyException('200002: File is empty (zero bytes).');
}
- $quoted = sprintf('"%s"', addcslashes(basename($attachment->filename), '"\\'));
+ $quoted = sprintf('"%s"', addcslashes(basename($attachment->filename), '"\\'));
/** @var LaravelResponse $response */
$response = response($content);
$response
->header('Content-Description', 'File Transfer')
->header('Content-Type', 'application/octet-stream')
- ->header('Content-Disposition', 'attachment; filename='.$quoted)
+ ->header('Content-Disposition', 'attachment; filename=' . $quoted)
->header('Content-Transfer-Encoding', 'binary')
->header('Connection', 'Keep-Alive')
->header('Expires', '0')
->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0')
->header('Pragma', 'public')
- ->header('Content-Length', (string) strlen($content))
- ;
+ ->header('Content-Length', (string)strlen($content));
return $response;
}
@@ -129,21 +128,21 @@ final class ShowController extends Controller
throw new NotFoundHttpException();
}
- $manager = $this->getManager();
+ $manager = $this->getManager();
// get list of attachments. Count it and split it.
- $collection = $this->repository->get();
- $count = $collection->count();
- $attachments = $collection->slice($offset, $limit);
+ $collection = $this->repository->get();
+ $count = $collection->count();
+ $attachments = $collection->slice($offset, $limit);
// make paginator:
- $paginator = new LengthAwarePaginator($attachments, $count, $limit, $page);
- $paginator->setPath(route('api.v1.attachments.index').$this->buildParams());
+ $paginator = new LengthAwarePaginator($attachments, $count, $limit, $page);
+ $paginator->setPath(route('api.v1.attachments.index') . $this->buildParams());
/** @var AttachmentTransformer $transformer */
- $transformer = app(AttachmentTransformer::class);
+ $transformer = app(AttachmentTransformer::class);
- $resource = new FractalCollection($attachments, $transformer, 'attachments');
+ $resource = new FractalCollection($attachments, $transformer, 'attachments');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -162,12 +161,12 @@ final class ShowController extends Controller
throw new NotFoundHttpException();
}
- $manager = $this->getManager();
+ $manager = $this->getManager();
/** @var AttachmentTransformer $transformer */
$transformer = app(AttachmentTransformer::class);
- $resource = new Item($attachment, $transformer, 'attachments');
+ $resource = new Item($attachment, $transformer, 'attachments');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/Attachment/StoreController.php b/app/Api/V1/Controllers/Models/Attachment/StoreController.php
index cf2af07158..1a8e0b0911 100644
--- a/app/Api/V1/Controllers/Models/Attachment/StoreController.php
+++ b/app/Api/V1/Controllers/Models/Attachment/StoreController.php
@@ -79,14 +79,14 @@ final class StoreController extends Controller
throw new NotFoundHttpException();
}
Log::debug(sprintf('Now in %s', __METHOD__));
- $data = $request->getAll();
- $attachment = $this->repository->store($data);
- $manager = $this->getManager();
+ $data = $request->getAll();
+ $attachment = $this->repository->store($data);
+ $manager = $this->getManager();
/** @var AttachmentTransformer $transformer */
$transformer = app(AttachmentTransformer::class);
- $resource = new Item($attachment, $transformer, 'attachments');
+ $resource = new Item($attachment, $transformer, 'attachments');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/Attachment/UpdateController.php b/app/Api/V1/Controllers/Models/Attachment/UpdateController.php
index bff86bd0ec..1c903c50cb 100644
--- a/app/Api/V1/Controllers/Models/Attachment/UpdateController.php
+++ b/app/Api/V1/Controllers/Models/Attachment/UpdateController.php
@@ -73,14 +73,14 @@ final class UpdateController extends Controller
throw new NotFoundHttpException();
}
- $data = $request->getAll();
+ $data = $request->getAll();
$this->repository->update($attachment, $data);
- $manager = $this->getManager();
+ $manager = $this->getManager();
/** @var AttachmentTransformer $transformer */
$transformer = app(AttachmentTransformer::class);
- $resource = new Item($attachment, $transformer, 'attachments');
+ $resource = new Item($attachment, $transformer, 'attachments');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/AvailableBudget/ShowController.php b/app/Api/V1/Controllers/Models/AvailableBudget/ShowController.php
index d97405258b..2c8dc42d96 100644
--- a/app/Api/V1/Controllers/Models/AvailableBudget/ShowController.php
+++ b/app/Api/V1/Controllers/Models/AvailableBudget/ShowController.php
@@ -68,29 +68,29 @@ final class ShowController extends Controller
*/
public function index(PaginationDateRangeRequest $request): JsonResponse
{
- $manager = $this->getManager();
+ $manager = $this->getManager();
['limit' => $limit, 'offset' => $offset, 'page' => $page, 'start' => $start, 'end' => $end] = $request->attributes->all();
// get list of available budgets. Count it and split it.
- $collection = $this->abRepository->getAvailableBudgetsByDate($start, $end);
- $count = $collection->count();
- $availableBudgets = $collection->slice($offset, $limit);
+ $collection = $this->abRepository->getAvailableBudgetsByDate($start, $end);
+ $count = $collection->count();
+ $availableBudgets = $collection->slice($offset, $limit);
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new AvailableBudgetEnrichment();
+ $admin = auth()->user();
+ $enrichment = new AvailableBudgetEnrichment();
$enrichment->setUser($admin);
- $availableBudgets = $enrichment->enrich($availableBudgets);
+ $availableBudgets = $enrichment->enrich($availableBudgets);
// make paginator:
- $paginator = new LengthAwarePaginator($availableBudgets, $count, $limit, $page);
- $paginator->setPath(route('api.v1.available-budgets.index').$this->buildParams());
+ $paginator = new LengthAwarePaginator($availableBudgets, $count, $limit, $page);
+ $paginator->setPath(route('api.v1.available-budgets.index') . $this->buildParams());
/** @var AvailableBudgetTransformer $transformer */
- $transformer = app(AvailableBudgetTransformer::class);
+ $transformer = app(AvailableBudgetTransformer::class);
- $resource = new FractalCollection($availableBudgets, $transformer, 'available_budgets');
+ $resource = new FractalCollection($availableBudgets, $transformer, 'available_budgets');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -104,21 +104,21 @@ final class ShowController extends Controller
*/
public function show(AvailableBudget $availableBudget): JsonResponse
{
- $manager = $this->getManager();
+ $manager = $this->getManager();
// $start = $this->parameters->get('start');
// $end = $this->parameters->get('end');
/** @var AvailableBudgetTransformer $transformer */
- $transformer = app(AvailableBudgetTransformer::class);
+ $transformer = app(AvailableBudgetTransformer::class);
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new AvailableBudgetEnrichment();
+ $admin = auth()->user();
+ $enrichment = new AvailableBudgetEnrichment();
$enrichment->setUser($admin);
$availableBudget = $enrichment->enrichSingle($availableBudget);
- $resource = new Item($availableBudget, $transformer, 'available_budgets');
+ $resource = new Item($availableBudget, $transformer, 'available_budgets');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/Bill/ListController.php b/app/Api/V1/Controllers/Models/Bill/ListController.php
index 5256be1cd7..74bc7bdf8e 100644
--- a/app/Api/V1/Controllers/Models/Bill/ListController.php
+++ b/app/Api/V1/Controllers/Models/Bill/ListController.php
@@ -73,20 +73,20 @@ final class ListController extends Controller
public function attachments(PaginationRequest $request, Bill $bill): JsonResponse
{
['limit' => $limit, 'offset' => $offset, 'page' => $page] = $request->attributes->all();
- $manager = $this->getManager();
- $collection = $this->repository->getAttachments($bill);
+ $manager = $this->getManager();
+ $collection = $this->repository->getAttachments($bill);
- $count = $collection->count();
- $attachments = $collection->slice($offset, $limit);
+ $count = $collection->count();
+ $attachments = $collection->slice($offset, $limit);
// make paginator:
- $paginator = new LengthAwarePaginator($attachments, $count, $limit, $page);
- $paginator->setPath(route('api.v1.bills.attachments', [$bill->id]).$this->buildParams());
+ $paginator = new LengthAwarePaginator($attachments, $count, $limit, $page);
+ $paginator->setPath(route('api.v1.bills.attachments', [$bill->id]) . $this->buildParams());
/** @var AttachmentTransformer $transformer */
- $transformer = app(AttachmentTransformer::class);
+ $transformer = app(AttachmentTransformer::class);
- $resource = new FractalCollection($attachments, $transformer, 'attachments');
+ $resource = new FractalCollection($attachments, $transformer, 'attachments');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -102,18 +102,18 @@ final class ListController extends Controller
{
['limit' => $limit, 'offset' => $offset, 'page' => $page] = $request->attributes->all();
- $manager = $this->getManager();
- $collection = $this->repository->getRulesForBill($bill);
- $count = $collection->count();
- $rules = $collection->slice($offset, $limit);
+ $manager = $this->getManager();
+ $collection = $this->repository->getRulesForBill($bill);
+ $count = $collection->count();
+ $rules = $collection->slice($offset, $limit);
// make paginator:
- $paginator = new LengthAwarePaginator($rules, $count, $limit, $page);
- $paginator->setPath(route('api.v1.bills.rules', [$bill->id]).$this->buildParams());
+ $paginator = new LengthAwarePaginator($rules, $count, $limit, $page);
+ $paginator->setPath(route('api.v1.bills.rules', [$bill->id]) . $this->buildParams());
/** @var RuleTransformer $transformer */
- $transformer = app(RuleTransformer::class);
- $resource = new FractalCollection($rules, $transformer, 'rules');
+ $transformer = app(RuleTransformer::class);
+ $resource = new FractalCollection($rules, $transformer, 'rules');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -129,14 +129,14 @@ final class ListController extends Controller
{
['limit' => $limit, 'page' => $page, 'types' => $types, 'start' => $start, 'end' => $end] = $request->attributes->all();
- $manager = $this->getManager();
+ $manager = $this->getManager();
/** @var User $admin */
- $admin = auth()->user();
+ $admin = auth()->user();
// use new group collector:
/** @var GroupCollectorInterface $collector */
- $collector = app(GroupCollectorInterface::class);
+ $collector = app(GroupCollectorInterface::class);
$collector
->setUser($admin)
// include source + destination account name and type.
@@ -148,8 +148,7 @@ final class ListController extends Controller
// set page to retrieve
->setPage($page)
// set types of transactions to return.
- ->setTypes($types)
- ;
+ ->setTypes($types);
if (null !== $start) {
$collector->setStart($start);
@@ -159,18 +158,18 @@ final class ListController extends Controller
}
// get paginator.
- $paginator = $collector->getPaginatedGroups();
- $paginator->setPath(route('api.v1.bills.transactions', [$bill->id]).$this->buildParams());
+ $paginator = $collector->getPaginatedGroups();
+ $paginator->setPath(route('api.v1.bills.transactions', [$bill->id]) . $this->buildParams());
// enrich
- $enrichment = new TransactionGroupEnrichment();
+ $enrichment = new TransactionGroupEnrichment();
$enrichment->setUser($admin);
- $transactions = $enrichment->enrich($paginator->getCollection());
+ $transactions = $enrichment->enrich($paginator->getCollection());
/** @var TransactionGroupTransformer $transformer */
- $transformer = app(TransactionGroupTransformer::class);
+ $transformer = app(TransactionGroupTransformer::class);
- $resource = new FractalCollection($transactions, $transformer, 'transactions');
+ $resource = new FractalCollection($transactions, $transformer, 'transactions');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
diff --git a/app/Api/V1/Controllers/Models/Bill/ShowController.php b/app/Api/V1/Controllers/Models/Bill/ShowController.php
index c67d880e1b..c604a576e2 100644
--- a/app/Api/V1/Controllers/Models/Bill/ShowController.php
+++ b/app/Api/V1/Controllers/Models/Bill/ShowController.php
@@ -70,25 +70,25 @@ final class ShowController extends Controller
['limit' => $limit, 'offset' => $offset, 'start' => $start, 'end' => $end, 'page' => $page] = $request->attributes->all();
$this->repository->correctOrder();
- $bills = $this->repository->getBills();
- $manager = $this->getManager();
- $count = $bills->count();
- $bills = $bills->slice($offset, $limit);
- $paginator = new LengthAwarePaginator($bills, $count, $limit, $page);
+ $bills = $this->repository->getBills();
+ $manager = $this->getManager();
+ $count = $bills->count();
+ $bills = $bills->slice($offset, $limit);
+ $paginator = new LengthAwarePaginator($bills, $count, $limit, $page);
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new SubscriptionEnrichment();
+ $admin = auth()->user();
+ $enrichment = new SubscriptionEnrichment();
$enrichment->setUser($admin);
$enrichment->setStart($start);
$enrichment->setEnd($end);
- $bills = $enrichment->enrich($bills);
+ $bills = $enrichment->enrich($bills);
/** @var BillTransformer $transformer */
- $transformer = app(BillTransformer::class);
+ $transformer = app(BillTransformer::class);
- $resource = new FractalCollection($bills, $transformer, 'bills');
+ $resource = new FractalCollection($bills, $transformer, 'bills');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -104,21 +104,21 @@ final class ShowController extends Controller
{
['start' => $start, 'end' => $end] = $request->attributes->all();
- $manager = $this->getManager();
+ $manager = $this->getManager();
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new SubscriptionEnrichment();
+ $admin = auth()->user();
+ $enrichment = new SubscriptionEnrichment();
$enrichment->setUser($admin);
$enrichment->setStart($start);
$enrichment->setEnd($end);
- $bill = $enrichment->enrichSingle($bill);
+ $bill = $enrichment->enrichSingle($bill);
/** @var BillTransformer $transformer */
- $transformer = app(BillTransformer::class);
+ $transformer = app(BillTransformer::class);
- $resource = new Item($bill, $transformer, 'bills');
+ $resource = new Item($bill, $transformer, 'bills');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/Bill/StoreController.php b/app/Api/V1/Controllers/Models/Bill/StoreController.php
index c39a1456cb..34b026f7f0 100644
--- a/app/Api/V1/Controllers/Models/Bill/StoreController.php
+++ b/app/Api/V1/Controllers/Models/Bill/StoreController.php
@@ -68,23 +68,23 @@ final class StoreController extends Controller
*/
public function store(StoreRequest $request): JsonResponse
{
- $data = $request->getAll();
- $bill = $this->repository->store($data);
- $manager = $this->getManager();
+ $data = $request->getAll();
+ $bill = $this->repository->store($data);
+ $manager = $this->getManager();
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new SubscriptionEnrichment();
+ $admin = auth()->user();
+ $enrichment = new SubscriptionEnrichment();
$enrichment->setUser($admin);
$enrichment->setStart($this->parameters->get('start'));
$enrichment->setEnd($this->parameters->get('end'));
- $bill = $enrichment->enrichSingle($bill);
+ $bill = $enrichment->enrichSingle($bill);
/** @var BillTransformer $transformer */
$transformer = app(BillTransformer::class);
- $resource = new Item($bill, $transformer, 'bills');
+ $resource = new Item($bill, $transformer, 'bills');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/Bill/UpdateController.php b/app/Api/V1/Controllers/Models/Bill/UpdateController.php
index fd18909383..4fd7e0e309 100644
--- a/app/Api/V1/Controllers/Models/Bill/UpdateController.php
+++ b/app/Api/V1/Controllers/Models/Bill/UpdateController.php
@@ -63,24 +63,24 @@ final class UpdateController extends Controller
*/
public function update(UpdateRequest $request, Bill $bill): JsonResponse
{
- $data = $request->getAll();
- $bill = $this->repository->update($bill, $data);
- $manager = $this->getManager();
+ $data = $request->getAll();
+ $bill = $this->repository->update($bill, $data);
+ $manager = $this->getManager();
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new SubscriptionEnrichment();
+ $admin = auth()->user();
+ $enrichment = new SubscriptionEnrichment();
$enrichment->setUser($admin);
$enrichment->setStart($this->parameters->get('start'));
$enrichment->setEnd($this->parameters->get('end'));
- $bill = $enrichment->enrichSingle($bill);
+ $bill = $enrichment->enrichSingle($bill);
/** @var BillTransformer $transformer */
$transformer = app(BillTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($bill, $transformer, 'bills');
+ $resource = new Item($bill, $transformer, 'bills');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/Budget/ListController.php b/app/Api/V1/Controllers/Models/Budget/ListController.php
index 8182e94924..da2357c9a8 100644
--- a/app/Api/V1/Controllers/Models/Budget/ListController.php
+++ b/app/Api/V1/Controllers/Models/Budget/ListController.php
@@ -49,7 +49,7 @@ final class ListController extends Controller
use TransactionFilter;
private BudgetLimitRepositoryInterface $blRepository;
- private BudgetRepositoryInterface $repository;
+ private BudgetRepositoryInterface $repository;
/**
* ListController constructor.
@@ -73,22 +73,22 @@ final class ListController extends Controller
*/
public function attachments(Budget $budget): JsonResponse
{
- $manager = $this->getManager();
- $pageSize = $this->parameters->get('limit');
- $collection = $this->repository->getAttachments($budget);
+ $manager = $this->getManager();
+ $pageSize = $this->parameters->get('limit');
+ $collection = $this->repository->getAttachments($budget);
$count = $collection->count();
$attachments = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
// make paginator:
- $paginator = new LengthAwarePaginator($attachments, $count, $pageSize, $this->parameters->get('page'));
- $paginator->setPath(route('api.v1.budgets.attachments', [$budget->id]).$this->buildParams());
+ $paginator = new LengthAwarePaginator($attachments, $count, $pageSize, $this->parameters->get('page'));
+ $paginator->setPath(route('api.v1.budgets.attachments', [$budget->id]) . $this->buildParams());
/** @var AttachmentTransformer $transformer */
$transformer = app(AttachmentTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($attachments, $transformer, 'attachments');
+ $resource = new FractalCollection($attachments, $transformer, 'attachments');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -102,26 +102,26 @@ final class ListController extends Controller
*/
public function budgetLimits(Budget $budget): JsonResponse
{
- $manager = $this->getManager();
- $pageSize = $this->parameters->get('limit');
+ $manager = $this->getManager();
+ $pageSize = $this->parameters->get('limit');
$this->parameters->set('budget_id', $budget->id);
$collection = $this->blRepository->getBudgetLimits($budget, $this->parameters->get('start'), $this->parameters->get('end'));
$count = $collection->count();
$budgetLimits = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
$paginator = new LengthAwarePaginator($budgetLimits, $count, $pageSize, $this->parameters->get('page'));
- $paginator->setPath(route('api.v1.budgets.budget-limits', [$budget->id]).$this->buildParams());
+ $paginator->setPath(route('api.v1.budgets.budget-limits', [$budget->id]) . $this->buildParams());
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new BudgetLimitEnrichment();
+ $admin = auth()->user();
+ $enrichment = new BudgetLimitEnrichment();
$enrichment->setUser($admin);
$budgetLimits = $enrichment->enrich($budgetLimits);
/** @var BudgetLimitTransformer $transformer */
- $transformer = app(BudgetLimitTransformer::class);
+ $transformer = app(BudgetLimitTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($budgetLimits, $transformer, 'budget_limits');
+ $resource = new FractalCollection($budgetLimits, $transformer, 'budget_limits');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -135,20 +135,20 @@ final class ListController extends Controller
*/
public function transactions(Request $request, Budget $budget): JsonResponse
{
- $pageSize = $this->parameters->get('limit');
+ $pageSize = $this->parameters->get('limit');
- $type = $request->input('type') ?? 'default';
+ $type = $request->input('type') ?? 'default';
$this->parameters->set('type', $type);
- $types = $this->mapTransactionTypes($this->parameters->get('type'));
- $manager = $this->getManager();
+ $types = $this->mapTransactionTypes($this->parameters->get('type'));
+ $manager = $this->getManager();
/** @var User $admin */
- $admin = auth()->user();
+ $admin = auth()->user();
// use new group collector:
/** @var GroupCollectorInterface $collector */
- $collector = app(GroupCollectorInterface::class);
+ $collector = app(GroupCollectorInterface::class);
$collector
->setUser($admin)
// filter on budget.
@@ -160,8 +160,7 @@ final class ListController extends Controller
// set page to retrieve
->setPage($this->parameters->get('page'))
// set types of transactions to return.
- ->setTypes($types)
- ;
+ ->setTypes($types);
if (null !== $this->parameters->get('start')) {
$collector->setStart($this->parameters->get('start'));
@@ -170,18 +169,18 @@ final class ListController extends Controller
$collector->setEnd($this->parameters->get('end'));
}
- $paginator = $collector->getPaginatedGroups();
- $paginator->setPath(route('api.v1.budgets.transactions', [$budget->id]).$this->buildParams());
+ $paginator = $collector->getPaginatedGroups();
+ $paginator->setPath(route('api.v1.budgets.transactions', [$budget->id]) . $this->buildParams());
// enrich
- $enrichment = new TransactionGroupEnrichment();
+ $enrichment = new TransactionGroupEnrichment();
$enrichment->setUser($admin);
$transactions = $enrichment->enrich($paginator->getCollection());
/** @var TransactionGroupTransformer $transformer */
- $transformer = app(TransactionGroupTransformer::class);
+ $transformer = app(TransactionGroupTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($transactions, $transformer, 'transactions');
+ $resource = new FractalCollection($transactions, $transformer, 'transactions');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -195,20 +194,20 @@ final class ListController extends Controller
*/
public function withoutBudget(Request $request): JsonResponse
{
- $pageSize = $this->parameters->get('limit');
+ $pageSize = $this->parameters->get('limit');
- $type = $request->input('type') ?? 'default';
+ $type = $request->input('type') ?? 'default';
$this->parameters->set('type', $type);
- $types = $this->mapTransactionTypes($this->parameters->get('type'));
- $manager = $this->getManager();
+ $types = $this->mapTransactionTypes($this->parameters->get('type'));
+ $manager = $this->getManager();
/** @var User $admin */
- $admin = auth()->user();
+ $admin = auth()->user();
// use new group collector:
/** @var GroupCollectorInterface $collector */
- $collector = app(GroupCollectorInterface::class);
+ $collector = app(GroupCollectorInterface::class);
$collector
->setUser($admin)
// withdrawals only
@@ -222,8 +221,7 @@ final class ListController extends Controller
// set page to retrieve
->setPage($this->parameters->get('page'))
// set types of transactions to return.
- ->setTypes($types)
- ;
+ ->setTypes($types);
if (null !== $this->parameters->get('start')) {
$collector->setStart($this->parameters->get('start'));
@@ -232,18 +230,18 @@ final class ListController extends Controller
$collector->setEnd($this->parameters->get('end'));
}
- $paginator = $collector->getPaginatedGroups();
- $paginator->setPath(route('api.v1.budgets.without-budget').$this->buildParams());
+ $paginator = $collector->getPaginatedGroups();
+ $paginator->setPath(route('api.v1.budgets.without-budget') . $this->buildParams());
// enrich
- $enrichment = new TransactionGroupEnrichment();
+ $enrichment = new TransactionGroupEnrichment();
$enrichment->setUser($admin);
$transactions = $enrichment->enrich($paginator->getCollection());
/** @var TransactionGroupTransformer $transformer */
- $transformer = app(TransactionGroupTransformer::class);
+ $transformer = app(TransactionGroupTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($transactions, $transformer, 'transactions');
+ $resource = new FractalCollection($transactions, $transformer, 'transactions');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
diff --git a/app/Api/V1/Controllers/Models/Budget/ShowController.php b/app/Api/V1/Controllers/Models/Budget/ShowController.php
index 17d4bc5c3e..25c4e84c9d 100644
--- a/app/Api/V1/Controllers/Models/Budget/ShowController.php
+++ b/app/Api/V1/Controllers/Models/Budget/ShowController.php
@@ -43,7 +43,7 @@ use League\Fractal\Resource\Item;
final class ShowController extends Controller
{
private BudgetLimitRepositoryInterface $blRepository;
- private BudgetRepositoryInterface $repository;
+ private BudgetRepositoryInterface $repository;
/**
* ListController constructor.
@@ -69,34 +69,34 @@ final class ShowController extends Controller
*/
public function index(): JsonResponse
{
- $manager = $this->getManager();
+ $manager = $this->getManager();
// types to get, page size:
- $pageSize = $this->parameters->get('limit');
+ $pageSize = $this->parameters->get('limit');
// get list of budgets. Count it and split it.
- $collection = $this->repository->getBudgets();
- $count = $collection->count();
- $budgets = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
+ $collection = $this->repository->getBudgets();
+ $count = $collection->count();
+ $budgets = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new BudgetEnrichment();
+ $admin = auth()->user();
+ $enrichment = new BudgetEnrichment();
$enrichment->setUser($admin);
$enrichment->setStart($this->parameters->get('start'));
$enrichment->setEnd($this->parameters->get('end'));
- $budgets = $enrichment->enrich($budgets);
+ $budgets = $enrichment->enrich($budgets);
// make paginator:
- $paginator = new LengthAwarePaginator($budgets, $count, $pageSize, $this->parameters->get('page'));
- $paginator->setPath(route('api.v1.budgets.index').$this->buildParams());
+ $paginator = new LengthAwarePaginator($budgets, $count, $pageSize, $this->parameters->get('page'));
+ $paginator->setPath(route('api.v1.budgets.index') . $this->buildParams());
/** @var BudgetTransformer $transformer */
$transformer = app(BudgetTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($budgets, $transformer, 'budgets');
+ $resource = new FractalCollection($budgets, $transformer, 'budgets');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -107,22 +107,22 @@ final class ShowController extends Controller
*/
public function show(Budget $budget): JsonResponse
{
- $manager = $this->getManager();
+ $manager = $this->getManager();
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new BudgetEnrichment();
+ $admin = auth()->user();
+ $enrichment = new BudgetEnrichment();
$enrichment->setUser($admin);
$enrichment->setStart($this->parameters->get('start'));
$enrichment->setEnd($this->parameters->get('end'));
- $budget = $enrichment->enrichSingle($budget);
+ $budget = $enrichment->enrichSingle($budget);
/** @var BudgetTransformer $transformer */
$transformer = app(BudgetTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($budget, $transformer, 'budgets');
+ $resource = new Item($budget, $transformer, 'budgets');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/Budget/StoreController.php b/app/Api/V1/Controllers/Models/Budget/StoreController.php
index e6a5a8960b..6cf376be39 100644
--- a/app/Api/V1/Controllers/Models/Budget/StoreController.php
+++ b/app/Api/V1/Controllers/Models/Budget/StoreController.php
@@ -65,24 +65,24 @@ final class StoreController extends Controller
*/
public function store(StoreRequest $request): JsonResponse
{
- $data = $request->getAll();
+ $data = $request->getAll();
$data['fire_webhooks'] ??= true;
- $budget = $this->repository->store($data);
+ $budget = $this->repository->store($data);
$budget->refresh();
- $manager = $this->getManager();
+ $manager = $this->getManager();
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new BudgetEnrichment();
+ $admin = auth()->user();
+ $enrichment = new BudgetEnrichment();
$enrichment->setUser($admin);
- $budget = $enrichment->enrichSingle($budget);
+ $budget = $enrichment->enrichSingle($budget);
/** @var BudgetTransformer $transformer */
$transformer = app(BudgetTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($budget, $transformer, 'budgets');
+ $resource = new Item($budget, $transformer, 'budgets');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/Budget/UpdateController.php b/app/Api/V1/Controllers/Models/Budget/UpdateController.php
index 004ba2a9d9..1b67e18aef 100644
--- a/app/Api/V1/Controllers/Models/Budget/UpdateController.php
+++ b/app/Api/V1/Controllers/Models/Budget/UpdateController.php
@@ -57,23 +57,23 @@ final class UpdateController extends Controller
public function update(UpdateRequest $request, Budget $budget): JsonResponse
{
- $data = $request->getAll();
+ $data = $request->getAll();
$data['fire_webhooks'] ??= true;
- $budget = $this->repository->update($budget, $data);
- $manager = $this->getManager();
+ $budget = $this->repository->update($budget, $data);
+ $manager = $this->getManager();
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new BudgetEnrichment();
+ $admin = auth()->user();
+ $enrichment = new BudgetEnrichment();
$enrichment->setUser($admin);
- $budget = $enrichment->enrichSingle($budget);
+ $budget = $enrichment->enrichSingle($budget);
/** @var BudgetTransformer $transformer */
$transformer = app(BudgetTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($budget, $transformer, 'budgets');
+ $resource = new Item($budget, $transformer, 'budgets');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/BudgetLimit/ListController.php b/app/Api/V1/Controllers/Models/BudgetLimit/ListController.php
index b5aa78ba74..ddb3a0294a 100644
--- a/app/Api/V1/Controllers/Models/BudgetLimit/ListController.php
+++ b/app/Api/V1/Controllers/Models/BudgetLimit/ListController.php
@@ -51,19 +51,19 @@ final class ListController extends Controller
*/
public function transactions(Request $request, Budget $budget, BudgetLimit $budgetLimit): JsonResponse
{
- $pageSize = $this->parameters->get('limit');
- $type = $request->input('type') ?? 'default';
+ $pageSize = $this->parameters->get('limit');
+ $type = $request->input('type') ?? 'default';
$this->parameters->set('type', $type);
- $types = $this->mapTransactionTypes($this->parameters->get('type'));
- $manager = $this->getManager();
+ $types = $this->mapTransactionTypes($this->parameters->get('type'));
+ $manager = $this->getManager();
/** @var User $admin */
- $admin = auth()->user();
+ $admin = auth()->user();
// use new group collector:
/** @var GroupCollectorInterface $collector */
- $collector = app(GroupCollectorInterface::class);
+ $collector = app(GroupCollectorInterface::class);
$collector
->setUser($admin)
// filter on budget.
@@ -75,24 +75,23 @@ final class ListController extends Controller
// set page to retrieve
->setPage($this->parameters->get('page'))
// set types of transactions to return.
- ->setTypes($types)
- ;
+ ->setTypes($types);
$collector->setRange($budgetLimit->start_date, $budgetLimit->end_date);
$collector->setTypes($types);
- $paginator = $collector->getPaginatedGroups();
- $paginator->setPath(route('api.v1.budgets.limits.transactions', [$budget->id, $budgetLimit->id]).$this->buildParams());
+ $paginator = $collector->getPaginatedGroups();
+ $paginator->setPath(route('api.v1.budgets.limits.transactions', [$budget->id, $budgetLimit->id]) . $this->buildParams());
// enrich
- $enrichment = new TransactionGroupEnrichment();
+ $enrichment = new TransactionGroupEnrichment();
$enrichment->setUser($admin);
$transactions = $enrichment->enrich($paginator->getCollection());
/** @var TransactionGroupTransformer $transformer */
- $transformer = app(TransactionGroupTransformer::class);
+ $transformer = app(TransactionGroupTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($transactions, $transformer, 'transactions');
+ $resource = new FractalCollection($transactions, $transformer, 'transactions');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
diff --git a/app/Api/V1/Controllers/Models/BudgetLimit/ShowController.php b/app/Api/V1/Controllers/Models/BudgetLimit/ShowController.php
index 125f64c25b..811ca7d0ef 100644
--- a/app/Api/V1/Controllers/Models/BudgetLimit/ShowController.php
+++ b/app/Api/V1/Controllers/Models/BudgetLimit/ShowController.php
@@ -47,7 +47,7 @@ use League\Fractal\Resource\Item;
final class ShowController extends Controller
{
private BudgetLimitRepositoryInterface $blRepository;
- private BudgetRepositoryInterface $repository;
+ private BudgetRepositoryInterface $repository;
/**
* BudgetLimitController constructor.
@@ -76,35 +76,35 @@ final class ShowController extends Controller
public function index(Budget $budget): JsonResponse
{
/** @var User $admin */
- $admin = auth()->user();
+ $admin = auth()->user();
// enrich budget:
- $enrichment = new BudgetEnrichment();
+ $enrichment = new BudgetEnrichment();
$enrichment->setUser($admin);
$enrichment->setStart($this->parameters->get('start'));
$enrichment->setEnd($this->parameters->get('end'));
/** @var Budget $budget */
- $budget = $enrichment->enrichSingle($budget);
+ $budget = $enrichment->enrichSingle($budget);
- $manager = $this->getManager();
+ $manager = $this->getManager();
$manager->parseIncludes('budget');
$pageSize = $this->parameters->get('limit');
$collection = $this->blRepository->getBudgetLimits($budget, $this->parameters->get('start'), $this->parameters->get('end'));
$count = $collection->count();
$budgetLimits = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
$paginator = new LengthAwarePaginator($budgetLimits, $count, $pageSize, $this->parameters->get('page'));
- $paginator->setPath(route('api.v1.budgets.limits.index', [$budget->id]).$this->buildParams());
+ $paginator->setPath(route('api.v1.budgets.limits.index', [$budget->id]) . $this->buildParams());
// enrich
- $enrichment = new BudgetLimitEnrichment();
+ $enrichment = new BudgetLimitEnrichment();
$enrichment->setUser($admin);
$budgetLimits = $enrichment->enrich($budgetLimits);
/** @var BudgetLimitTransformer $transformer */
- $transformer = app(BudgetLimitTransformer::class);
+ $transformer = app(BudgetLimitTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($budgetLimits, $transformer, 'budget_limits');
+ $resource = new FractalCollection($budgetLimits, $transformer, 'budget_limits');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -120,27 +120,27 @@ final class ShowController extends Controller
*/
public function indexAll(DateRangeRequest $request): JsonResponse
{
- $manager = $this->getManager();
+ $manager = $this->getManager();
$manager->parseIncludes('budget');
$pageSize = $this->parameters->get('limit');
$collection = $this->blRepository->getAllBudgetLimits($request->attributes->get('start'), $request->attributes->get('end'));
$count = $collection->count();
$budgetLimits = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
$paginator = new LengthAwarePaginator($budgetLimits, $count, $pageSize, $this->parameters->get('page'));
- $paginator->setPath(route('api.v1.budget-limits.index').$this->buildParams());
+ $paginator->setPath(route('api.v1.budget-limits.index') . $this->buildParams());
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new BudgetLimitEnrichment();
+ $admin = auth()->user();
+ $enrichment = new BudgetLimitEnrichment();
$enrichment->setUser($admin);
$budgetLimits = $enrichment->enrich($budgetLimits);
/** @var BudgetLimitTransformer $transformer */
- $transformer = app(BudgetLimitTransformer::class);
+ $transformer = app(BudgetLimitTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($budgetLimits, $transformer, 'budget_limits');
+ $resource = new FractalCollection($budgetLimits, $transformer, 'budget_limits');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -158,19 +158,19 @@ final class ShowController extends Controller
throw new FireflyException('20028: The budget limit does not belong to the budget.');
}
// continue!
- $manager = $this->getManager();
+ $manager = $this->getManager();
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new BudgetLimitEnrichment();
+ $admin = auth()->user();
+ $enrichment = new BudgetLimitEnrichment();
$enrichment->setUser($admin);
$budgetLimit = $enrichment->enrichSingle($budgetLimit);
/** @var BudgetLimitTransformer $transformer */
$transformer = app(BudgetLimitTransformer::class);
- $resource = new Item($budgetLimit, $transformer, 'budget_limits');
+ $resource = new Item($budgetLimit, $transformer, 'budget_limits');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/BudgetLimit/StoreController.php b/app/Api/V1/Controllers/Models/BudgetLimit/StoreController.php
index 17022a1285..a6e2b5b974 100644
--- a/app/Api/V1/Controllers/Models/BudgetLimit/StoreController.php
+++ b/app/Api/V1/Controllers/Models/BudgetLimit/StoreController.php
@@ -65,27 +65,27 @@ final class StoreController extends Controller
*/
public function store(StoreRequest $request, Budget $budget): JsonResponse
{
- $data = $request->getAll();
- $data['start_date'] = $data['start'];
- $data['end_date'] = $data['end'];
+ $data = $request->getAll();
+ $data['start_date'] = $data['start'];
+ $data['end_date'] = $data['end'];
$data['fire_webhooks'] ??= true;
- $data['budget_id'] = $budget->id;
+ $data['budget_id'] = $budget->id;
- $budgetLimit = $this->blRepository->store($data);
- $manager = $this->getManager();
+ $budgetLimit = $this->blRepository->store($data);
+ $manager = $this->getManager();
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new BudgetLimitEnrichment();
+ $admin = auth()->user();
+ $enrichment = new BudgetLimitEnrichment();
$enrichment->setUser($admin);
- $budgetLimit = $enrichment->enrichSingle($budgetLimit);
+ $budgetLimit = $enrichment->enrichSingle($budgetLimit);
/** @var BudgetLimitTransformer $transformer */
- $transformer = app(BudgetLimitTransformer::class);
+ $transformer = app(BudgetLimitTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($budgetLimit, $transformer, 'budget_limits');
+ $resource = new Item($budgetLimit, $transformer, 'budget_limits');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/BudgetLimit/UpdateController.php b/app/Api/V1/Controllers/Models/BudgetLimit/UpdateController.php
index 2106b0ca09..54c8287efd 100644
--- a/app/Api/V1/Controllers/Models/BudgetLimit/UpdateController.php
+++ b/app/Api/V1/Controllers/Models/BudgetLimit/UpdateController.php
@@ -74,24 +74,24 @@ final class UpdateController extends Controller
if ($budget->id !== $budgetLimit->budget_id) {
throw new FireflyException('20028: The budget limit does not belong to the budget.');
}
- $data = $request->getAll();
+ $data = $request->getAll();
$data['fire_webhooks'] ??= true;
- $data['budget_id'] = $budget->id;
- $budgetLimit = $this->blRepository->update($budgetLimit, $data);
- $manager = $this->getManager();
+ $data['budget_id'] = $budget->id;
+ $budgetLimit = $this->blRepository->update($budgetLimit, $data);
+ $manager = $this->getManager();
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new BudgetLimitEnrichment();
+ $admin = auth()->user();
+ $enrichment = new BudgetLimitEnrichment();
$enrichment->setUser($admin);
- $budgetLimit = $enrichment->enrichSingle($budgetLimit);
+ $budgetLimit = $enrichment->enrichSingle($budgetLimit);
/** @var BudgetLimitTransformer $transformer */
- $transformer = app(BudgetLimitTransformer::class);
+ $transformer = app(BudgetLimitTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($budgetLimit, $transformer, 'budget_limits');
+ $resource = new Item($budgetLimit, $transformer, 'budget_limits');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/Category/ListController.php b/app/Api/V1/Controllers/Models/Category/ListController.php
index 13752ccaf0..d3cd175818 100644
--- a/app/Api/V1/Controllers/Models/Category/ListController.php
+++ b/app/Api/V1/Controllers/Models/Category/ListController.php
@@ -68,22 +68,22 @@ final class ListController extends Controller
*/
public function attachments(Category $category): JsonResponse
{
- $manager = $this->getManager();
- $pageSize = $this->parameters->get('limit');
- $collection = $this->repository->getAttachments($category);
+ $manager = $this->getManager();
+ $pageSize = $this->parameters->get('limit');
+ $collection = $this->repository->getAttachments($category);
$count = $collection->count();
$attachments = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
// make paginator:
- $paginator = new LengthAwarePaginator($attachments, $count, $pageSize, $this->parameters->get('page'));
- $paginator->setPath(route('api.v1.categories.attachments', [$category->id]).$this->buildParams());
+ $paginator = new LengthAwarePaginator($attachments, $count, $pageSize, $this->parameters->get('page'));
+ $paginator->setPath(route('api.v1.categories.attachments', [$category->id]) . $this->buildParams());
/** @var AttachmentTransformer $transformer */
$transformer = app(AttachmentTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($attachments, $transformer, 'attachments');
+ $resource = new FractalCollection($attachments, $transformer, 'attachments');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -97,19 +97,19 @@ final class ListController extends Controller
*/
public function transactions(Request $request, Category $category): JsonResponse
{
- $pageSize = $this->parameters->get('limit');
- $type = $request->input('type') ?? 'default';
+ $pageSize = $this->parameters->get('limit');
+ $type = $request->input('type') ?? 'default';
$this->parameters->set('type', $type);
- $types = $this->mapTransactionTypes($this->parameters->get('type'));
- $manager = $this->getManager();
+ $types = $this->mapTransactionTypes($this->parameters->get('type'));
+ $manager = $this->getManager();
/** @var User $admin */
- $admin = auth()->user();
+ $admin = auth()->user();
// use new group collector:
/** @var GroupCollectorInterface $collector */
- $collector = app(GroupCollectorInterface::class);
+ $collector = app(GroupCollectorInterface::class);
$collector
->setUser($admin)
// filter on category.
@@ -121,8 +121,7 @@ final class ListController extends Controller
// set page to retrieve
->setPage($this->parameters->get('page'))
// set types of transactions to return.
- ->setTypes($types)
- ;
+ ->setTypes($types);
if (null !== $this->parameters->get('start')) {
$collector->setStart($this->parameters->get('start'));
@@ -131,19 +130,19 @@ final class ListController extends Controller
$collector->setEnd($this->parameters->get('end'));
}
- $paginator = $collector->getPaginatedGroups();
- $paginator->setPath(route('api.v1.categories.transactions', [$category->id]).$this->buildParams());
+ $paginator = $collector->getPaginatedGroups();
+ $paginator->setPath(route('api.v1.categories.transactions', [$category->id]) . $this->buildParams());
// enrich
- $enrichment = new TransactionGroupEnrichment();
+ $enrichment = new TransactionGroupEnrichment();
$enrichment->setUser($admin);
$transactions = $enrichment->enrich($paginator->getCollection());
/** @var TransactionGroupTransformer $transformer */
- $transformer = app(TransactionGroupTransformer::class);
+ $transformer = app(TransactionGroupTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($transactions, $transformer, 'transactions');
+ $resource = new FractalCollection($transactions, $transformer, 'transactions');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
diff --git a/app/Api/V1/Controllers/Models/Category/ShowController.php b/app/Api/V1/Controllers/Models/Category/ShowController.php
index 87f24f23a7..1756eb4962 100644
--- a/app/Api/V1/Controllers/Models/Category/ShowController.php
+++ b/app/Api/V1/Controllers/Models/Category/ShowController.php
@@ -65,33 +65,33 @@ final class ShowController extends Controller
*/
public function index(): JsonResponse
{
- $manager = $this->getManager();
+ $manager = $this->getManager();
// types to get, page size:
- $pageSize = $this->parameters->get('limit');
+ $pageSize = $this->parameters->get('limit');
// get list of budgets. Count it and split it.
- $collection = $this->repository->getCategories();
- $count = $collection->count();
- $categories = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
+ $collection = $this->repository->getCategories();
+ $count = $collection->count();
+ $categories = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new CategoryEnrichment();
+ $admin = auth()->user();
+ $enrichment = new CategoryEnrichment();
$enrichment->setUser($admin);
$enrichment->setStart($this->parameters->get('start'));
$enrichment->setEnd($this->parameters->get('end'));
- $categories = $enrichment->enrich($categories);
+ $categories = $enrichment->enrich($categories);
// make paginator:
- $paginator = new LengthAwarePaginator($categories, $count, $pageSize, $this->parameters->get('page'));
- $paginator->setPath(route('api.v1.categories.index').$this->buildParams());
+ $paginator = new LengthAwarePaginator($categories, $count, $pageSize, $this->parameters->get('page'));
+ $paginator->setPath(route('api.v1.categories.index') . $this->buildParams());
/** @var CategoryTransformer $transformer */
$transformer = app(CategoryTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($categories, $transformer, 'categories');
+ $resource = new FractalCollection($categories, $transformer, 'categories');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -105,7 +105,7 @@ final class ShowController extends Controller
*/
public function show(Category $category): JsonResponse
{
- $manager = $this->getManager();
+ $manager = $this->getManager();
/** @var CategoryTransformer $transformer */
$transformer = app(CategoryTransformer::class);
@@ -113,14 +113,14 @@ final class ShowController extends Controller
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new CategoryEnrichment();
+ $admin = auth()->user();
+ $enrichment = new CategoryEnrichment();
$enrichment->setUser($admin);
$enrichment->setStart($this->parameters->get('start'));
$enrichment->setEnd($this->parameters->get('end'));
- $category = $enrichment->enrichSingle($category);
+ $category = $enrichment->enrichSingle($category);
- $resource = new Item($category, $transformer, 'categories');
+ $resource = new Item($category, $transformer, 'categories');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/Category/StoreController.php b/app/Api/V1/Controllers/Models/Category/StoreController.php
index b9639902a3..16c801941c 100644
--- a/app/Api/V1/Controllers/Models/Category/StoreController.php
+++ b/app/Api/V1/Controllers/Models/Category/StoreController.php
@@ -65,8 +65,8 @@ final class StoreController extends Controller
*/
public function store(StoreRequest $request): JsonResponse
{
- $category = $this->repository->store($request->getAll());
- $manager = $this->getManager();
+ $category = $this->repository->store($request->getAll());
+ $manager = $this->getManager();
/** @var CategoryTransformer $transformer */
$transformer = app(CategoryTransformer::class);
@@ -74,14 +74,14 @@ final class StoreController extends Controller
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new CategoryEnrichment();
+ $admin = auth()->user();
+ $enrichment = new CategoryEnrichment();
$enrichment->setUser($admin);
$enrichment->setStart($this->parameters->get('start'));
$enrichment->setEnd($this->parameters->get('end'));
- $category = $enrichment->enrichSingle($category);
+ $category = $enrichment->enrichSingle($category);
- $resource = new Item($category, $transformer, 'categories');
+ $resource = new Item($category, $transformer, 'categories');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/Category/UpdateController.php b/app/Api/V1/Controllers/Models/Category/UpdateController.php
index 3f482b35ad..2059e9ad7b 100644
--- a/app/Api/V1/Controllers/Models/Category/UpdateController.php
+++ b/app/Api/V1/Controllers/Models/Category/UpdateController.php
@@ -63,9 +63,9 @@ final class UpdateController extends Controller
*/
public function update(UpdateRequest $request, Category $category): JsonResponse
{
- $data = $request->getAll();
- $category = $this->repository->update($category, $data);
- $manager = $this->getManager();
+ $data = $request->getAll();
+ $category = $this->repository->update($category, $data);
+ $manager = $this->getManager();
/** @var CategoryTransformer $transformer */
$transformer = app(CategoryTransformer::class);
@@ -73,14 +73,14 @@ final class UpdateController extends Controller
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new CategoryEnrichment();
+ $admin = auth()->user();
+ $enrichment = new CategoryEnrichment();
$enrichment->setUser($admin);
$enrichment->setStart($this->parameters->get('start'));
$enrichment->setEnd($this->parameters->get('end'));
- $category = $enrichment->enrichSingle($category);
+ $category = $enrichment->enrichSingle($category);
- $resource = new Item($category, $transformer, 'categories');
+ $resource = new Item($category, $transformer, 'categories');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/CurrencyExchangeRate/DestroyController.php b/app/Api/V1/Controllers/Models/CurrencyExchangeRate/DestroyController.php
index 94aed4d919..7280864bb0 100644
--- a/app/Api/V1/Controllers/Models/CurrencyExchangeRate/DestroyController.php
+++ b/app/Api/V1/Controllers/Models/CurrencyExchangeRate/DestroyController.php
@@ -45,7 +45,7 @@ final class DestroyController extends Controller
public const string RESOURCE_KEY = 'exchange-rates';
#[Override]
- protected array $acceptedRoles = [UserRoleEnum::OWNER];
+ protected array $acceptedRoles = [UserRoleEnum::OWNER];
private ExchangeRateRepositoryInterface $repository;
public function __construct()
diff --git a/app/Api/V1/Controllers/Models/CurrencyExchangeRate/IndexController.php b/app/Api/V1/Controllers/Models/CurrencyExchangeRate/IndexController.php
index f426a86476..319a3910d2 100644
--- a/app/Api/V1/Controllers/Models/CurrencyExchangeRate/IndexController.php
+++ b/app/Api/V1/Controllers/Models/CurrencyExchangeRate/IndexController.php
@@ -44,7 +44,7 @@ final class IndexController extends Controller
public const string RESOURCE_KEY = 'exchange-rates';
#[Override]
- protected array $acceptedRoles = [UserRoleEnum::OWNER];
+ protected array $acceptedRoles = [UserRoleEnum::OWNER];
private ExchangeRateRepositoryInterface $repository;
public function __construct()
diff --git a/app/Api/V1/Controllers/Models/CurrencyExchangeRate/ShowController.php b/app/Api/V1/Controllers/Models/CurrencyExchangeRate/ShowController.php
index 4b44b64d02..33d06d1202 100644
--- a/app/Api/V1/Controllers/Models/CurrencyExchangeRate/ShowController.php
+++ b/app/Api/V1/Controllers/Models/CurrencyExchangeRate/ShowController.php
@@ -48,7 +48,7 @@ final class ShowController extends Controller
public const string RESOURCE_KEY = 'exchange-rates';
#[Override]
- protected array $acceptedRoles = [UserRoleEnum::OWNER];
+ protected array $acceptedRoles = [UserRoleEnum::OWNER];
private ExchangeRateRepositoryInterface $repository;
public function __construct()
@@ -64,12 +64,12 @@ final class ShowController extends Controller
public function show(TransactionCurrency $from, TransactionCurrency $to): JsonResponse
{
- $pageSize = $this->parameters->get('limit');
- $page = $this->parameters->get('page');
- $rates = $this->repository->getRates($from, $to);
- $count = $rates->count();
- $rates = $rates->slice(($page - 1) * $pageSize, $pageSize);
- $paginator = new LengthAwarePaginator($rates, $count, $pageSize, $page);
+ $pageSize = $this->parameters->get('limit');
+ $page = $this->parameters->get('page');
+ $rates = $this->repository->getRates($from, $to);
+ $count = $rates->count();
+ $rates = $rates->slice(($page - 1) * $pageSize, $pageSize);
+ $paginator = new LengthAwarePaginator($rates, $count, $pageSize, $page);
$transformer = new ExchangeRateTransformer();
$transformer->setParameters($this->parameters); // give params to transformer
@@ -79,7 +79,7 @@ final class ShowController extends Controller
public function showSingleByDate(TransactionCurrency $from, TransactionCurrency $to, Carbon $date): JsonResponse
{
- $transformer = new ExchangeRateTransformer();
+ $transformer = new ExchangeRateTransformer();
$transformer->setParameters($this->parameters);
$exchangeRate = $this->repository->getSpecificRateOnDate($from, $to, $date);
diff --git a/app/Api/V1/Controllers/Models/CurrencyExchangeRate/StoreController.php b/app/Api/V1/Controllers/Models/CurrencyExchangeRate/StoreController.php
index c400d41f36..8fbad4b338 100644
--- a/app/Api/V1/Controllers/Models/CurrencyExchangeRate/StoreController.php
+++ b/app/Api/V1/Controllers/Models/CurrencyExchangeRate/StoreController.php
@@ -51,7 +51,7 @@ final class StoreController extends Controller
public const string RESOURCE_KEY = 'exchange-rates';
#[Override]
- protected array $acceptedRoles = [UserRoleEnum::OWNER];
+ protected array $acceptedRoles = [UserRoleEnum::OWNER];
private ExchangeRateRepositoryInterface $repository;
public function __construct()
@@ -67,13 +67,13 @@ final class StoreController extends Controller
public function store(StoreRequest $request): JsonResponse
{
- $date = $request->getDate();
- $rate = $request->getRate();
- $from = $request->getFromCurrency();
- $to = $request->getToCurrency();
+ $date = $request->getDate();
+ $rate = $request->getRate();
+ $from = $request->getFromCurrency();
+ $to = $request->getToCurrency();
// already has rate?
- $object = $this->repository->getSpecificRateOnDate($from, $to, $date);
+ $object = $this->repository->getSpecificRateOnDate($from, $to, $date);
if ($object instanceof CurrencyExchangeRate) {
// just update it, no matter.
$rate = $this->repository->updateExchangeRate($object, $rate, $date);
@@ -93,8 +93,8 @@ final class StoreController extends Controller
public function storeByCurrencies(StoreByCurrenciesRequest $request, TransactionCurrency $from, TransactionCurrency $to): JsonResponse
{
- $data = $request->getAll();
- $collection = new Collection();
+ $data = $request->getAll();
+ $collection = new Collection();
foreach ($data as $date => $rate) {
$date = Carbon::createFromFormat('Y-m-d', $date);
@@ -107,7 +107,7 @@ final class StoreController extends Controller
continue;
}
- $new = $this->repository->storeExchangeRate($from, $to, $rate, $date);
+ $new = $this->repository->storeExchangeRate($from, $to, $rate, $date);
event(new CreatedCurrencyExchangeRate($new));
$collection->push($new);
}
@@ -122,9 +122,9 @@ final class StoreController extends Controller
public function storeByDate(StoreByDateRequest $request, Carbon $date): JsonResponse
{
- $data = $request->getAll();
- $from = $request->getFromCurrency();
- $collection = new Collection();
+ $data = $request->getAll();
+ $from = $request->getFromCurrency();
+ $collection = new Collection();
foreach ($data['rates'] as $key => $rate) {
$to = Amount::getTransactionCurrencyByCode($key);
$existing = $this->repository->getSpecificRateOnDate($from, $to, $date);
@@ -136,7 +136,7 @@ final class StoreController extends Controller
continue;
}
- $new = $this->repository->storeExchangeRate($from, $to, $rate, $date);
+ $new = $this->repository->storeExchangeRate($from, $to, $rate, $date);
$collection->push($new);
event(new CreatedCurrencyExchangeRate($new));
}
diff --git a/app/Api/V1/Controllers/Models/CurrencyExchangeRate/UpdateController.php b/app/Api/V1/Controllers/Models/CurrencyExchangeRate/UpdateController.php
index 701a56fe11..93811fec05 100644
--- a/app/Api/V1/Controllers/Models/CurrencyExchangeRate/UpdateController.php
+++ b/app/Api/V1/Controllers/Models/CurrencyExchangeRate/UpdateController.php
@@ -46,7 +46,7 @@ final class UpdateController extends Controller
public const string RESOURCE_KEY = 'exchange-rates';
#[Override]
- protected array $acceptedRoles = [UserRoleEnum::OWNER];
+ protected array $acceptedRoles = [UserRoleEnum::OWNER];
private ExchangeRateRepositoryInterface $repository;
public function __construct()
@@ -70,7 +70,7 @@ final class UpdateController extends Controller
$rate = $request->getRate();
$exchangeRate = $this->repository->updateExchangeRate($exchangeRate, $rate, $date);
event(new UpdatedCurrencyExchangeRate($exchangeRate));
- $transformer = new ExchangeRateTransformer();
+ $transformer = new ExchangeRateTransformer();
return response()->api($this->jsonApiObject(self::RESOURCE_KEY, $exchangeRate, $transformer))->header('Content-Type', self::CONTENT_TYPE);
}
@@ -81,7 +81,7 @@ final class UpdateController extends Controller
$rate = $request->getRate();
$exchangeRate = $this->repository->updateExchangeRate($exchangeRate, $rate, $date);
event(new UpdatedCurrencyExchangeRate($exchangeRate));
- $transformer = new ExchangeRateTransformer();
+ $transformer = new ExchangeRateTransformer();
$transformer->setParameters($this->parameters);
return response()->api($this->jsonApiObject(self::RESOURCE_KEY, $exchangeRate, $transformer))->header('Content-Type', self::CONTENT_TYPE);
diff --git a/app/Api/V1/Controllers/Models/ObjectGroup/ListController.php b/app/Api/V1/Controllers/Models/ObjectGroup/ListController.php
index 6a4e7ebc33..b41babd180 100644
--- a/app/Api/V1/Controllers/Models/ObjectGroup/ListController.php
+++ b/app/Api/V1/Controllers/Models/ObjectGroup/ListController.php
@@ -68,32 +68,32 @@ final class ListController extends Controller
*/
public function bills(ObjectGroup $objectGroup): JsonResponse
{
- $manager = $this->getManager();
+ $manager = $this->getManager();
- $pageSize = $this->parameters->get('limit');
+ $pageSize = $this->parameters->get('limit');
// get list of piggy banks. Count it and split it.
- $collection = $this->repository->getBills($objectGroup);
- $count = $collection->count();
- $bills = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
+ $collection = $this->repository->getBills($objectGroup);
+ $count = $collection->count();
+ $bills = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new SubscriptionEnrichment();
+ $admin = auth()->user();
+ $enrichment = new SubscriptionEnrichment();
$enrichment->setUser($admin);
$enrichment->setStart($this->parameters->get('start'));
$enrichment->setEnd($this->parameters->get('end'));
- $bills = $enrichment->enrich($bills);
+ $bills = $enrichment->enrich($bills);
// make paginator:
- $paginator = new LengthAwarePaginator($bills, $count, $pageSize, $this->parameters->get('page'));
- $paginator->setPath(route('api.v1.currencies.bills', [$objectGroup->id]).$this->buildParams());
+ $paginator = new LengthAwarePaginator($bills, $count, $pageSize, $this->parameters->get('page'));
+ $paginator->setPath(route('api.v1.currencies.bills', [$objectGroup->id]) . $this->buildParams());
/** @var BillTransformer $transformer */
$transformer = app(BillTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($bills, $transformer, 'bills');
+ $resource = new FractalCollection($bills, $transformer, 'bills');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -108,32 +108,32 @@ final class ListController extends Controller
public function piggyBanks(ObjectGroup $objectGroup): JsonResponse
{
// create some objects:
- $manager = $this->getManager();
+ $manager = $this->getManager();
// types to get, page size:
- $pageSize = $this->parameters->get('limit');
+ $pageSize = $this->parameters->get('limit');
// get list of piggy banks. Count it and split it.
- $collection = $this->repository->getPiggyBanks($objectGroup);
- $count = $collection->count();
- $piggyBanks = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
+ $collection = $this->repository->getPiggyBanks($objectGroup);
+ $count = $collection->count();
+ $piggyBanks = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new PiggyBankEnrichment();
+ $admin = auth()->user();
+ $enrichment = new PiggyBankEnrichment();
$enrichment->setUser($admin);
- $piggyBanks = $enrichment->enrich($piggyBanks);
+ $piggyBanks = $enrichment->enrich($piggyBanks);
// make paginator:
- $paginator = new LengthAwarePaginator($piggyBanks, $count, $pageSize, $this->parameters->get('page'));
- $paginator->setPath(route('api.v1.object-groups.piggy-banks', [$objectGroup->id]).$this->buildParams());
+ $paginator = new LengthAwarePaginator($piggyBanks, $count, $pageSize, $this->parameters->get('page'));
+ $paginator->setPath(route('api.v1.object-groups.piggy-banks', [$objectGroup->id]) . $this->buildParams());
/** @var PiggyBankTransformer $transformer */
$transformer = app(PiggyBankTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($piggyBanks, $transformer, 'piggy-banks');
+ $resource = new FractalCollection($piggyBanks, $transformer, 'piggy-banks');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
diff --git a/app/Api/V1/Controllers/Models/ObjectGroup/ShowController.php b/app/Api/V1/Controllers/Models/ObjectGroup/ShowController.php
index 589a60f4b6..169616a0e6 100644
--- a/app/Api/V1/Controllers/Models/ObjectGroup/ShowController.php
+++ b/app/Api/V1/Controllers/Models/ObjectGroup/ShowController.php
@@ -66,10 +66,10 @@ final class ShowController extends Controller
*/
public function index(): JsonResponse
{
- $manager = $this->getManager();
+ $manager = $this->getManager();
// types to get, page size:
- $pageSize = $this->parameters->get('limit');
+ $pageSize = $this->parameters->get('limit');
$this->repository->resetOrder();
$collection = $this->repository->get();
@@ -77,14 +77,14 @@ final class ShowController extends Controller
$objectGroups = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
// make paginator:
- $paginator = new LengthAwarePaginator($objectGroups, $count, $pageSize, $this->parameters->get('page'));
- $paginator->setPath(route('api.v1.object-groups.index').$this->buildParams());
+ $paginator = new LengthAwarePaginator($objectGroups, $count, $pageSize, $this->parameters->get('page'));
+ $paginator->setPath(route('api.v1.object-groups.index') . $this->buildParams());
/** @var ObjectGroupTransformer $transformer */
- $transformer = app(ObjectGroupTransformer::class);
+ $transformer = app(ObjectGroupTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($objectGroups, $transformer, 'object_groups');
+ $resource = new FractalCollection($objectGroups, $transformer, 'object_groups');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -98,14 +98,14 @@ final class ShowController extends Controller
*/
public function show(ObjectGroup $objectGroup): JsonResponse
{
- $manager = $this->getManager();
+ $manager = $this->getManager();
$this->repository->resetOrder();
$objectGroup->refresh();
/** @var ObjectGroupTransformer $transformer */
$transformer = app(ObjectGroupTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($objectGroup, $transformer, 'object_groups');
+ $resource = new Item($objectGroup, $transformer, 'object_groups');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/ObjectGroup/UpdateController.php b/app/Api/V1/Controllers/Models/ObjectGroup/UpdateController.php
index c39763e600..dd4f03cb27 100644
--- a/app/Api/V1/Controllers/Models/ObjectGroup/UpdateController.php
+++ b/app/Api/V1/Controllers/Models/ObjectGroup/UpdateController.php
@@ -62,15 +62,15 @@ final class UpdateController extends Controller
*/
public function update(UpdateRequest $request, ObjectGroup $objectGroup): JsonResponse
{
- $data = $request->getUpdateData();
+ $data = $request->getUpdateData();
$this->repository->update($objectGroup, $data);
$this->repository->resetOrder();
- $manager = $this->getManager();
+ $manager = $this->getManager();
/** @var ObjectGroupTransformer $transformer */
$transformer = app(ObjectGroupTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($objectGroup, $transformer, 'object_groups');
+ $resource = new Item($objectGroup, $transformer, 'object_groups');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/PiggyBank/ListController.php b/app/Api/V1/Controllers/Models/PiggyBank/ListController.php
index 60117da1a0..0db8c04f2d 100644
--- a/app/Api/V1/Controllers/Models/PiggyBank/ListController.php
+++ b/app/Api/V1/Controllers/Models/PiggyBank/ListController.php
@@ -68,30 +68,30 @@ final class ListController extends Controller
public function accounts(PiggyBank $piggyBank): JsonResponse
{
// types to get, page size:
- $pageSize = $this->parameters->get('limit');
- $manager = $this->getManager();
+ $pageSize = $this->parameters->get('limit');
+ $manager = $this->getManager();
- $collection = $piggyBank->accounts;
- $count = $collection->count();
- $accounts = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
+ $collection = $piggyBank->accounts;
+ $count = $collection->count();
+ $accounts = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new AccountEnrichment();
+ $admin = auth()->user();
+ $enrichment = new AccountEnrichment();
$enrichment->setDate($this->parameters->get('date'));
$enrichment->setUser($admin);
- $accounts = $enrichment->enrich($accounts);
+ $accounts = $enrichment->enrich($accounts);
// make paginator:
- $paginator = new LengthAwarePaginator($accounts, $count, $pageSize, $this->parameters->get('page'));
- $paginator->setPath(route('api.v1.piggy-banks.accounts', [$piggyBank->id]).$this->buildParams());
+ $paginator = new LengthAwarePaginator($accounts, $count, $pageSize, $this->parameters->get('page'));
+ $paginator->setPath(route('api.v1.piggy-banks.accounts', [$piggyBank->id]) . $this->buildParams());
/** @var AccountTransformer $transformer */
$transformer = app(AccountTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($accounts, $transformer, 'accounts');
+ $resource = new FractalCollection($accounts, $transformer, 'accounts');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -103,22 +103,22 @@ final class ListController extends Controller
*/
public function attachments(PiggyBank $piggyBank): JsonResponse
{
- $manager = $this->getManager();
- $pageSize = $this->parameters->get('limit');
- $collection = $this->repository->getAttachments($piggyBank);
+ $manager = $this->getManager();
+ $pageSize = $this->parameters->get('limit');
+ $collection = $this->repository->getAttachments($piggyBank);
$count = $collection->count();
$attachments = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
// make paginator:
- $paginator = new LengthAwarePaginator($attachments, $count, $pageSize, $this->parameters->get('page'));
- $paginator->setPath(route('api.v1.piggy-banks.attachments', [$piggyBank->id]).$this->buildParams());
+ $paginator = new LengthAwarePaginator($attachments, $count, $pageSize, $this->parameters->get('page'));
+ $paginator->setPath(route('api.v1.piggy-banks.attachments', [$piggyBank->id]) . $this->buildParams());
/** @var AttachmentTransformer $transformer */
$transformer = app(AttachmentTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($attachments, $transformer, 'attachments');
+ $resource = new FractalCollection($attachments, $transformer, 'attachments');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -133,29 +133,29 @@ final class ListController extends Controller
public function piggyBankEvents(PiggyBank $piggyBank): JsonResponse
{
// types to get, page size:
- $pageSize = $this->parameters->get('limit');
- $manager = $this->getManager();
+ $pageSize = $this->parameters->get('limit');
+ $manager = $this->getManager();
- $collection = $this->repository->getEvents($piggyBank);
- $count = $collection->count();
- $events = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
+ $collection = $this->repository->getEvents($piggyBank);
+ $count = $collection->count();
+ $events = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new PiggyBankEventEnrichment();
+ $admin = auth()->user();
+ $enrichment = new PiggyBankEventEnrichment();
$enrichment->setUser($admin);
- $events = $enrichment->enrich($events);
+ $events = $enrichment->enrich($events);
// make paginator:
- $paginator = new LengthAwarePaginator($events, $count, $pageSize, $this->parameters->get('page'));
- $paginator->setPath(route('api.v1.piggy-banks.events', [$piggyBank->id]).$this->buildParams());
+ $paginator = new LengthAwarePaginator($events, $count, $pageSize, $this->parameters->get('page'));
+ $paginator->setPath(route('api.v1.piggy-banks.events', [$piggyBank->id]) . $this->buildParams());
/** @var PiggyBankEventTransformer $transformer */
$transformer = app(PiggyBankEventTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($events, $transformer, sprintf('piggy-banks/%d/events', $piggyBank->id));
+ $resource = new FractalCollection($events, $transformer, sprintf('piggy-banks/%d/events', $piggyBank->id));
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
diff --git a/app/Api/V1/Controllers/Models/PiggyBank/ShowController.php b/app/Api/V1/Controllers/Models/PiggyBank/ShowController.php
index f305d7cd25..182cc84115 100644
--- a/app/Api/V1/Controllers/Models/PiggyBank/ShowController.php
+++ b/app/Api/V1/Controllers/Models/PiggyBank/ShowController.php
@@ -65,31 +65,31 @@ final class ShowController extends Controller
*/
public function index(): JsonResponse
{
- $manager = $this->getManager();
+ $manager = $this->getManager();
// types to get, page size:
- $pageSize = $this->parameters->get('limit');
+ $pageSize = $this->parameters->get('limit');
// get list of piggy banks. Count it and split it.
- $collection = $this->repository->getPiggyBanks();
- $count = $collection->count();
- $piggyBanks = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
+ $collection = $this->repository->getPiggyBanks();
+ $count = $collection->count();
+ $piggyBanks = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new PiggyBankEnrichment();
+ $admin = auth()->user();
+ $enrichment = new PiggyBankEnrichment();
$enrichment->setUser($admin);
- $piggyBanks = $enrichment->enrich($piggyBanks);
+ $piggyBanks = $enrichment->enrich($piggyBanks);
// make paginator:
- $paginator = new LengthAwarePaginator($piggyBanks, $count, $pageSize, $this->parameters->get('page'));
- $paginator->setPath(route('api.v1.piggy-banks.index').$this->buildParams());
+ $paginator = new LengthAwarePaginator($piggyBanks, $count, $pageSize, $this->parameters->get('page'));
+ $paginator->setPath(route('api.v1.piggy-banks.index') . $this->buildParams());
/** @var PiggyBankTransformer $transformer */
$transformer = app(PiggyBankTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($piggyBanks, $transformer, 'piggy-banks');
+ $resource = new FractalCollection($piggyBanks, $transformer, 'piggy-banks');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -103,20 +103,20 @@ final class ShowController extends Controller
*/
public function show(PiggyBank $piggyBank): JsonResponse
{
- $manager = $this->getManager();
+ $manager = $this->getManager();
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new PiggyBankEnrichment();
+ $admin = auth()->user();
+ $enrichment = new PiggyBankEnrichment();
$enrichment->setUser($admin);
- $piggyBank = $enrichment->enrichSingle($piggyBank);
+ $piggyBank = $enrichment->enrichSingle($piggyBank);
/** @var PiggyBankTransformer $transformer */
$transformer = app(PiggyBankTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($piggyBank, $transformer, 'piggy-banks');
+ $resource = new Item($piggyBank, $transformer, 'piggy-banks');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/PiggyBank/StoreController.php b/app/Api/V1/Controllers/Models/PiggyBank/StoreController.php
index d502921765..8e7baddb18 100644
--- a/app/Api/V1/Controllers/Models/PiggyBank/StoreController.php
+++ b/app/Api/V1/Controllers/Models/PiggyBank/StoreController.php
@@ -65,21 +65,21 @@ final class StoreController extends Controller
*/
public function store(StoreRequest $request): JsonResponse
{
- $piggyBank = $this->repository->store($request->getAll());
- $manager = $this->getManager();
+ $piggyBank = $this->repository->store($request->getAll());
+ $manager = $this->getManager();
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new PiggyBankEnrichment();
+ $admin = auth()->user();
+ $enrichment = new PiggyBankEnrichment();
$enrichment->setUser($admin);
- $piggyBank = $enrichment->enrichSingle($piggyBank);
+ $piggyBank = $enrichment->enrichSingle($piggyBank);
/** @var PiggyBankTransformer $transformer */
$transformer = app(PiggyBankTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($piggyBank, $transformer, 'piggy_banks');
+ $resource = new Item($piggyBank, $transformer, 'piggy_banks');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/PiggyBank/UpdateController.php b/app/Api/V1/Controllers/Models/PiggyBank/UpdateController.php
index 65f742b31a..dcbfed4f6e 100644
--- a/app/Api/V1/Controllers/Models/PiggyBank/UpdateController.php
+++ b/app/Api/V1/Controllers/Models/PiggyBank/UpdateController.php
@@ -63,23 +63,23 @@ final class UpdateController extends Controller
*/
public function update(UpdateRequest $request, PiggyBank $piggyBank): JsonResponse
{
- $data = $request->getAll();
- $piggyBank = $this->repository->update($piggyBank, $data);
+ $data = $request->getAll();
+ $piggyBank = $this->repository->update($piggyBank, $data);
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new PiggyBankEnrichment();
+ $admin = auth()->user();
+ $enrichment = new PiggyBankEnrichment();
$enrichment->setUser($admin);
- $piggyBank = $enrichment->enrichSingle($piggyBank);
+ $piggyBank = $enrichment->enrichSingle($piggyBank);
- $manager = $this->getManager();
+ $manager = $this->getManager();
/** @var PiggyBankTransformer $transformer */
$transformer = app(PiggyBankTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($piggyBank, $transformer, 'piggy-banks');
+ $resource = new Item($piggyBank, $transformer, 'piggy-banks');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/Recurrence/ListController.php b/app/Api/V1/Controllers/Models/Recurrence/ListController.php
index 151019fae6..6857fe8159 100644
--- a/app/Api/V1/Controllers/Models/Recurrence/ListController.php
+++ b/app/Api/V1/Controllers/Models/Recurrence/ListController.php
@@ -68,21 +68,21 @@ final class ListController extends Controller
*/
public function transactions(Request $request, Recurrence $recurrence): JsonResponse
{
- $pageSize = $this->parameters->get('limit');
- $type = $request->input('type') ?? 'default';
+ $pageSize = $this->parameters->get('limit');
+ $type = $request->input('type') ?? 'default';
$this->parameters->set('type', $type);
- $types = $this->mapTransactionTypes($this->parameters->get('type'));
- $manager = $this->getManager();
+ $types = $this->mapTransactionTypes($this->parameters->get('type'));
+ $manager = $this->getManager();
// whatever is returned by the query, it must be part of these journals:
- $journalIds = $this->repository->getJournalIds($recurrence);
+ $journalIds = $this->repository->getJournalIds($recurrence);
/** @var User $admin */
- $admin = auth()->user();
+ $admin = auth()->user();
// use new group collector:
/** @var GroupCollectorInterface $collector */
- $collector = app(GroupCollectorInterface::class);
+ $collector = app(GroupCollectorInterface::class);
if (0 === count($journalIds)) {
$collector->findNothing();
}
@@ -97,8 +97,7 @@ final class ListController extends Controller
// set page to retrieve
->setPage($this->parameters->get('page'))
// set types of transactions to return.
- ->setTypes($types)
- ;
+ ->setTypes($types);
if (null !== $this->parameters->get('start')) {
$collector->setStart($this->parameters->get('start'));
@@ -107,19 +106,19 @@ final class ListController extends Controller
$collector->setEnd($this->parameters->get('end'));
}
- $paginator = $collector->getPaginatedGroups();
- $paginator->setPath(route('api.v1.transactions.index').$this->buildParams());
+ $paginator = $collector->getPaginatedGroups();
+ $paginator->setPath(route('api.v1.transactions.index') . $this->buildParams());
// enrich
- $enrichment = new TransactionGroupEnrichment();
+ $enrichment = new TransactionGroupEnrichment();
$enrichment->setUser($admin);
$transactions = $enrichment->enrich($paginator->getCollection());
/** @var TransactionGroupTransformer $transformer */
- $transformer = app(TransactionGroupTransformer::class);
+ $transformer = app(TransactionGroupTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($transactions, $transformer, 'transactions');
+ $resource = new FractalCollection($transactions, $transformer, 'transactions');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
diff --git a/app/Api/V1/Controllers/Models/Recurrence/ShowController.php b/app/Api/V1/Controllers/Models/Recurrence/ShowController.php
index 8c9cdef82a..f4223e647b 100644
--- a/app/Api/V1/Controllers/Models/Recurrence/ShowController.php
+++ b/app/Api/V1/Controllers/Models/Recurrence/ShowController.php
@@ -65,10 +65,10 @@ final class ShowController extends Controller
*/
public function index(): JsonResponse
{
- $manager = $this->getManager();
+ $manager = $this->getManager();
// types to get, page size:
- $pageSize = $this->parameters->get('limit');
+ $pageSize = $this->parameters->get('limit');
// get list of budgets. Count it and split it.
$collection = $this->repository->get();
@@ -77,20 +77,20 @@ final class ShowController extends Controller
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new RecurringEnrichment();
+ $admin = auth()->user();
+ $enrichment = new RecurringEnrichment();
$enrichment->setUser($admin);
$recurrences = $enrichment->enrich($recurrences);
// make paginator:
- $paginator = new LengthAwarePaginator($recurrences, $count, $pageSize, $this->parameters->get('page'));
- $paginator->setPath(route('api.v1.recurrences.index').$this->buildParams());
+ $paginator = new LengthAwarePaginator($recurrences, $count, $pageSize, $this->parameters->get('page'));
+ $paginator->setPath(route('api.v1.recurrences.index') . $this->buildParams());
/** @var RecurrenceTransformer $transformer */
$transformer = app(RecurrenceTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($recurrences, $transformer, 'recurrences');
+ $resource = new FractalCollection($recurrences, $transformer, 'recurrences');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -104,20 +104,20 @@ final class ShowController extends Controller
*/
public function show(Recurrence $recurrence): JsonResponse
{
- $manager = $this->getManager();
+ $manager = $this->getManager();
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new RecurringEnrichment();
+ $admin = auth()->user();
+ $enrichment = new RecurringEnrichment();
$enrichment->setUser($admin);
- $recurrence = $enrichment->enrichSingle($recurrence);
+ $recurrence = $enrichment->enrichSingle($recurrence);
/** @var RecurrenceTransformer $transformer */
$transformer = app(RecurrenceTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($recurrence, $transformer, 'recurrences');
+ $resource = new Item($recurrence, $transformer, 'recurrences');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/Recurrence/StoreController.php b/app/Api/V1/Controllers/Models/Recurrence/StoreController.php
index 2c3a574f4f..202b0c5377 100644
--- a/app/Api/V1/Controllers/Models/Recurrence/StoreController.php
+++ b/app/Api/V1/Controllers/Models/Recurrence/StoreController.php
@@ -65,22 +65,22 @@ final class StoreController extends Controller
*/
public function store(StoreRequest $request): JsonResponse
{
- $data = $request->getAll();
- $recurrence = $this->repository->store($data);
- $manager = $this->getManager();
+ $data = $request->getAll();
+ $recurrence = $this->repository->store($data);
+ $manager = $this->getManager();
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new RecurringEnrichment();
+ $admin = auth()->user();
+ $enrichment = new RecurringEnrichment();
$enrichment->setUser($admin);
- $recurrence = $enrichment->enrichSingle($recurrence);
+ $recurrence = $enrichment->enrichSingle($recurrence);
/** @var RecurrenceTransformer $transformer */
$transformer = app(RecurrenceTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($recurrence, $transformer, 'recurrences');
+ $resource = new Item($recurrence, $transformer, 'recurrences');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/Recurrence/TriggerController.php b/app/Api/V1/Controllers/Models/Recurrence/TriggerController.php
index f3f1f31dc0..a04c0afc0b 100644
--- a/app/Api/V1/Controllers/Models/Recurrence/TriggerController.php
+++ b/app/Api/V1/Controllers/Models/Recurrence/TriggerController.php
@@ -63,31 +63,31 @@ final class TriggerController extends Controller
{
// find recurrence occurrence for this date and trigger it.
// grab the date from the last time the recurrence fired:
- $backupDate = $recurrence->latest_date;
- $date = $request->attributes->get('date');
+ $backupDate = $recurrence->latest_date;
+ $date = $request->attributes->get('date');
// fire the recurring cron job on the given date, then post-date the created transaction.
Log::info(sprintf('Trigger: will now fire recurring cron job task for date "%s".', $date->format('Y-m-d H:i:s')));
/** @var CreateRecurringTransactions $job */
- $job = app(CreateRecurringTransactions::class);
+ $job = app(CreateRecurringTransactions::class);
$job->setRecurrences(new Collection()->push($recurrence));
$job->setDate($date);
$job->setForce(false);
$job->handle();
Log::debug('Done with recurrence.');
- $groups = $job->getGroups();
+ $groups = $job->getGroups();
$this->repository->markGroupsAsNow($groups);
- $recurrence = $this->repository->setLatestDate($recurrence, $backupDate);
+ $recurrence = $this->repository->setLatestDate($recurrence, $backupDate);
Preferences::mark();
// enrich groups and return them:
- $paginator = new LengthAwarePaginator(new Collection(), 0, 1);
+ $paginator = new LengthAwarePaginator(new Collection(), 0, 1);
if ($groups->count() > 0) {
/** @var User $admin */
- $admin = auth()->user();
+ $admin = auth()->user();
// use new group collector:
/** @var GroupCollectorInterface $collector */
@@ -96,20 +96,20 @@ final class TriggerController extends Controller
$paginator = $collector->getPaginatedGroups();
}
- $manager = $this->getManager();
- $paginator->setPath(route('api.v1.recurrences.trigger', [$recurrence->id]).$this->buildParams());
+ $manager = $this->getManager();
+ $paginator->setPath(route('api.v1.recurrences.trigger', [$recurrence->id]) . $this->buildParams());
// enrich
- $admin = auth()->user();
- $enrichment = new TransactionGroupEnrichment();
+ $admin = auth()->user();
+ $enrichment = new TransactionGroupEnrichment();
$enrichment->setUser($admin);
$transactions = $enrichment->enrich($paginator->getCollection());
/** @var TransactionGroupTransformer $transformer */
- $transformer = app(TransactionGroupTransformer::class);
+ $transformer = app(TransactionGroupTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($transactions, $transformer, 'transactions');
+ $resource = new FractalCollection($transactions, $transformer, 'transactions');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
diff --git a/app/Api/V1/Controllers/Models/Recurrence/UpdateController.php b/app/Api/V1/Controllers/Models/Recurrence/UpdateController.php
index 203230b19a..5274de011d 100644
--- a/app/Api/V1/Controllers/Models/Recurrence/UpdateController.php
+++ b/app/Api/V1/Controllers/Models/Recurrence/UpdateController.php
@@ -63,22 +63,22 @@ final class UpdateController extends Controller
*/
public function update(UpdateRequest $request, Recurrence $recurrence): JsonResponse
{
- $data = $request->getAll();
- $recurrence = $this->repository->update($recurrence, $data);
- $manager = $this->getManager();
+ $data = $request->getAll();
+ $recurrence = $this->repository->update($recurrence, $data);
+ $manager = $this->getManager();
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new RecurringEnrichment();
+ $admin = auth()->user();
+ $enrichment = new RecurringEnrichment();
$enrichment->setUser($admin);
- $recurrence = $enrichment->enrichSingle($recurrence);
+ $recurrence = $enrichment->enrichSingle($recurrence);
/** @var RecurrenceTransformer $transformer */
$transformer = app(RecurrenceTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($recurrence, $transformer, 'recurrences');
+ $resource = new Item($recurrence, $transformer, 'recurrences');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/Rule/DestroyController.php b/app/Api/V1/Controllers/Models/Rule/DestroyController.php
index a9fff279f9..87db86aad3 100644
--- a/app/Api/V1/Controllers/Models/Rule/DestroyController.php
+++ b/app/Api/V1/Controllers/Models/Rule/DestroyController.php
@@ -46,7 +46,7 @@ final class DestroyController extends Controller
parent::__construct();
$this->middleware(function ($request, $next) {
/** @var User $user */
- $user = auth()->user();
+ $user = auth()->user();
$this->ruleRepository = app(RuleRepositoryInterface::class);
$this->ruleRepository->setUser($user);
diff --git a/app/Api/V1/Controllers/Models/Rule/ShowController.php b/app/Api/V1/Controllers/Models/Rule/ShowController.php
index fc8d40737a..de61506c26 100644
--- a/app/Api/V1/Controllers/Models/Rule/ShowController.php
+++ b/app/Api/V1/Controllers/Models/Rule/ShowController.php
@@ -50,7 +50,7 @@ final class ShowController extends Controller
parent::__construct();
$this->middleware(function ($request, $next) {
/** @var User $user */
- $user = auth()->user();
+ $user = auth()->user();
$this->ruleRepository = app(RuleRepositoryInterface::class);
$this->ruleRepository->setUser($user);
@@ -67,25 +67,25 @@ final class ShowController extends Controller
*/
public function index(): JsonResponse
{
- $manager = $this->getManager();
+ $manager = $this->getManager();
// types to get, page size:
- $pageSize = $this->parameters->get('limit');
+ $pageSize = $this->parameters->get('limit');
// get list of budgets. Count it and split it.
- $collection = $this->ruleRepository->getAll();
- $count = $collection->count();
- $rules = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
+ $collection = $this->ruleRepository->getAll();
+ $count = $collection->count();
+ $rules = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
// make paginator:
- $paginator = new LengthAwarePaginator($rules, $count, $pageSize, $this->parameters->get('page'));
- $paginator->setPath(route('api.v1.rules.index').$this->buildParams());
+ $paginator = new LengthAwarePaginator($rules, $count, $pageSize, $this->parameters->get('page'));
+ $paginator->setPath(route('api.v1.rules.index') . $this->buildParams());
/** @var RuleTransformer $transformer */
$transformer = app(RuleTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($rules, $transformer, 'rules');
+ $resource = new FractalCollection($rules, $transformer, 'rules');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -99,13 +99,13 @@ final class ShowController extends Controller
*/
public function show(Rule $rule): JsonResponse
{
- $manager = $this->getManager();
+ $manager = $this->getManager();
/** @var RuleTransformer $transformer */
$transformer = app(RuleTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($rule, $transformer, 'rules');
+ $resource = new Item($rule, $transformer, 'rules');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/Rule/StoreController.php b/app/Api/V1/Controllers/Models/Rule/StoreController.php
index 10ea227aa4..e43d6159ca 100644
--- a/app/Api/V1/Controllers/Models/Rule/StoreController.php
+++ b/app/Api/V1/Controllers/Models/Rule/StoreController.php
@@ -47,7 +47,7 @@ final class StoreController extends Controller
parent::__construct();
$this->middleware(function ($request, $next) {
/** @var User $user */
- $user = auth()->user();
+ $user = auth()->user();
$this->ruleRepository = app(RuleRepositoryInterface::class);
$this->ruleRepository->setUser($user);
@@ -64,14 +64,14 @@ final class StoreController extends Controller
*/
public function store(StoreRequest $request): JsonResponse
{
- $rule = $this->ruleRepository->store($request->getAll());
- $manager = $this->getManager();
+ $rule = $this->ruleRepository->store($request->getAll());
+ $manager = $this->getManager();
/** @var RuleTransformer $transformer */
$transformer = app(RuleTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($rule, $transformer, 'rules');
+ $resource = new Item($rule, $transformer, 'rules');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/Rule/TriggerController.php b/app/Api/V1/Controllers/Models/Rule/TriggerController.php
index cc969326dc..89d5912db0 100644
--- a/app/Api/V1/Controllers/Models/Rule/TriggerController.php
+++ b/app/Api/V1/Controllers/Models/Rule/TriggerController.php
@@ -54,7 +54,7 @@ final class TriggerController extends Controller
parent::__construct();
$this->middleware(function ($request, $next) {
/** @var User $user */
- $user = auth()->user();
+ $user = auth()->user();
$this->ruleRepository = app(RuleRepositoryInterface::class);
$this->ruleRepository->setUser($user);
@@ -69,10 +69,10 @@ final class TriggerController extends Controller
*/
public function testRule(TestRequest $request, Rule $rule): JsonResponse
{
- $parameters = $request->getTestParameters();
+ $parameters = $request->getTestParameters();
/** @var RuleEngineInterface $ruleEngine */
- $ruleEngine = app(RuleEngineInterface::class);
+ $ruleEngine = app(RuleEngineInterface::class);
$ruleEngine->setRules(new Collection()->push($rule));
// overrule the rule(s) if necessary.
@@ -94,21 +94,21 @@ final class TriggerController extends Controller
$count = $transactions->count();
// enrich
- $enrichment = new TransactionGroupEnrichment();
+ $enrichment = new TransactionGroupEnrichment();
$enrichment->setUser($rule->user);
$transactions = $enrichment->enrich($transactions);
- $paginator = new LengthAwarePaginator($transactions, $count, 31_337, $this->parameters->get('page'));
- $paginator->setPath(route('api.v1.rules.test', [$rule->id]).$this->buildParams());
+ $paginator = new LengthAwarePaginator($transactions, $count, 31_337, $this->parameters->get('page'));
+ $paginator->setPath(route('api.v1.rules.test', [$rule->id]) . $this->buildParams());
// resulting list is presented as JSON thing.
- $manager = $this->getManager();
+ $manager = $this->getManager();
/** @var TransactionGroupTransformer $transformer */
- $transformer = app(TransactionGroupTransformer::class);
+ $transformer = app(TransactionGroupTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($transactions, $transformer, 'transactions');
+ $resource = new FractalCollection($transactions, $transformer, 'transactions');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
diff --git a/app/Api/V1/Controllers/Models/Rule/UpdateController.php b/app/Api/V1/Controllers/Models/Rule/UpdateController.php
index 1867208f41..def7fb59e8 100644
--- a/app/Api/V1/Controllers/Models/Rule/UpdateController.php
+++ b/app/Api/V1/Controllers/Models/Rule/UpdateController.php
@@ -48,7 +48,7 @@ final class UpdateController extends Controller
parent::__construct();
$this->middleware(function ($request, $next) {
/** @var User $user */
- $user = auth()->user();
+ $user = auth()->user();
$this->ruleRepository = app(RuleRepositoryInterface::class);
$this->ruleRepository->setUser($user);
@@ -65,15 +65,15 @@ final class UpdateController extends Controller
*/
public function update(UpdateRequest $request, Rule $rule): JsonResponse
{
- $data = $request->getAll();
- $rule = $this->ruleRepository->update($rule, $data);
- $manager = $this->getManager();
+ $data = $request->getAll();
+ $rule = $this->ruleRepository->update($rule, $data);
+ $manager = $this->getManager();
/** @var RuleTransformer $transformer */
$transformer = app(RuleTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($rule, $transformer, 'rules');
+ $resource = new Item($rule, $transformer, 'rules');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/RuleGroup/DestroyController.php b/app/Api/V1/Controllers/Models/RuleGroup/DestroyController.php
index 15a4585317..c7db0cdabe 100644
--- a/app/Api/V1/Controllers/Models/RuleGroup/DestroyController.php
+++ b/app/Api/V1/Controllers/Models/RuleGroup/DestroyController.php
@@ -46,7 +46,7 @@ final class DestroyController extends Controller
parent::__construct();
$this->middleware(function ($request, $next) {
/** @var User $user */
- $user = auth()->user();
+ $user = auth()->user();
$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);
$this->ruleGroupRepository->setUser($user);
diff --git a/app/Api/V1/Controllers/Models/RuleGroup/ListController.php b/app/Api/V1/Controllers/Models/RuleGroup/ListController.php
index 96ae8521cb..0318bce43b 100644
--- a/app/Api/V1/Controllers/Models/RuleGroup/ListController.php
+++ b/app/Api/V1/Controllers/Models/RuleGroup/ListController.php
@@ -49,7 +49,7 @@ final class ListController extends Controller
parent::__construct();
$this->middleware(function ($request, $next) {
/** @var User $user */
- $user = auth()->user();
+ $user = auth()->user();
$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);
$this->ruleGroupRepository->setUser($user);
@@ -64,24 +64,24 @@ final class ListController extends Controller
*/
public function rules(RuleGroup $group): JsonResponse
{
- $manager = $this->getManager();
+ $manager = $this->getManager();
// types to get, page size:
- $pageSize = $this->parameters->get('limit');
+ $pageSize = $this->parameters->get('limit');
// get list of budgets. Count it and split it.
- $collection = $this->ruleGroupRepository->getRules($group);
- $count = $collection->count();
- $rules = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
+ $collection = $this->ruleGroupRepository->getRules($group);
+ $count = $collection->count();
+ $rules = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
// make paginator:
- $paginator = new LengthAwarePaginator($rules, $count, $pageSize, $this->parameters->get('page'));
- $paginator->setPath(route('api.v1.rule-groups.rules', [$group->id]).$this->buildParams());
+ $paginator = new LengthAwarePaginator($rules, $count, $pageSize, $this->parameters->get('page'));
+ $paginator->setPath(route('api.v1.rule-groups.rules', [$group->id]) . $this->buildParams());
/** @var RuleTransformer $transformer */
$transformer = app(RuleTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($rules, $transformer, 'rules');
+ $resource = new FractalCollection($rules, $transformer, 'rules');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
diff --git a/app/Api/V1/Controllers/Models/RuleGroup/ShowController.php b/app/Api/V1/Controllers/Models/RuleGroup/ShowController.php
index cd842f7636..ea6d1277c6 100644
--- a/app/Api/V1/Controllers/Models/RuleGroup/ShowController.php
+++ b/app/Api/V1/Controllers/Models/RuleGroup/ShowController.php
@@ -50,7 +50,7 @@ final class ShowController extends Controller
parent::__construct();
$this->middleware(function ($request, $next) {
/** @var User $user */
- $user = auth()->user();
+ $user = auth()->user();
$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);
$this->ruleGroupRepository->setUser($user);
@@ -66,24 +66,24 @@ final class ShowController extends Controller
*/
public function index(): JsonResponse
{
- $manager = $this->getManager();
+ $manager = $this->getManager();
// types to get, page size:
- $pageSize = $this->parameters->get('limit');
+ $pageSize = $this->parameters->get('limit');
// get list of rule groups. Count it and split it.
- $collection = $this->ruleGroupRepository->get();
- $count = $collection->count();
- $ruleGroups = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
+ $collection = $this->ruleGroupRepository->get();
+ $count = $collection->count();
+ $ruleGroups = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
// make paginator:
- $paginator = new LengthAwarePaginator($ruleGroups, $count, $pageSize, $this->parameters->get('page'));
- $paginator->setPath(route('api.v1.rule-groups.index').$this->buildParams());
+ $paginator = new LengthAwarePaginator($ruleGroups, $count, $pageSize, $this->parameters->get('page'));
+ $paginator->setPath(route('api.v1.rule-groups.index') . $this->buildParams());
/** @var RuleGroupTransformer $transformer */
$transformer = app(RuleGroupTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($ruleGroups, $transformer, 'rule_groups');
+ $resource = new FractalCollection($ruleGroups, $transformer, 'rule_groups');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -97,13 +97,13 @@ final class ShowController extends Controller
*/
public function show(RuleGroup $ruleGroup): JsonResponse
{
- $manager = $this->getManager();
+ $manager = $this->getManager();
/** @var RuleGroupTransformer $transformer */
$transformer = app(RuleGroupTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($ruleGroup, $transformer, 'rule_groups');
+ $resource = new Item($ruleGroup, $transformer, 'rule_groups');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/RuleGroup/StoreController.php b/app/Api/V1/Controllers/Models/RuleGroup/StoreController.php
index 2fdd88323e..9fc51a1b88 100644
--- a/app/Api/V1/Controllers/Models/RuleGroup/StoreController.php
+++ b/app/Api/V1/Controllers/Models/RuleGroup/StoreController.php
@@ -38,7 +38,7 @@ use League\Fractal\Resource\Item;
*/
final class StoreController extends Controller
{
- private AccountRepositoryInterface $accountRepository;
+ private AccountRepositoryInterface $accountRepository;
private RuleGroupRepositoryInterface $ruleGroupRepository;
/**
@@ -49,12 +49,12 @@ final class StoreController extends Controller
parent::__construct();
$this->middleware(function ($request, $next) {
/** @var User $user */
- $user = auth()->user();
+ $user = auth()->user();
$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);
$this->ruleGroupRepository->setUser($user);
- $this->accountRepository = app(AccountRepositoryInterface::class);
+ $this->accountRepository = app(AccountRepositoryInterface::class);
$this->accountRepository->setUser($user);
return $next($request);
@@ -69,14 +69,14 @@ final class StoreController extends Controller
*/
public function store(StoreRequest $request): JsonResponse
{
- $ruleGroup = $this->ruleGroupRepository->store($request->getAll());
- $manager = $this->getManager();
+ $ruleGroup = $this->ruleGroupRepository->store($request->getAll());
+ $manager = $this->getManager();
/** @var RuleGroupTransformer $transformer */
$transformer = app(RuleGroupTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($ruleGroup, $transformer, 'rule_groups');
+ $resource = new Item($ruleGroup, $transformer, 'rule_groups');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/RuleGroup/TriggerController.php b/app/Api/V1/Controllers/Models/RuleGroup/TriggerController.php
index 3e1888723f..23fd987f73 100644
--- a/app/Api/V1/Controllers/Models/RuleGroup/TriggerController.php
+++ b/app/Api/V1/Controllers/Models/RuleGroup/TriggerController.php
@@ -55,7 +55,7 @@ final class TriggerController extends Controller
parent::__construct();
$this->middleware(function ($request, $next) {
/** @var User $user */
- $user = auth()->user();
+ $user = auth()->user();
$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);
$this->ruleGroupRepository->setUser($user);
@@ -72,14 +72,14 @@ final class TriggerController extends Controller
*/
public function testGroup(TestRequest $request, RuleGroup $group): JsonResponse
{
- $rules = $this->ruleGroupRepository->getActiveRules($group);
+ $rules = $this->ruleGroupRepository->getActiveRules($group);
if (0 === $rules->count()) {
throw new FireflyException('200023: No rules in this rule group.');
}
- $parameters = $request->getTestParameters();
+ $parameters = $request->getTestParameters();
/** @var RuleEngineInterface $ruleEngine */
- $ruleEngine = app(RuleEngineInterface::class);
+ $ruleEngine = app(RuleEngineInterface::class);
$ruleEngine->setRules($rules);
// overrule the rule(s) if necessary.
@@ -101,21 +101,21 @@ final class TriggerController extends Controller
$count = $transactions->count();
// enrich
- $enrichment = new TransactionGroupEnrichment();
+ $enrichment = new TransactionGroupEnrichment();
$enrichment->setUser($group->user);
$transactions = $enrichment->enrich($transactions);
- $paginator = new LengthAwarePaginator($transactions, $count, 31_337, $this->parameters->get('page'));
- $paginator->setPath(route('api.v1.rule-groups.test', [$group->id]).$this->buildParams());
+ $paginator = new LengthAwarePaginator($transactions, $count, 31_337, $this->parameters->get('page'));
+ $paginator->setPath(route('api.v1.rule-groups.test', [$group->id]) . $this->buildParams());
// resulting list is presented as JSON thing.
- $manager = $this->getManager();
+ $manager = $this->getManager();
/** @var TransactionGroupTransformer $transformer */
- $transformer = app(TransactionGroupTransformer::class);
+ $transformer = app(TransactionGroupTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($transactions, $transformer, 'transactions');
+ $resource = new FractalCollection($transactions, $transformer, 'transactions');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -131,7 +131,7 @@ final class TriggerController extends Controller
*/
public function triggerGroup(TriggerRequest $request, RuleGroup $group): JsonResponse
{
- $rules = $this->ruleGroupRepository->getActiveRules($group);
+ $rules = $this->ruleGroupRepository->getActiveRules($group);
if (0 === $rules->count()) {
throw new FireflyException('200023: No rules in this rule group.');
}
diff --git a/app/Api/V1/Controllers/Models/RuleGroup/UpdateController.php b/app/Api/V1/Controllers/Models/RuleGroup/UpdateController.php
index 14291cf4d3..aa45ac3e35 100644
--- a/app/Api/V1/Controllers/Models/RuleGroup/UpdateController.php
+++ b/app/Api/V1/Controllers/Models/RuleGroup/UpdateController.php
@@ -48,7 +48,7 @@ final class UpdateController extends Controller
parent::__construct();
$this->middleware(function ($request, $next) {
/** @var User $user */
- $user = auth()->user();
+ $user = auth()->user();
$this->ruleGroupRepository = app(RuleGroupRepositoryInterface::class);
$this->ruleGroupRepository->setUser($user);
@@ -65,14 +65,14 @@ final class UpdateController extends Controller
*/
public function update(UpdateRequest $request, RuleGroup $ruleGroup): JsonResponse
{
- $ruleGroup = $this->ruleGroupRepository->update($ruleGroup, $request->getAll());
- $manager = $this->getManager();
+ $ruleGroup = $this->ruleGroupRepository->update($ruleGroup, $request->getAll());
+ $manager = $this->getManager();
/** @var RuleGroupTransformer $transformer */
$transformer = app(RuleGroupTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($ruleGroup, $transformer, 'rule_groups');
+ $resource = new Item($ruleGroup, $transformer, 'rule_groups');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/Tag/DestroyController.php b/app/Api/V1/Controllers/Models/Tag/DestroyController.php
index b1b09a77d0..5ca1e2475a 100644
--- a/app/Api/V1/Controllers/Models/Tag/DestroyController.php
+++ b/app/Api/V1/Controllers/Models/Tag/DestroyController.php
@@ -46,7 +46,7 @@ final class DestroyController extends Controller
parent::__construct();
$this->middleware(function ($request, $next) {
/** @var User $user */
- $user = auth()->user();
+ $user = auth()->user();
$this->repository = app(TagRepositoryInterface::class);
$this->repository->setUser($user);
diff --git a/app/Api/V1/Controllers/Models/Tag/ListController.php b/app/Api/V1/Controllers/Models/Tag/ListController.php
index fb3b8c98df..06b403e863 100644
--- a/app/Api/V1/Controllers/Models/Tag/ListController.php
+++ b/app/Api/V1/Controllers/Models/Tag/ListController.php
@@ -56,7 +56,7 @@ final class ListController extends Controller
parent::__construct();
$this->middleware(function ($request, $next) {
/** @var User $user */
- $user = auth()->user();
+ $user = auth()->user();
$this->repository = app(TagRepositoryInterface::class);
$this->repository->setUser($user);
@@ -71,22 +71,22 @@ final class ListController extends Controller
*/
public function attachments(Tag $tag): JsonResponse
{
- $manager = $this->getManager();
- $pageSize = $this->parameters->get('limit');
- $collection = $this->repository->getAttachments($tag);
+ $manager = $this->getManager();
+ $pageSize = $this->parameters->get('limit');
+ $collection = $this->repository->getAttachments($tag);
$count = $collection->count();
$attachments = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
// make paginator:
- $paginator = new LengthAwarePaginator($attachments, $count, $pageSize, $this->parameters->get('page'));
- $paginator->setPath(route('api.v1.tags.attachments', [$tag->id]).$this->buildParams());
+ $paginator = new LengthAwarePaginator($attachments, $count, $pageSize, $this->parameters->get('page'));
+ $paginator->setPath(route('api.v1.tags.attachments', [$tag->id]) . $this->buildParams());
/** @var AttachmentTransformer $transformer */
$transformer = app(AttachmentTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($attachments, $transformer, 'attachments');
+ $resource = new FractalCollection($attachments, $transformer, 'attachments');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -100,19 +100,19 @@ final class ListController extends Controller
*/
public function transactions(Request $request, Tag $tag): JsonResponse
{
- $pageSize = $this->parameters->get('limit');
- $type = $request->input('type') ?? 'default';
+ $pageSize = $this->parameters->get('limit');
+ $type = $request->input('type') ?? 'default';
$this->parameters->set('type', $type);
- $types = $this->mapTransactionTypes($this->parameters->get('type'));
- $manager = $this->getManager();
+ $types = $this->mapTransactionTypes($this->parameters->get('type'));
+ $manager = $this->getManager();
/** @var User $admin */
- $admin = auth()->user();
+ $admin = auth()->user();
// use new group collector:
/** @var GroupCollectorInterface $collector */
- $collector = app(GroupCollectorInterface::class);
+ $collector = app(GroupCollectorInterface::class);
$collector
->setUser($admin)
// filter on tag.
@@ -124,8 +124,7 @@ final class ListController extends Controller
// set page to retrieve
->setPage($this->parameters->get('page'))
// set types of transactions to return.
- ->setTypes($types)
- ;
+ ->setTypes($types);
if (null !== $this->parameters->get('start')) {
$collector->setStart($this->parameters->get('start'));
@@ -133,19 +132,19 @@ final class ListController extends Controller
if (null !== $this->parameters->get('end')) {
$collector->setEnd($this->parameters->get('end'));
}
- $paginator = $collector->getPaginatedGroups();
- $paginator->setPath(route('api.v1.tags.transactions', [$tag->id]).$this->buildParams());
+ $paginator = $collector->getPaginatedGroups();
+ $paginator->setPath(route('api.v1.tags.transactions', [$tag->id]) . $this->buildParams());
// enrich
- $enrichment = new TransactionGroupEnrichment();
+ $enrichment = new TransactionGroupEnrichment();
$enrichment->setUser($admin);
$transactions = $enrichment->enrich($paginator->getCollection());
/** @var TransactionGroupTransformer $transformer */
- $transformer = app(TransactionGroupTransformer::class);
+ $transformer = app(TransactionGroupTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($transactions, $transformer, 'transactions');
+ $resource = new FractalCollection($transactions, $transformer, 'transactions');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
diff --git a/app/Api/V1/Controllers/Models/Tag/ShowController.php b/app/Api/V1/Controllers/Models/Tag/ShowController.php
index be923830f6..b8c323b075 100644
--- a/app/Api/V1/Controllers/Models/Tag/ShowController.php
+++ b/app/Api/V1/Controllers/Models/Tag/ShowController.php
@@ -50,7 +50,7 @@ final class ShowController extends Controller
parent::__construct();
$this->middleware(function ($request, $next) {
/** @var User $user */
- $user = auth()->user();
+ $user = auth()->user();
$this->repository = app(TagRepositoryInterface::class);
$this->repository->setUser($user);
@@ -67,24 +67,24 @@ final class ShowController extends Controller
*/
public function index(): JsonResponse
{
- $manager = $this->getManager();
+ $manager = $this->getManager();
// types to get, page size:
- $pageSize = $this->parameters->get('limit');
+ $pageSize = $this->parameters->get('limit');
// get list of budgets. Count it and split it.
- $collection = $this->repository->get();
- $count = $collection->count();
- $rules = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
+ $collection = $this->repository->get();
+ $count = $collection->count();
+ $rules = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
// make paginator:
- $paginator = new LengthAwarePaginator($rules, $count, $pageSize, $this->parameters->get('page'));
- $paginator->setPath(route('api.v1.tags.index').$this->buildParams());
+ $paginator = new LengthAwarePaginator($rules, $count, $pageSize, $this->parameters->get('page'));
+ $paginator->setPath(route('api.v1.tags.index') . $this->buildParams());
/** @var TagTransformer $transformer */
$transformer = app(TagTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($rules, $transformer, 'tags');
+ $resource = new FractalCollection($rules, $transformer, 'tags');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -98,13 +98,13 @@ final class ShowController extends Controller
*/
public function show(Tag $tag): JsonResponse
{
- $manager = $this->getManager();
+ $manager = $this->getManager();
/** @var TagTransformer $transformer */
$transformer = app(TagTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($tag, $transformer, 'tags');
+ $resource = new Item($tag, $transformer, 'tags');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/Tag/StoreController.php b/app/Api/V1/Controllers/Models/Tag/StoreController.php
index 2be32d3362..b3e87683aa 100644
--- a/app/Api/V1/Controllers/Models/Tag/StoreController.php
+++ b/app/Api/V1/Controllers/Models/Tag/StoreController.php
@@ -47,7 +47,7 @@ final class StoreController extends Controller
parent::__construct();
$this->middleware(function ($request, $next) {
/** @var User $user */
- $user = auth()->user();
+ $user = auth()->user();
$this->repository = app(TagRepositoryInterface::class);
$this->repository->setUser($user);
@@ -64,14 +64,14 @@ final class StoreController extends Controller
*/
public function store(StoreRequest $request): JsonResponse
{
- $rule = $this->repository->store($request->getAll());
- $manager = $this->getManager();
+ $rule = $this->repository->store($request->getAll());
+ $manager = $this->getManager();
/** @var TagTransformer $transformer */
$transformer = app(TagTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($rule, $transformer, 'tags');
+ $resource = new Item($rule, $transformer, 'tags');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/Tag/UpdateController.php b/app/Api/V1/Controllers/Models/Tag/UpdateController.php
index 2bb2a16338..f9d381c4bb 100644
--- a/app/Api/V1/Controllers/Models/Tag/UpdateController.php
+++ b/app/Api/V1/Controllers/Models/Tag/UpdateController.php
@@ -48,7 +48,7 @@ final class UpdateController extends Controller
parent::__construct();
$this->middleware(function ($request, $next) {
/** @var User $user */
- $user = auth()->user();
+ $user = auth()->user();
$this->repository = app(TagRepositoryInterface::class);
$this->repository->setUser($user);
@@ -65,14 +65,14 @@ final class UpdateController extends Controller
*/
public function update(UpdateRequest $request, Tag $tag): JsonResponse
{
- $rule = $this->repository->update($tag, $request->getAll());
- $manager = $this->getManager();
+ $rule = $this->repository->update($tag, $request->getAll());
+ $manager = $this->getManager();
/** @var TagTransformer $transformer */
$transformer = app(TagTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($rule, $transformer, 'tags');
+ $resource = new Item($rule, $transformer, 'tags');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/Transaction/DestroyController.php b/app/Api/V1/Controllers/Models/Transaction/DestroyController.php
index 76eac21f5d..a014070e55 100644
--- a/app/Api/V1/Controllers/Models/Transaction/DestroyController.php
+++ b/app/Api/V1/Controllers/Models/Transaction/DestroyController.php
@@ -50,9 +50,9 @@ final class DestroyController extends Controller
parent::__construct();
$this->middleware(function ($request, $next) {
/** @var User $admin */
- $admin = auth()->user();
+ $admin = auth()->user();
- $this->repository = app(JournalRepositoryInterface::class);
+ $this->repository = app(JournalRepositoryInterface::class);
$this->repository->setUser($admin);
$this->groupRepository = app(TransactionGroupRepository::class);
diff --git a/app/Api/V1/Controllers/Models/Transaction/ListController.php b/app/Api/V1/Controllers/Models/Transaction/ListController.php
index 284ffc4c23..40574da140 100644
--- a/app/Api/V1/Controllers/Models/Transaction/ListController.php
+++ b/app/Api/V1/Controllers/Models/Transaction/ListController.php
@@ -54,7 +54,7 @@ final class ListController extends Controller
parent::__construct();
$this->middleware(function ($request, $next) {
/** @var User $admin */
- $admin = auth()->user();
+ $admin = auth()->user();
$this->journalAPIRepository = app(JournalAPIRepositoryInterface::class);
$this->journalAPIRepository->setUser($admin);
@@ -69,9 +69,9 @@ final class ListController extends Controller
*/
public function attachments(TransactionGroup $transactionGroup): JsonResponse
{
- $manager = $this->getManager();
- $pageSize = $this->parameters->get('limit');
- $collection = new Collection();
+ $manager = $this->getManager();
+ $pageSize = $this->parameters->get('limit');
+ $collection = new Collection();
foreach ($transactionGroup->transactionJournals as $transactionJournal) {
$collection = $this->journalAPIRepository->getAttachments($transactionJournal)->merge($collection);
}
@@ -80,14 +80,14 @@ final class ListController extends Controller
$attachments = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
// make paginator:
- $paginator = new LengthAwarePaginator($attachments, $count, $pageSize, $this->parameters->get('page'));
- $paginator->setPath(route('api.v1.transactions.attachments', [$transactionGroup->id]).$this->buildParams());
+ $paginator = new LengthAwarePaginator($attachments, $count, $pageSize, $this->parameters->get('page'));
+ $paginator->setPath(route('api.v1.transactions.attachments', [$transactionGroup->id]) . $this->buildParams());
/** @var AttachmentTransformer $transformer */
$transformer = app(AttachmentTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($attachments, $transformer, 'attachments');
+ $resource = new FractalCollection($attachments, $transformer, 'attachments');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -99,31 +99,31 @@ final class ListController extends Controller
*/
public function piggyBankEvents(TransactionGroup $transactionGroup): JsonResponse
{
- $manager = $this->getManager();
- $collection = new Collection();
- $pageSize = $this->parameters->get('limit');
+ $manager = $this->getManager();
+ $collection = new Collection();
+ $pageSize = $this->parameters->get('limit');
foreach ($transactionGroup->transactionJournals as $transactionJournal) {
$collection = $this->journalAPIRepository->getPiggyBankEvents($transactionJournal)->merge($collection);
}
- $count = $collection->count();
- $events = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
+ $count = $collection->count();
+ $events = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new PiggyBankEventEnrichment();
+ $admin = auth()->user();
+ $enrichment = new PiggyBankEventEnrichment();
$enrichment->setUser($admin);
- $events = $enrichment->enrich($events);
+ $events = $enrichment->enrich($events);
// make paginator:
- $paginator = new LengthAwarePaginator($events, $count, $pageSize, $this->parameters->get('page'));
- $paginator->setPath(route('api.v1.transactions.piggy-bank-events', [$transactionGroup->id]).$this->buildParams());
+ $paginator = new LengthAwarePaginator($events, $count, $pageSize, $this->parameters->get('page'));
+ $paginator->setPath(route('api.v1.transactions.piggy-bank-events', [$transactionGroup->id]) . $this->buildParams());
/** @var PiggyBankEventTransformer $transformer */
$transformer = app(PiggyBankEventTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($events, $transformer, 'piggy_bank_events');
+ $resource = new FractalCollection($events, $transformer, 'piggy_bank_events');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
// /** @var PiggyBankEventTransformer $transformer */
// $transformer = app(PiggyBankEventTransformer::class);
@@ -147,14 +147,14 @@ final class ListController extends Controller
$journalLinks = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
// make paginator:
- $paginator = new LengthAwarePaginator($journalLinks, $count, $pageSize, $this->parameters->get('page'));
- $paginator->setPath(route('api.v1.transaction-journals.transaction-links', [$transactionJournal->id]).$this->buildParams());
+ $paginator = new LengthAwarePaginator($journalLinks, $count, $pageSize, $this->parameters->get('page'));
+ $paginator->setPath(route('api.v1.transaction-journals.transaction-links', [$transactionJournal->id]) . $this->buildParams());
/** @var TransactionLinkTransformer $transformer */
- $transformer = app(TransactionLinkTransformer::class);
+ $transformer = app(TransactionLinkTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($journalLinks, $transformer, 'transaction_links');
+ $resource = new FractalCollection($journalLinks, $transformer, 'transaction_links');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
diff --git a/app/Api/V1/Controllers/Models/Transaction/ShowController.php b/app/Api/V1/Controllers/Models/Transaction/ShowController.php
index cd96be0605..ca522a69f7 100644
--- a/app/Api/V1/Controllers/Models/Transaction/ShowController.php
+++ b/app/Api/V1/Controllers/Models/Transaction/ShowController.php
@@ -54,19 +54,19 @@ final class ShowController extends Controller
*/
public function index(Request $request): JsonResponse
{
- $pageSize = $this->parameters->get('limit');
- $type = $request->input('type') ?? 'default';
+ $pageSize = $this->parameters->get('limit');
+ $type = $request->input('type') ?? 'default';
$this->parameters->set('type', $type);
- $types = $this->mapTransactionTypes($this->parameters->get('type'));
- $manager = $this->getManager();
+ $types = $this->mapTransactionTypes($this->parameters->get('type'));
+ $manager = $this->getManager();
/** @var User $admin */
- $admin = auth()->user();
+ $admin = auth()->user();
// use new group collector:
/** @var GroupCollectorInterface $collector */
- $collector = app(GroupCollectorInterface::class);
+ $collector = app(GroupCollectorInterface::class);
$collector
->setUser($admin)
// all info needed for the API:
@@ -76,24 +76,23 @@ final class ShowController extends Controller
// set page to retrieve
->setPage($this->parameters->get('page'))
// set types of transactions to return.
- ->setTypes($types)
- ;
+ ->setTypes($types);
if (null !== $this->parameters->get('start') || null !== $this->parameters->get('end')) {
$collector->setRange($this->parameters->get('start'), $this->parameters->get('end'));
}
- $paginator = $collector->getPaginatedGroups();
- $paginator->setPath(route('api.v1.transactions.index').$this->buildParams());
+ $paginator = $collector->getPaginatedGroups();
+ $paginator->setPath(route('api.v1.transactions.index') . $this->buildParams());
// enrich
- $enrichment = new TransactionGroupEnrichment();
+ $enrichment = new TransactionGroupEnrichment();
$enrichment->setUser($admin);
$transactions = $enrichment->enrich($paginator->getCollection());
/** @var TransactionGroupTransformer $transformer */
- $transformer = app(TransactionGroupTransformer::class);
+ $transformer = app(TransactionGroupTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($transactions, $transformer, 'transactions');
+ $resource = new FractalCollection($transactions, $transformer, 'transactions');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -107,21 +106,20 @@ final class ShowController extends Controller
*/
public function show(TransactionGroup $transactionGroup): JsonResponse
{
- $manager = $this->getManager();
+ $manager = $this->getManager();
/** @var User $admin */
- $admin = auth()->user();
+ $admin = auth()->user();
// use new group collector:
/** @var GroupCollectorInterface $collector */
- $collector = app(GroupCollectorInterface::class);
+ $collector = app(GroupCollectorInterface::class);
$collector
->setUser($admin)
// filter on transaction group.
->setTransactionGroup($transactionGroup)
// all info needed for the API:
- ->withAPIInformation()
- ;
+ ->withAPIInformation();
$selectedGroup = $collector->getGroups()->first();
if (null === $selectedGroup) {
@@ -129,14 +127,14 @@ final class ShowController extends Controller
}
// enrich
- $enrichment = new TransactionGroupEnrichment();
+ $enrichment = new TransactionGroupEnrichment();
$enrichment->setUser($admin);
$selectedGroup = $enrichment->enrichSingle($selectedGroup);
/** @var TransactionGroupTransformer $transformer */
- $transformer = app(TransactionGroupTransformer::class);
+ $transformer = app(TransactionGroupTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($selectedGroup, $transformer, 'transactions');
+ $resource = new Item($selectedGroup, $transformer, 'transactions');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/Transaction/StoreController.php b/app/Api/V1/Controllers/Models/Transaction/StoreController.php
index e21ae4cf32..a845525999 100644
--- a/app/Api/V1/Controllers/Models/Transaction/StoreController.php
+++ b/app/Api/V1/Controllers/Models/Transaction/StoreController.php
@@ -54,7 +54,7 @@ final class StoreController extends Controller
use TransactionFilter;
#[Override]
- protected array $acceptedRoles = [UserRoleEnum::MANAGE_TRANSACTIONS];
+ protected array $acceptedRoles = [UserRoleEnum::MANAGE_TRANSACTIONS];
private TransactionGroupRepositoryInterface $groupRepository;
/**
@@ -65,8 +65,8 @@ final class StoreController extends Controller
parent::__construct();
$this->middleware(function (Request $request, $next) {
/** @var User $admin */
- $admin = auth()->user();
- $userGroup = $this->validateUserGroup($request);
+ $admin = auth()->user();
+ $userGroup = $this->validateUserGroup($request);
$this->groupRepository = app(TransactionGroupRepositoryInterface::class);
$this->groupRepository->setUser($admin);
@@ -111,37 +111,36 @@ final class StoreController extends Controller
throw new ValidationException($validator);
}
- $manager = $this->getManager();
+ $manager = $this->getManager();
/** @var User $admin */
- $admin = auth()->user();
+ $admin = auth()->user();
// use new group collector:
/** @var GroupCollectorInterface $collector */
- $collector = app(GroupCollectorInterface::class);
+ $collector = app(GroupCollectorInterface::class);
$collector
->setUser($admin)
->setUserGroup($this->userGroup)
// filter on transaction group.
->setTransactionGroup($transactionGroup)
// all info needed for the API:
- ->withAPIInformation()
- ;
+ ->withAPIInformation();
- $selectedGroup = $collector->getGroups()->first();
+ $selectedGroup = $collector->getGroups()->first();
if (null === $selectedGroup) {
throw HttpException::fromStatusCode(410, '200032: Cannot find transaction. Possibly, a rule deleted this transaction after its creation.');
}
// enrich
- $enrichment = new TransactionGroupEnrichment();
+ $enrichment = new TransactionGroupEnrichment();
$enrichment->setUser($admin);
- $selectedGroup = $enrichment->enrichSingle($selectedGroup);
+ $selectedGroup = $enrichment->enrichSingle($selectedGroup);
/** @var TransactionGroupTransformer $transformer */
- $transformer = app(TransactionGroupTransformer::class);
+ $transformer = app(TransactionGroupTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($selectedGroup, $transformer, 'transactions');
+ $resource = new Item($selectedGroup, $transformer, 'transactions');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/Transaction/UpdateController.php b/app/Api/V1/Controllers/Models/Transaction/UpdateController.php
index 5d48aa93ab..b2f2cd16ab 100644
--- a/app/Api/V1/Controllers/Models/Transaction/UpdateController.php
+++ b/app/Api/V1/Controllers/Models/Transaction/UpdateController.php
@@ -48,9 +48,9 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
*/
final class UpdateController extends Controller
{
- private TransactionGroupRepositoryInterface $groupRepository;
#[Override]
- protected array $acceptedRoles = [];
+ protected array $acceptedRoles = [];
+ private TransactionGroupRepositoryInterface $groupRepository;
/**
* TransactionController constructor.
@@ -60,7 +60,7 @@ final class UpdateController extends Controller
parent::__construct();
$this->middleware(function ($request, $next) {
/** @var User $admin */
- $admin = auth()->user();
+ $admin = auth()->user();
$this->groupRepository = app(TransactionGroupRepositoryInterface::class);
$this->groupRepository->setUser($admin);
@@ -77,19 +77,19 @@ final class UpdateController extends Controller
*/
public function update(UpdateRequest $request, TransactionGroup $transactionGroup): JsonResponse
{
- $data = $request->getAll();
+ $data = $request->getAll();
Log::debug('Now in update routine for transaction group', $data);
- $oldHash = $this->groupRepository->getCompareHash($transactionGroup);
- $objects = TransactionGroupEventObjects::collectFromTransactionGroup($transactionGroup);
- $transactionGroup = $this->groupRepository->update($transactionGroup, $data);
+ $oldHash = $this->groupRepository->getCompareHash($transactionGroup);
+ $objects = TransactionGroupEventObjects::collectFromTransactionGroup($transactionGroup);
+ $transactionGroup = $this->groupRepository->update($transactionGroup, $data);
$objects->appendFromTransactionGroup($transactionGroup);
- $newHash = $this->groupRepository->getCompareHash($transactionGroup);
- $manager = $this->getManager();
+ $newHash = $this->groupRepository->getCompareHash($transactionGroup);
+ $manager = $this->getManager();
Preferences::mark();
- $applyRules = $data['apply_rules'] ?? true;
- $fireWebhooks = $data['fire_webhooks'] ?? true;
- $runRecalculations = $oldHash !== $newHash;
+ $applyRules = $data['apply_rules'] ?? true;
+ $fireWebhooks = $data['fire_webhooks'] ?? true;
+ $runRecalculations = $oldHash !== $newHash;
$flags = new TransactionGroupEventFlags();
$flags->applyRules = $applyRules;
@@ -100,32 +100,31 @@ final class UpdateController extends Controller
event(new WebhookMessagesRequestSending());
/** @var User $admin */
- $admin = auth()->user();
+ $admin = auth()->user();
// use new group collector:
/** @var GroupCollectorInterface $collector */
- $collector = app(GroupCollectorInterface::class);
+ $collector = app(GroupCollectorInterface::class);
$collector
->setUser($admin)
// filter on transaction group.
->setTransactionGroup($transactionGroup)
// all info needed for the API:
- ->withAPIInformation()
- ;
+ ->withAPIInformation();
- $selectedGroup = $collector->getGroups()->first();
+ $selectedGroup = $collector->getGroups()->first();
if (null === $selectedGroup) {
throw new NotFoundHttpException();
}
// enrich
- $enrichment = new TransactionGroupEnrichment();
+ $enrichment = new TransactionGroupEnrichment();
$enrichment->setUser($admin);
- $selectedGroup = $enrichment->enrichSingle($selectedGroup);
+ $selectedGroup = $enrichment->enrichSingle($selectedGroup);
/** @var TransactionGroupTransformer $transformer */
- $transformer = app(TransactionGroupTransformer::class);
- $resource = new Item($selectedGroup, $transformer, 'transactions');
+ $transformer = app(TransactionGroupTransformer::class);
+ $resource = new Item($selectedGroup, $transformer, 'transactions');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/TransactionCurrency/ListController.php b/app/Api/V1/Controllers/Models/TransactionCurrency/ListController.php
index 9c8de461d2..019ed473ab 100644
--- a/app/Api/V1/Controllers/Models/TransactionCurrency/ListController.php
+++ b/app/Api/V1/Controllers/Models/TransactionCurrency/ListController.php
@@ -73,15 +73,15 @@ final class ListController extends Controller
*/
public function accounts(Request $request, TransactionCurrency $currency): JsonResponse
{
- $manager = $this->getManager();
+ $manager = $this->getManager();
// read type from URL
- $type = $request->input('type') ?? 'all';
+ $type = $request->input('type') ?? 'all';
$this->parameters->set('type', $type);
// types to get, page size:
- $types = $this->mapAccountTypes($this->parameters->get('type'));
- $pageSize = $this->parameters->get('limit');
+ $types = $this->mapAccountTypes($this->parameters->get('type'));
+ $pageSize = $this->parameters->get('limit');
// get list of accounts. Count it and split it.
/** @var AccountRepositoryInterface $accountRepository */
@@ -89,14 +89,14 @@ final class ListController extends Controller
$unfiltered = $accountRepository->getAccountsByType($types);
// filter list on currency preference:
- $collection = $unfiltered->filter(static function (Account $account) use ($currency, $accountRepository): bool {
- $currencyId = (int) $accountRepository->getMetaValue($account, 'currency_id');
+ $collection = $unfiltered->filter(static function (Account $account) use ($currency, $accountRepository): bool {
+ $currencyId = (int)$accountRepository->getMetaValue($account, 'currency_id');
return $currencyId === $currency->id;
});
- $count = $collection->count();
- $accounts = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
+ $count = $collection->count();
+ $accounts = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
// #11007 go to the end of the previous day.
$this->parameters->set('start', $this->parameters->get('start')?->subSecond());
@@ -105,22 +105,22 @@ final class ListController extends Controller
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new AccountEnrichment();
+ $admin = auth()->user();
+ $enrichment = new AccountEnrichment();
$enrichment->setDate($this->parameters->get('date'));
$enrichment->setStart($this->parameters->get('start'));
$enrichment->setEnd($this->parameters->get('end'));
$enrichment->setUser($admin);
- $accounts = $enrichment->enrich($accounts);
+ $accounts = $enrichment->enrich($accounts);
// make paginator:
- $paginator = new LengthAwarePaginator($accounts, $count, $pageSize, $this->parameters->get('page'));
- $paginator->setPath(route('api.v1.currencies.accounts', [$currency->code]).$this->buildParams());
+ $paginator = new LengthAwarePaginator($accounts, $count, $pageSize, $this->parameters->get('page'));
+ $paginator->setPath(route('api.v1.currencies.accounts', [$currency->code]) . $this->buildParams());
/** @var AccountTransformer $transformer */
- $transformer = app(AccountTransformer::class);
+ $transformer = app(AccountTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($accounts, $transformer, 'accounts');
+ $resource = new FractalCollection($accounts, $transformer, 'accounts');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -134,26 +134,26 @@ final class ListController extends Controller
*/
public function availableBudgets(TransactionCurrency $currency): JsonResponse
{
- $manager = $this->getManager();
+ $manager = $this->getManager();
// types to get, page size:
- $pageSize = $this->parameters->get('limit');
+ $pageSize = $this->parameters->get('limit');
// get list of available budgets. Count it and split it.
/** @var AvailableBudgetRepositoryInterface $abRepository */
- $abRepository = app(AvailableBudgetRepositoryInterface::class);
+ $abRepository = app(AvailableBudgetRepositoryInterface::class);
$collection = $abRepository->getAvailableBudgetsByCurrency($currency);
$count = $collection->count();
$availableBudgets = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
// make paginator:
- $paginator = new LengthAwarePaginator($availableBudgets, $count, $pageSize, $this->parameters->get('page'));
- $paginator->setPath(route('api.v1.currencies.available-budgets', [$currency->code]).$this->buildParams());
+ $paginator = new LengthAwarePaginator($availableBudgets, $count, $pageSize, $this->parameters->get('page'));
+ $paginator->setPath(route('api.v1.currencies.available-budgets', [$currency->code]) . $this->buildParams());
/** @var AvailableBudgetTransformer $transformer */
- $transformer = app(AvailableBudgetTransformer::class);
+ $transformer = app(AvailableBudgetTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($availableBudgets, $transformer, 'available_budgets');
+ $resource = new FractalCollection($availableBudgets, $transformer, 'available_budgets');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -167,36 +167,36 @@ final class ListController extends Controller
*/
public function bills(TransactionCurrency $currency): JsonResponse
{
- $manager = $this->getManager();
+ $manager = $this->getManager();
/** @var BillRepositoryInterface $billRepos */
- $billRepos = app(BillRepositoryInterface::class);
- $pageSize = $this->parameters->get('limit');
- $unfiltered = $billRepos->getBills();
+ $billRepos = app(BillRepositoryInterface::class);
+ $pageSize = $this->parameters->get('limit');
+ $unfiltered = $billRepos->getBills();
// filter and paginate list:
- $collection = $unfiltered->filter(static fn (Bill $bill): bool => $bill->transaction_currency_id === $currency->id);
- $count = $collection->count();
- $bills = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
+ $collection = $unfiltered->filter(static fn(Bill $bill): bool => $bill->transaction_currency_id === $currency->id);
+ $count = $collection->count();
+ $bills = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new SubscriptionEnrichment();
+ $admin = auth()->user();
+ $enrichment = new SubscriptionEnrichment();
$enrichment->setUser($admin);
$enrichment->setStart($this->parameters->get('start'));
$enrichment->setEnd($this->parameters->get('end'));
- $bills = $enrichment->enrich($bills);
+ $bills = $enrichment->enrich($bills);
// make paginator:
- $paginator = new LengthAwarePaginator($bills, $count, $pageSize, $this->parameters->get('page'));
- $paginator->setPath(route('api.v1.currencies.bills', [$currency->code]).$this->buildParams());
+ $paginator = new LengthAwarePaginator($bills, $count, $pageSize, $this->parameters->get('page'));
+ $paginator->setPath(route('api.v1.currencies.bills', [$currency->code]) . $this->buildParams());
/** @var BillTransformer $transformer */
$transformer = app(BillTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($bills, $transformer, 'bills');
+ $resource = new FractalCollection($bills, $transformer, 'bills');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -219,20 +219,20 @@ final class ListController extends Controller
$count = $collection->count();
$budgetLimits = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
$paginator = new LengthAwarePaginator($budgetLimits, $count, $pageSize, $this->parameters->get('page'));
- $paginator->setPath(route('api.v1.currencies.budget-limits', [$currency->code]).$this->buildParams());
+ $paginator->setPath(route('api.v1.currencies.budget-limits', [$currency->code]) . $this->buildParams());
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new BudgetLimitEnrichment();
+ $admin = auth()->user();
+ $enrichment = new BudgetLimitEnrichment();
$enrichment->setUser($admin);
$budgetLimits = $enrichment->enrich($budgetLimits);
/** @var BudgetLimitTransformer $transformer */
- $transformer = app(BudgetLimitTransformer::class);
+ $transformer = app(BudgetLimitTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($budgetLimits, $transformer, 'budget_limits');
+ $resource = new FractalCollection($budgetLimits, $transformer, 'budget_limits');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -246,9 +246,9 @@ final class ListController extends Controller
*/
public function recurrences(TransactionCurrency $currency): JsonResponse
{
- $manager = $this->getManager();
+ $manager = $this->getManager();
// types to get, page size:
- $pageSize = $this->parameters->get('limit');
+ $pageSize = $this->parameters->get('limit');
// get list of budgets. Count it and split it.
/** @var RecurringRepositoryInterface $recurringRepos */
@@ -256,35 +256,35 @@ final class ListController extends Controller
$unfiltered = $recurringRepos->get();
// filter selection
- $collection = $unfiltered->filter(static function (Recurrence $recurrence) use ($currency): ?Recurrence {
+ $collection = $unfiltered->filter(static function (Recurrence $recurrence) use ($currency): ?Recurrence {
if (array_any(
$recurrence->recurrenceTransactions,
- static fn ($transaction): bool => $transaction->transaction_currency_id === $currency->id || $transaction->foreign_currency_id === $currency->id
+ static fn($transaction): bool => $transaction->transaction_currency_id === $currency->id || $transaction->foreign_currency_id === $currency->id
)) {
return $recurrence;
}
return null;
});
- $count = $collection->count();
- $recurrences = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
+ $count = $collection->count();
+ $recurrences = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new RecurringEnrichment();
+ $admin = auth()->user();
+ $enrichment = new RecurringEnrichment();
$enrichment->setUser($admin);
- $recurrences = $enrichment->enrich($recurrences);
+ $recurrences = $enrichment->enrich($recurrences);
// make paginator:
- $paginator = new LengthAwarePaginator($recurrences, $count, $pageSize, $this->parameters->get('page'));
- $paginator->setPath(route('api.v1.currencies.recurrences', [$currency->code]).$this->buildParams());
+ $paginator = new LengthAwarePaginator($recurrences, $count, $pageSize, $this->parameters->get('page'));
+ $paginator->setPath(route('api.v1.currencies.recurrences', [$currency->code]) . $this->buildParams());
/** @var RecurrenceTransformer $transformer */
- $transformer = app(RecurrenceTransformer::class);
+ $transformer = app(RecurrenceTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($recurrences, $transformer, 'recurrences');
+ $resource = new FractalCollection($recurrences, $transformer, 'recurrences');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -298,18 +298,18 @@ final class ListController extends Controller
*/
public function rules(TransactionCurrency $currency): JsonResponse
{
- $manager = $this->getManager();
- $pageSize = $this->parameters->get('limit');
+ $manager = $this->getManager();
+ $pageSize = $this->parameters->get('limit');
// get list of budgets. Count it and split it.
/** @var RuleRepositoryInterface $ruleRepos */
- $ruleRepos = app(RuleRepositoryInterface::class);
- $unfiltered = $ruleRepos->getAll();
+ $ruleRepos = app(RuleRepositoryInterface::class);
+ $unfiltered = $ruleRepos->getAll();
- $collection = $unfiltered->filter(static function (Rule $rule) use ($currency): ?Rule {
+ $collection = $unfiltered->filter(static function (Rule $rule) use ($currency): ?Rule {
if (array_any(
$rule->ruleTriggers,
- static fn ($trigger): bool => 'currency_is' === $trigger->trigger_type && $currency->name === $trigger->trigger_value
+ static fn($trigger): bool => 'currency_is' === $trigger->trigger_type && $currency->name === $trigger->trigger_value
)) {
return $rule;
}
@@ -317,18 +317,18 @@ final class ListController extends Controller
return null;
});
- $count = $collection->count();
- $rules = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
+ $count = $collection->count();
+ $rules = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
// make paginator:
- $paginator = new LengthAwarePaginator($rules, $count, $pageSize, $this->parameters->get('page'));
- $paginator->setPath(route('api.v1.rules.index').$this->buildParams());
+ $paginator = new LengthAwarePaginator($rules, $count, $pageSize, $this->parameters->get('page'));
+ $paginator->setPath(route('api.v1.rules.index') . $this->buildParams());
/** @var RuleTransformer $transformer */
$transformer = app(RuleTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($rules, $transformer, 'rules');
+ $resource = new FractalCollection($rules, $transformer, 'rules');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -342,19 +342,19 @@ final class ListController extends Controller
*/
public function transactions(Request $request, TransactionCurrency $currency): JsonResponse
{
- $pageSize = $this->parameters->get('limit');
- $type = $request->input('type') ?? 'default';
+ $pageSize = $this->parameters->get('limit');
+ $type = $request->input('type') ?? 'default';
$this->parameters->set('type', $type);
- $types = $this->mapTransactionTypes($this->parameters->get('type'));
- $manager = $this->getManager();
+ $types = $this->mapTransactionTypes($this->parameters->get('type'));
+ $manager = $this->getManager();
/** @var User $admin */
- $admin = auth()->user();
+ $admin = auth()->user();
// use new group collector:
/** @var GroupCollectorInterface $collector */
- $collector = app(GroupCollectorInterface::class);
+ $collector = app(GroupCollectorInterface::class);
$collector
->setUser($admin)
// filter on currency.
@@ -366,27 +366,26 @@ final class ListController extends Controller
// set page to retrieve
->setPage($this->parameters->get('page'))
// set types of transactions to return.
- ->setTypes($types)
- ;
+ ->setTypes($types);
if (null !== $this->parameters->get('start')) {
$collector->setStart($this->parameters->get('start'));
}
if (null !== $this->parameters->get('end')) {
$collector->setEnd($this->parameters->get('end'));
}
- $paginator = $collector->getPaginatedGroups();
- $paginator->setPath(route('api.v1.currencies.transactions', [$currency->code]).$this->buildParams());
+ $paginator = $collector->getPaginatedGroups();
+ $paginator->setPath(route('api.v1.currencies.transactions', [$currency->code]) . $this->buildParams());
// enrich
- $enrichment = new TransactionGroupEnrichment();
+ $enrichment = new TransactionGroupEnrichment();
$enrichment->setUser($admin);
$transactions = $enrichment->enrich($paginator->getCollection());
/** @var TransactionGroupTransformer $transformer */
- $transformer = app(TransactionGroupTransformer::class);
+ $transformer = app(TransactionGroupTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($transactions, $transformer, 'transactions');
+ $resource = new FractalCollection($transactions, $transformer, 'transactions');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
diff --git a/app/Api/V1/Controllers/Models/TransactionCurrency/ShowController.php b/app/Api/V1/Controllers/Models/TransactionCurrency/ShowController.php
index a643398767..c10302b8a9 100644
--- a/app/Api/V1/Controllers/Models/TransactionCurrency/ShowController.php
+++ b/app/Api/V1/Controllers/Models/TransactionCurrency/ShowController.php
@@ -69,21 +69,21 @@ final class ShowController extends Controller
*/
public function index(): JsonResponse
{
- $pageSize = $this->parameters->get('limit');
- $collection = $this->repository->getAll();
- $count = $collection->count();
+ $pageSize = $this->parameters->get('limit');
+ $collection = $this->repository->getAll();
+ $count = $collection->count();
// slice them:
- $currencies = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
- $paginator = new LengthAwarePaginator($currencies, $count, $pageSize, $this->parameters->get('page'));
- $paginator->setPath(route('api.v1.currencies.index').$this->buildParams());
- $manager = $this->getManager();
+ $currencies = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
+ $paginator = new LengthAwarePaginator($currencies, $count, $pageSize, $this->parameters->get('page'));
+ $paginator->setPath(route('api.v1.currencies.index') . $this->buildParams());
+ $manager = $this->getManager();
/** @var CurrencyTransformer $transformer */
$transformer = app(CurrencyTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($currencies, $transformer, 'currencies');
+ $resource = new FractalCollection($currencies, $transformer, 'currencies');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -98,8 +98,8 @@ final class ShowController extends Controller
public function show(TransactionCurrency $currency): JsonResponse
{
/** @var User $user */
- $user = auth()->user();
- $manager = $this->getManager();
+ $user = auth()->user();
+ $manager = $this->getManager();
$this->parameters->set('primaryCurrency', $this->primaryCurrency);
// update fields with user info.
@@ -109,7 +109,7 @@ final class ShowController extends Controller
$transformer = app(CurrencyTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($currency, $transformer, 'currencies');
+ $resource = new Item($currency, $transformer, 'currencies');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
@@ -120,9 +120,9 @@ final class ShowController extends Controller
public function showPrimary(): JsonResponse
{
/** @var User $user */
- $user = auth()->user();
- $manager = $this->getManager();
- $currency = $this->primaryCurrency;
+ $user = auth()->user();
+ $manager = $this->getManager();
+ $currency = $this->primaryCurrency;
// update fields with user info.
$currency->refreshForUser($user);
@@ -131,7 +131,7 @@ final class ShowController extends Controller
$transformer = app(CurrencyTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($currency, $transformer, 'currencies');
+ $resource = new Item($currency, $transformer, 'currencies');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/TransactionCurrency/StoreController.php b/app/Api/V1/Controllers/Models/TransactionCurrency/StoreController.php
index a970467c6f..61c5fdb693 100644
--- a/app/Api/V1/Controllers/Models/TransactionCurrency/StoreController.php
+++ b/app/Api/V1/Controllers/Models/TransactionCurrency/StoreController.php
@@ -67,22 +67,22 @@ final class StoreController extends Controller
*/
public function store(StoreRequest $request): JsonResponse
{
- $currency = $this->repository->store($request->getAll());
+ $currency = $this->repository->store($request->getAll());
if (true === $request->boolean('default')) {
$this->repository->makePrimary($currency);
Preferences::mark();
}
- $manager = $this->getManager();
+ $manager = $this->getManager();
/** @var User $user */
- $user = auth()->user();
+ $user = auth()->user();
$currency->refreshForUser($user);
/** @var CurrencyTransformer $transformer */
$transformer = app(CurrencyTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($currency, $transformer, 'currencies');
+ $resource = new Item($currency, $transformer, 'currencies');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/TransactionCurrency/UpdateController.php b/app/Api/V1/Controllers/Models/TransactionCurrency/UpdateController.php
index 2ef137b8d3..ae4ebdefdb 100644
--- a/app/Api/V1/Controllers/Models/TransactionCurrency/UpdateController.php
+++ b/app/Api/V1/Controllers/Models/TransactionCurrency/UpdateController.php
@@ -81,9 +81,9 @@ final class UpdateController extends Controller
}
/** @var User $user */
- $user = auth()->user();
+ $user = auth()->user();
$this->repository->disable($currency);
- $manager = $this->getManager();
+ $manager = $this->getManager();
$currency->refreshForUser($user);
@@ -91,7 +91,7 @@ final class UpdateController extends Controller
$transformer = app(CurrencyTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($currency, $transformer, 'currencies');
+ $resource = new Item($currency, $transformer, 'currencies');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
@@ -105,10 +105,10 @@ final class UpdateController extends Controller
public function enable(TransactionCurrency $currency): JsonResponse
{
$this->repository->enable($currency);
- $manager = $this->getManager();
+ $manager = $this->getManager();
/** @var User $user */
- $user = auth()->user();
+ $user = auth()->user();
$currency->refreshForUser($user);
@@ -116,7 +116,7 @@ final class UpdateController extends Controller
$transformer = app(CurrencyTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($currency, $transformer, 'currencies');
+ $resource = new Item($currency, $transformer, 'currencies');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
@@ -124,20 +124,20 @@ final class UpdateController extends Controller
public function makePrimary(TransactionCurrency $currency): JsonResponse
{
/** @var User $user */
- $user = auth()->user();
+ $user = auth()->user();
$this->repository->enable($currency);
$this->repository->makePrimary($currency);
Preferences::mark();
- $manager = $this->getManager();
+ $manager = $this->getManager();
$currency->refreshForUser($user);
/** @var CurrencyTransformer $transformer */
$transformer = app(CurrencyTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($currency, $transformer, 'currencies');
+ $resource = new Item($currency, $transformer, 'currencies');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
@@ -152,13 +152,13 @@ final class UpdateController extends Controller
*/
public function update(UpdateRequest $request, TransactionCurrency $currency): JsonResponse
{
- $data = $request->getAll();
+ $data = $request->getAll();
/** @var User $user */
- $user = auth()->user();
+ $user = auth()->user();
// safety catch on currency disablement.
- $set = $this->repository->get();
+ $set = $this->repository->get();
if (array_key_exists('enabled', $data) && false === $data['enabled'] && 1 === count($set) && $set->first()->id === $currency->id) {
return response()->json([], 409);
}
@@ -167,17 +167,17 @@ final class UpdateController extends Controller
return response()->json([], 409);
}
- $currency = $this->repository->update($currency, $data);
+ $currency = $this->repository->update($currency, $data);
Preferences::mark();
- $manager = $this->getManager();
+ $manager = $this->getManager();
$currency->refreshForUser($user);
/** @var CurrencyTransformer $transformer */
$transformer = app(CurrencyTransformer::class);
- $resource = new Item($currency, $transformer, 'currencies');
+ $resource = new Item($currency, $transformer, 'currencies');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/TransactionLink/DestroyController.php b/app/Api/V1/Controllers/Models/TransactionLink/DestroyController.php
index 8b4417b983..e7f4c8315e 100644
--- a/app/Api/V1/Controllers/Models/TransactionLink/DestroyController.php
+++ b/app/Api/V1/Controllers/Models/TransactionLink/DestroyController.php
@@ -46,7 +46,7 @@ final class DestroyController extends Controller
parent::__construct();
$this->middleware(function ($request, $next) {
/** @var User $user */
- $user = auth()->user();
+ $user = auth()->user();
$this->repository = app(LinkTypeRepositoryInterface::class);
diff --git a/app/Api/V1/Controllers/Models/TransactionLink/ShowController.php b/app/Api/V1/Controllers/Models/TransactionLink/ShowController.php
index 1d2fdafb25..941e97c676 100644
--- a/app/Api/V1/Controllers/Models/TransactionLink/ShowController.php
+++ b/app/Api/V1/Controllers/Models/TransactionLink/ShowController.php
@@ -51,7 +51,7 @@ final class ShowController extends Controller
parent::__construct();
$this->middleware(function ($request, $next) {
/** @var User $user */
- $user = auth()->user();
+ $user = auth()->user();
$this->repository = app(LinkTypeRepositoryInterface::class);
@@ -70,13 +70,13 @@ final class ShowController extends Controller
public function index(Request $request): JsonResponse
{
// create some objects:
- $manager = $this->getManager();
+ $manager = $this->getManager();
// read type from URL
- $name = $request->input('name');
+ $name = $request->input('name');
// types to get, page size:
- $pageSize = $this->parameters->get('limit');
- $linkType = $this->repository->findByName($name);
+ $pageSize = $this->parameters->get('limit');
+ $linkType = $this->repository->findByName($name);
// get list of transaction links. Count it and split it.
$collection = $this->repository->getJournalLinks($linkType);
@@ -84,14 +84,14 @@ final class ShowController extends Controller
$journalLinks = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
// make paginator:
- $paginator = new LengthAwarePaginator($journalLinks, $count, $pageSize, $this->parameters->get('page'));
- $paginator->setPath(route('api.v1.transaction-links.index').$this->buildParams());
+ $paginator = new LengthAwarePaginator($journalLinks, $count, $pageSize, $this->parameters->get('page'));
+ $paginator->setPath(route('api.v1.transaction-links.index') . $this->buildParams());
/** @var TransactionLinkTransformer $transformer */
- $transformer = app(TransactionLinkTransformer::class);
+ $transformer = app(TransactionLinkTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($journalLinks, $transformer, 'transaction_links');
+ $resource = new FractalCollection($journalLinks, $transformer, 'transaction_links');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -105,13 +105,13 @@ final class ShowController extends Controller
*/
public function show(TransactionJournalLink $journalLink): JsonResponse
{
- $manager = $this->getManager();
+ $manager = $this->getManager();
/** @var TransactionLinkTransformer $transformer */
$transformer = app(TransactionLinkTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($journalLink, $transformer, 'transaction_links');
+ $resource = new Item($journalLink, $transformer, 'transaction_links');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/TransactionLink/StoreController.php b/app/Api/V1/Controllers/Models/TransactionLink/StoreController.php
index 5da90bbd04..8244a53a7d 100644
--- a/app/Api/V1/Controllers/Models/TransactionLink/StoreController.php
+++ b/app/Api/V1/Controllers/Models/TransactionLink/StoreController.php
@@ -43,7 +43,7 @@ final class StoreController extends Controller
{
use TransactionFilter;
- private JournalRepositoryInterface $journalRepository;
+ private JournalRepositoryInterface $journalRepository;
private LinkTypeRepositoryInterface $repository;
/**
@@ -54,7 +54,7 @@ final class StoreController extends Controller
parent::__construct();
$this->middleware(function ($request, $next) {
/** @var User $user */
- $user = auth()->user();
+ $user = auth()->user();
$this->repository = app(LinkTypeRepositoryInterface::class);
$this->journalRepository = app(JournalRepositoryInterface::class);
@@ -76,22 +76,22 @@ final class StoreController extends Controller
*/
public function store(StoreRequest $request): JsonResponse
{
- $manager = $this->getManager();
- $data = $request->getAll();
- $inward = $this->journalRepository->find($data['inward_id'] ?? 0);
- $outward = $this->journalRepository->find($data['outward_id'] ?? 0);
+ $manager = $this->getManager();
+ $data = $request->getAll();
+ $inward = $this->journalRepository->find($data['inward_id'] ?? 0);
+ $outward = $this->journalRepository->find($data['outward_id'] ?? 0);
if (!$inward instanceof TransactionJournal || !$outward instanceof TransactionJournal) {
throw new FireflyException('200024: Source or destination does not exist.');
}
$data['direction'] = 'inward';
- $journalLink = $this->repository->storeLink($data, $inward, $outward);
+ $journalLink = $this->repository->storeLink($data, $inward, $outward);
/** @var TransactionLinkTransformer $transformer */
- $transformer = app(TransactionLinkTransformer::class);
+ $transformer = app(TransactionLinkTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($journalLink, $transformer, 'transaction_links');
+ $resource = new Item($journalLink, $transformer, 'transaction_links');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/TransactionLink/UpdateController.php b/app/Api/V1/Controllers/Models/TransactionLink/UpdateController.php
index 351c79c8c8..51f42251a4 100644
--- a/app/Api/V1/Controllers/Models/TransactionLink/UpdateController.php
+++ b/app/Api/V1/Controllers/Models/TransactionLink/UpdateController.php
@@ -39,7 +39,7 @@ use League\Fractal\Resource\Item;
*/
final class UpdateController extends Controller
{
- private JournalRepositoryInterface $journalRepository;
+ private JournalRepositoryInterface $journalRepository;
private LinkTypeRepositoryInterface $repository;
/**
@@ -50,7 +50,7 @@ final class UpdateController extends Controller
parent::__construct();
$this->middleware(function ($request, $next) {
/** @var User $user */
- $user = auth()->user();
+ $user = auth()->user();
$this->repository = app(LinkTypeRepositoryInterface::class);
$this->journalRepository = app(JournalRepositoryInterface::class);
@@ -78,7 +78,7 @@ final class UpdateController extends Controller
$transformer = app(TransactionLinkTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($journalLink, $transformer, 'transaction_links');
+ $resource = new Item($journalLink, $transformer, 'transaction_links');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/TransactionLinkType/ListController.php b/app/Api/V1/Controllers/Models/TransactionLinkType/ListController.php
index 93809f73bb..9a08834c5e 100644
--- a/app/Api/V1/Controllers/Models/TransactionLinkType/ListController.php
+++ b/app/Api/V1/Controllers/Models/TransactionLinkType/ListController.php
@@ -68,22 +68,22 @@ final class ListController extends Controller
*/
public function transactions(Request $request, LinkType $linkType): JsonResponse
{
- $pageSize = $this->parameters->get('limit');
- $type = $request->input('type') ?? 'default';
+ $pageSize = $this->parameters->get('limit');
+ $type = $request->input('type') ?? 'default';
$this->parameters->set('type', $type);
- $types = $this->mapTransactionTypes($this->parameters->get('type'));
- $manager = $this->getManager();
+ $types = $this->mapTransactionTypes($this->parameters->get('type'));
+ $manager = $this->getManager();
// whatever is returned by the query, it must be part of these journals:
- $journalIds = $this->repository->getJournalIds($linkType);
+ $journalIds = $this->repository->getJournalIds($linkType);
/** @var User $admin */
- $admin = auth()->user();
+ $admin = auth()->user();
// use new group collector:
/** @var GroupCollectorInterface $collector */
- $collector = app(GroupCollectorInterface::class);
+ $collector = app(GroupCollectorInterface::class);
if (0 === count($journalIds)) {
$collector->findNothing();
}
@@ -98,27 +98,26 @@ final class ListController extends Controller
// set page to retrieve
->setPage($this->parameters->get('page'))
// set types of transactions to return.
- ->setTypes($types)
- ;
+ ->setTypes($types);
if (null !== $this->parameters->get('start')) {
$collector->setStart($this->parameters->get('start'));
}
if (null !== $this->parameters->get('end')) {
$collector->setEnd($this->parameters->get('end'));
}
- $paginator = $collector->getPaginatedGroups();
- $paginator->setPath(route('api.v1.transactions.index').$this->buildParams());
+ $paginator = $collector->getPaginatedGroups();
+ $paginator->setPath(route('api.v1.transactions.index') . $this->buildParams());
// enrich
- $enrichment = new TransactionGroupEnrichment();
+ $enrichment = new TransactionGroupEnrichment();
$enrichment->setUser($admin);
$transactions = $enrichment->enrich($paginator->getCollection());
/** @var TransactionGroupTransformer $transformer */
- $transformer = app(TransactionGroupTransformer::class);
+ $transformer = app(TransactionGroupTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($transactions, $transformer, 'transactions');
+ $resource = new FractalCollection($transactions, $transformer, 'transactions');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
diff --git a/app/Api/V1/Controllers/Models/TransactionLinkType/ShowController.php b/app/Api/V1/Controllers/Models/TransactionLinkType/ShowController.php
index e3ac05e86c..073362ee0a 100644
--- a/app/Api/V1/Controllers/Models/TransactionLinkType/ShowController.php
+++ b/app/Api/V1/Controllers/Models/TransactionLinkType/ShowController.php
@@ -68,23 +68,23 @@ final class ShowController extends Controller
public function index(): JsonResponse
{
// create some objects:
- $manager = $this->getManager();
- $pageSize = $this->parameters->get('limit');
+ $manager = $this->getManager();
+ $pageSize = $this->parameters->get('limit');
// get list of accounts. Count it and split it.
- $collection = $this->repository->get();
- $count = $collection->count();
- $linkTypes = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
+ $collection = $this->repository->get();
+ $count = $collection->count();
+ $linkTypes = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
// make paginator:
- $paginator = new LengthAwarePaginator($linkTypes, $count, $pageSize, $this->parameters->get('page'));
- $paginator->setPath(route('api.v1.link-types.index').$this->buildParams());
+ $paginator = new LengthAwarePaginator($linkTypes, $count, $pageSize, $this->parameters->get('page'));
+ $paginator->setPath(route('api.v1.link-types.index') . $this->buildParams());
/** @var LinkTypeTransformer $transformer */
$transformer = app(LinkTypeTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($linkTypes, $transformer, 'link_types');
+ $resource = new FractalCollection($linkTypes, $transformer, 'link_types');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -98,13 +98,13 @@ final class ShowController extends Controller
*/
public function show(LinkType $linkType): JsonResponse
{
- $manager = $this->getManager();
+ $manager = $this->getManager();
/** @var LinkTypeTransformer $transformer */
$transformer = app(LinkTypeTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($linkType, $transformer, 'link_types');
+ $resource = new Item($linkType, $transformer, 'link_types');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/TransactionLinkType/StoreController.php b/app/Api/V1/Controllers/Models/TransactionLinkType/StoreController.php
index ab3c84a44b..c582c58198 100644
--- a/app/Api/V1/Controllers/Models/TransactionLinkType/StoreController.php
+++ b/app/Api/V1/Controllers/Models/TransactionLinkType/StoreController.php
@@ -69,15 +69,15 @@ final class StoreController extends Controller
*/
public function store(StoreRequest $request): JsonResponse
{
- $data = $request->getAll();
+ $data = $request->getAll();
// if currency ID is 0, find the currency by the code:
- $linkType = $this->repository->store($data);
- $manager = $this->getManager();
+ $linkType = $this->repository->store($data);
+ $manager = $this->getManager();
/** @var LinkTypeTransformer $transformer */
$transformer = app(LinkTypeTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($linkType, $transformer, 'link_types');
+ $resource = new Item($linkType, $transformer, 'link_types');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/TransactionLinkType/UpdateController.php b/app/Api/V1/Controllers/Models/TransactionLinkType/UpdateController.php
index 13efa8f99d..54f47c6bad 100644
--- a/app/Api/V1/Controllers/Models/TransactionLinkType/UpdateController.php
+++ b/app/Api/V1/Controllers/Models/TransactionLinkType/UpdateController.php
@@ -76,15 +76,15 @@ final class UpdateController extends Controller
throw new FireflyException('200020: Link type cannot be changed.');
}
- $data = $request->getAll();
+ $data = $request->getAll();
$this->repository->update($linkType, $data);
- $manager = $this->getManager();
+ $manager = $this->getManager();
/** @var LinkTypeTransformer $transformer */
$transformer = app(LinkTypeTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($linkType, $transformer, 'link_types');
+ $resource = new Item($linkType, $transformer, 'link_types');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/UserGroup/IndexController.php b/app/Api/V1/Controllers/Models/UserGroup/IndexController.php
index 54a9fd266e..a4b44a3af6 100644
--- a/app/Api/V1/Controllers/Models/UserGroup/IndexController.php
+++ b/app/Api/V1/Controllers/Models/UserGroup/IndexController.php
@@ -52,12 +52,12 @@ final class IndexController extends Controller
public function index(PaginationRequest $request): JsonResponse
{
- $administrations = $this->repository->get();
+ $administrations = $this->repository->get();
['page' => $page, 'limit' => $limit, 'offset' => $offset] = $request->attributes->all();
- $count = $administrations->count();
- $administrations = $administrations->slice($offset, $limit);
- $paginator = new LengthAwarePaginator($administrations, $count, $limit, $page);
- $transformer = new UserGroupTransformer();
+ $count = $administrations->count();
+ $administrations = $administrations->slice($offset, $limit);
+ $paginator = new LengthAwarePaginator($administrations, $count, $limit, $page);
+ $transformer = new UserGroupTransformer();
return response()->json($this->jsonApiList(self::RESOURCE_KEY, $paginator, $transformer))->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Models/UserGroup/UpdateController.php b/app/Api/V1/Controllers/Models/UserGroup/UpdateController.php
index 95479cda5a..0edd420223 100644
--- a/app/Api/V1/Controllers/Models/UserGroup/UpdateController.php
+++ b/app/Api/V1/Controllers/Models/UserGroup/UpdateController.php
@@ -55,8 +55,8 @@ final class UpdateController extends Controller
public function update(UpdateRequest $request, UserGroup $userGroup): JsonResponse
{
Log::debug(sprintf('Now in %s', __METHOD__));
- $data = $request->getData();
- $userGroup = $this->repository->update($userGroup, $data);
+ $data = $request->getData();
+ $userGroup = $this->repository->update($userGroup, $data);
$userGroup->refresh();
Preferences::mark();
diff --git a/app/Api/V1/Controllers/Search/AccountController.php b/app/Api/V1/Controllers/Search/AccountController.php
index a3b1370b90..58c9f7c5b0 100644
--- a/app/Api/V1/Controllers/Search/AccountController.php
+++ b/app/Api/V1/Controllers/Search/AccountController.php
@@ -45,55 +45,56 @@ final class AccountController extends Controller
{
use AccountFilter;
- private array $validFields = [
- AccountSearch::SEARCH_ALL,
- AccountSearch::SEARCH_ID,
- AccountSearch::SEARCH_NAME,
- AccountSearch::SEARCH_IBAN,
- AccountSearch::SEARCH_NUMBER,
- ];
+ private array $validFields
+ = [
+ AccountSearch::SEARCH_ALL,
+ AccountSearch::SEARCH_ID,
+ AccountSearch::SEARCH_NAME,
+ AccountSearch::SEARCH_IBAN,
+ AccountSearch::SEARCH_NUMBER,
+ ];
/**
* This endpoint is documented at:
* https://api-docs.firefly-iii.org/?urls.primaryName=2.0.0%20(v1)#/search/searchAccounts
*/
- public function search(Request $request): JsonResponse|Response
+ public function search(Request $request): JsonResponse | Response
{
- $manager = $this->getManager();
- $query = trim((string) $request->input('query'));
- $field = trim((string) $request->input('field'));
- $type = $request->input('type') ?? 'all';
+ $manager = $this->getManager();
+ $query = trim((string)$request->input('query'));
+ $field = trim((string)$request->input('field'));
+ $type = $request->input('type') ?? 'all';
if ('' === $query || !in_array($field, $this->validFields, strict: true)) {
return response(null, 422);
}
Log::debug(sprintf('Now in account search("%s", "%s")', $field, $query));
- $types = $this->mapAccountTypes($type);
+ $types = $this->mapAccountTypes($type);
/** @var AccountSearch $search */
- $search = app(AccountSearch::class);
+ $search = app(AccountSearch::class);
$search->setUser(auth()->user());
$search->setTypes($types);
$search->setField($field);
$search->setQuery($query);
- $accounts = $search->search();
+ $accounts = $search->search();
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new AccountEnrichment();
+ $admin = auth()->user();
+ $enrichment = new AccountEnrichment();
$enrichment->setDate($this->parameters->get('date'));
$enrichment->setUser($admin);
- $accounts = $enrichment->enrich($accounts);
+ $accounts = $enrichment->enrich($accounts);
/** @var AccountTransformer $transformer */
$transformer = app(AccountTransformer::class);
$transformer->setParameters($this->parameters);
- $count = $accounts->count();
- $perPage = 0 === $count ? 1 : $count;
- $paginator = new LengthAwarePaginator($accounts, $count, $perPage, 1);
+ $count = $accounts->count();
+ $perPage = 0 === $count ? 1 : $count;
+ $paginator = new LengthAwarePaginator($accounts, $count, $perPage, 1);
- $resource = new FractalCollection($accounts, $transformer, 'accounts');
+ $resource = new FractalCollection($accounts, $transformer, 'accounts');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
diff --git a/app/Api/V1/Controllers/Search/TransactionController.php b/app/Api/V1/Controllers/Search/TransactionController.php
index 5ac75b84cd..197fd2f2bd 100644
--- a/app/Api/V1/Controllers/Search/TransactionController.php
+++ b/app/Api/V1/Controllers/Search/TransactionController.php
@@ -49,7 +49,7 @@ final class TransactionController extends Controller
parent::__construct();
$this->middleware(function ($request, $next) {
/** @var User $admin */
- $admin = auth()->user();
+ $admin = auth()->user();
$this->repository = app(JournalRepositoryInterface::class);
$this->repository->setUser($admin);
@@ -62,10 +62,10 @@ final class TransactionController extends Controller
{
$count = 0;
$includeDeleted = $request->attributes->get('include_deleted', false);
- $externalId = (string) $request->attributes->get('external_identifier');
- $internalRef = (string) $request->attributes->get('internal_reference');
- $notes = (string) $request->attributes->get('notes');
- $description = (string) $request->attributes->get('description');
+ $externalId = (string)$request->attributes->get('external_identifier');
+ $internalRef = (string)$request->attributes->get('internal_reference');
+ $notes = (string)$request->attributes->get('notes');
+ $description = (string)$request->attributes->get('description');
Log::debug(sprintf('Include deleted? %s', var_export(value: $includeDeleted, return: true)));
if ('' !== $externalId) {
$count += $this->repository->countByMeta('external_id', $externalId, $includeDeleted);
@@ -93,31 +93,31 @@ final class TransactionController extends Controller
*/
public function search(TransactionSearchRequest $request, SearchInterface $searcher): JsonResponse
{
- $manager = $this->getManager();
- $fullQuery = (string) $request->attributes->get('query');
- $page = $request->attributes->get('page');
- $pageSize = $request->attributes->get('limit');
+ $manager = $this->getManager();
+ $fullQuery = (string)$request->attributes->get('query');
+ $page = $request->attributes->get('page');
+ $pageSize = $request->attributes->get('limit');
$searcher->parseQuery($fullQuery);
$searcher->setPage($page);
$searcher->setLimit($pageSize);
- $groups = $searcher->searchTransactions();
- $parameters = ['search' => $fullQuery];
- $url = route('api.v1.search.transactions').'?'.http_build_query($parameters);
+ $groups = $searcher->searchTransactions();
+ $parameters = ['search' => $fullQuery];
+ $url = route('api.v1.search.transactions') . '?' . http_build_query($parameters);
$groups->setPath($url);
// enrich
- $enrichment = new TransactionGroupEnrichment();
+ $enrichment = new TransactionGroupEnrichment();
$enrichment->setUser(auth()->user());
$transactions = $enrichment->enrich($groups->getCollection());
/** @var TransactionGroupTransformer $transformer */
- $transformer = app(TransactionGroupTransformer::class);
+ $transformer = app(TransactionGroupTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Collection($transactions, $transformer, 'transactions');
+ $resource = new Collection($transactions, $transformer, 'transactions');
$resource->setPaginator(new IlluminatePaginatorAdapter($groups));
- $array = $manager->createData($resource)->toArray();
+ $array = $manager->createData($resource)->toArray();
return response()->json($array)->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Summary/BasicController.php b/app/Api/V1/Controllers/Summary/BasicController.php
index a557f35188..ba0a1cf2e9 100644
--- a/app/Api/V1/Controllers/Summary/BasicController.php
+++ b/app/Api/V1/Controllers/Summary/BasicController.php
@@ -53,11 +53,11 @@ use Illuminate\Support\Facades\Log;
final class BasicController extends Controller
{
private AvailableBudgetRepositoryInterface $abRepository;
- private AccountRepositoryInterface $accountRepository;
- private BillRepositoryInterface $billRepository;
- private BudgetRepositoryInterface $budgetRepository;
- private CurrencyRepositoryInterface $currencyRepos;
- private OperationsRepositoryInterface $opsRepository;
+ private AccountRepositoryInterface $accountRepository;
+ private BillRepositoryInterface $billRepository;
+ private BudgetRepositoryInterface $budgetRepository;
+ private CurrencyRepositoryInterface $currencyRepos;
+ private OperationsRepositoryInterface $opsRepository;
/**
* BasicController constructor.
@@ -92,18 +92,18 @@ final class BasicController extends Controller
// parameters for boxes:
['start' => $start, 'end' => $end, 'code' => $code] = $request->attributes->all();
// balance information:
- $balanceData = $this->getBalanceInformation($start, $end);
- $billData = $this->getSubscriptionInformation($start, $end);
- $spentData = $this->getLeftToSpendInfo($start, $end);
- $netWorthData = $this->getNetWorthInfo($end);
+ $balanceData = $this->getBalanceInformation($start, $end);
+ $billData = $this->getSubscriptionInformation($start, $end);
+ $spentData = $this->getLeftToSpendInfo($start, $end);
+ $netWorthData = $this->getNetWorthInfo($end);
// $balanceData = [];
// $billData = [];
// $spentData = [];
// $netWorthData = [];
- $total = array_merge($balanceData, $billData, $spentData, $netWorthData);
+ $total = array_merge($balanceData, $billData, $spentData, $netWorthData);
// give new keys
- $return = [];
+ $return = [];
foreach ($total as $entry) {
if ('' === $code || $code === $entry['currency_code']) {
$return[$entry['key']] = $entry;
@@ -120,28 +120,27 @@ final class BasicController extends Controller
$convertToPrimary = Amount::convertToPrimary();
$primary = Amount::getPrimaryCurrency();
// prep some arrays:
- $sums = [];
- $return = [];
- $currencies = [$primary->id => $primary];
+ $sums = [];
+ $return = [];
+ $currencies = [$primary->id => $primary];
// collect income of user using the new group collector.
/** @var GroupCollectorInterface $collector */
- $collector = app(GroupCollectorInterface::class);
- $summarizer = new TransactionSummarizer();
- $set = $collector->setRange($start, $end)->setTypes([TransactionTypeEnum::DEPOSIT->value])->getExtractedJournals();
- $incomes = $summarizer->groupByCurrencyId($set, 'positive', false);
+ $collector = app(GroupCollectorInterface::class);
+ $summarizer = new TransactionSummarizer();
+ $set = $collector->setRange($start, $end)->setTypes([TransactionTypeEnum::DEPOSIT->value])->getExtractedJournals();
+ $incomes = $summarizer->groupByCurrencyId($set, 'positive', false);
// collect expenses of user.
// collect expenses of user using the new group collector.
/** @var GroupCollectorInterface $collector */
- $collector = app(GroupCollectorInterface::class);
- $set = $collector
+ $collector = app(GroupCollectorInterface::class);
+ $set = $collector
->setRange($start, $end)
->setPage($this->parameters->get('page'))
->setTypes([TransactionTypeEnum::WITHDRAWAL->value])
- ->getExtractedJournals()
- ;
- $expenses = $summarizer->groupByCurrencyId($set, 'negative', false);
+ ->getExtractedJournals();
+ $expenses = $summarizer->groupByCurrencyId($set, 'negative', false);
// if convert to primary, do so right now.
if ($convertToPrimary) {
@@ -173,29 +172,29 @@ final class BasicController extends Controller
],
];
- $converter = new ExchangeRateConverter();
+ $converter = new ExchangeRateConverter();
// loop over income and expenses
foreach ([$expenses, $incomes] as $index => $array) {
// loop over either one.
foreach ($array as $entry) {
// if it is the primary currency already.
if ($entry['currency_id'] === $primary->id) {
- $sums[$primary->id]['sum'] = bcadd((string) $entry['sum'], $sums[$primary->id]['sum']);
+ $sums[$primary->id]['sum'] = bcadd((string)$entry['sum'], $sums[$primary->id]['sum']);
// don't forget to add it to newExpenses and newIncome
if (0 === $index) {
- $newExpenses[$primary->id]['sum'] = bcadd($newExpenses[$primary->id]['sum'], (string) $entry['sum']);
+ $newExpenses[$primary->id]['sum'] = bcadd($newExpenses[$primary->id]['sum'], (string)$entry['sum']);
}
if (1 === $index) {
- $newIncomes[$primary->id]['sum'] = bcadd($newIncomes[$primary->id]['sum'], (string) $entry['sum']);
+ $newIncomes[$primary->id]['sum'] = bcadd($newIncomes[$primary->id]['sum'], (string)$entry['sum']);
}
continue;
}
$currencies[$entry['currency_id']] ??= $this->currencyRepos->find($entry['currency_id']);
- $convertedSum = $converter->convert($currencies[$entry['currency_id']], $primary, $start, $entry['sum']);
- $sums[$primary->id]['sum'] = bcadd($sums[$primary->id]['sum'], $convertedSum);
+ $convertedSum = $converter->convert($currencies[$entry['currency_id']], $primary, $start, $entry['sum']);
+ $sums[$primary->id]['sum'] = bcadd($sums[$primary->id]['sum'], $convertedSum);
if (0 === $index) {
$newExpenses[$primary->id]['sum'] = bcadd($newExpenses[$primary->id]['sum'], $convertedSum);
}
@@ -204,26 +203,26 @@ final class BasicController extends Controller
}
}
}
- $incomes = $newIncomes;
- $expenses = $newExpenses;
+ $incomes = $newIncomes;
+ $expenses = $newExpenses;
}
if (!$convertToPrimary) {
foreach ([$expenses, $incomes] as $array) {
foreach ($array as $entry) {
$currencyId = $entry['currency_id'];
- $sums[$currencyId] ??= [
+ $sums[$currencyId] ??= [
'currency_id' => $entry['currency_id'],
'currency_code' => $entry['currency_code'],
'currency_symbol' => $entry['currency_symbol'],
'currency_decimal_places' => $entry['currency_decimal_places'],
'sum' => '0',
];
- $sums[$currencyId]['sum'] = bcadd($sums[$currencyId]['sum'], (string) $entry['sum']);
+ $sums[$currencyId]['sum'] = bcadd($sums[$currencyId]['sum'], (string)$entry['sum']);
}
}
}
// format amounts:
- $keys = array_keys($sums);
+ $keys = array_keys($sums);
foreach ($keys as $currencyId) {
$currency = $currencies[$currencyId] ?? $this->currencyRepos->find($currencyId);
if (null === $currency) {
@@ -234,21 +233,21 @@ final class BasicController extends Controller
'key' => sprintf('balance-in-%s', $currency->code),
'title' => trans('firefly.box_balance_in_currency', ['currency' => $currency->symbol]),
'monetary_value' => $sums[$currencyId]['sum'] ?? '0',
- 'currency_id' => (string) $currency->id,
+ 'currency_id' => (string)$currency->id,
'currency_code' => $currency->code,
'currency_symbol' => $currency->symbol,
'currency_decimal_places' => $currency->decimal_places,
'value_parsed' => Amount::formatAnything($currency, $sums[$currencyId]['sum'] ?? '0', false),
'local_icon' => 'balance-scale',
'sub_title' => Amount::formatAnything($currency, $expenses[$currencyId]['sum'] ?? '0', false)
- .' + '
- .Amount::formatAnything($currency, $incomes[$currencyId]['sum'] ?? '0', false),
+ . ' + '
+ . Amount::formatAnything($currency, $incomes[$currencyId]['sum'] ?? '0', false),
];
$return[] = [
'key' => sprintf('spent-in-%s', $currency->code),
'title' => trans('firefly.box_spent_in_currency', ['currency' => $currency->symbol]),
'monetary_value' => $expenses[$currencyId]['sum'] ?? '0',
- 'currency_id' => (string) $currency->id,
+ 'currency_id' => (string)$currency->id,
'currency_code' => $currency->code,
'currency_symbol' => $currency->symbol,
'currency_decimal_places' => $currency->decimal_places,
@@ -260,7 +259,7 @@ final class BasicController extends Controller
'key' => sprintf('earned-in-%s', $currency->code),
'title' => trans('firefly.box_earned_in_currency', ['currency' => $currency->symbol]),
'monetary_value' => $incomes[$currencyId]['sum'] ?? '0',
- 'currency_id' => (string) $currency->id,
+ 'currency_id' => (string)$currency->id,
'currency_code' => $currency->code,
'currency_symbol' => $currency->symbol,
'currency_decimal_places' => $currency->decimal_places,
@@ -276,19 +275,19 @@ final class BasicController extends Controller
'key' => sprintf('balance-in-%s', $currency->code),
'title' => trans('firefly.box_balance_in_currency', ['currency' => $currency->symbol]),
'monetary_value' => '0',
- 'currency_id' => (string) $currency->id,
+ 'currency_id' => (string)$currency->id,
'currency_code' => $currency->code,
'currency_symbol' => $currency->symbol,
'currency_decimal_places' => $currency->decimal_places,
'value_parsed' => Amount::formatAnything($currency, '0', false),
'local_icon' => 'balance-scale',
- 'sub_title' => Amount::formatAnything($currency, '0', false).' + '.Amount::formatAnything($currency, '0', false),
+ 'sub_title' => Amount::formatAnything($currency, '0', false) . ' + ' . Amount::formatAnything($currency, '0', false),
];
$return[] = [
'key' => sprintf('spent-in-%s', $currency->code),
'title' => trans('firefly.box_spent_in_currency', ['currency' => $currency->symbol]),
'monetary_value' => '0',
- 'currency_id' => (string) $currency->id,
+ 'currency_id' => (string)$currency->id,
'currency_code' => $currency->code,
'currency_symbol' => $currency->symbol,
'currency_decimal_places' => $currency->decimal_places,
@@ -300,7 +299,7 @@ final class BasicController extends Controller
'key' => sprintf('earned-in-%s', $currency->code),
'title' => trans('firefly.box_earned_in_currency', ['currency' => $currency->symbol]),
'monetary_value' => '0',
- 'currency_id' => (string) $currency->id,
+ 'currency_id' => (string)$currency->id,
'currency_code' => $currency->code,
'currency_symbol' => $currency->symbol,
'currency_decimal_places' => $currency->decimal_places,
@@ -324,19 +323,19 @@ final class BasicController extends Controller
$available = $this->abRepository->getAvailableBudgetWithCurrency($start, $end);
$budgets = $this->budgetRepository->getActiveBudgets();
$spent = $this->opsRepository->sumExpenses($start, $end, null, $budgets, null, true);
- $days = (int) $today->diffInDays($end, true) + 1;
+ $days = (int)$today->diffInDays($end, true) + 1;
$currencies = [];
// first, create an entry for each entry in the "available" array.
/** @var string $availableBudget */
foreach ($available as $currencyId => $availableBudget) {
$currencies[$currencyId] ??= $this->currencyRepos->find($currencyId);
- $return[$currencyId] = [
+ $return[$currencyId] = [
'key' => sprintf('left-to-spend-in-%s', $currencies[$currencyId]->code),
'title' => trans('firefly.box_left_to_spend_in_currency', ['currency' => $currencies[$currencyId]->symbol]),
'no_available_budgets' => false,
'monetary_value' => $availableBudget,
- 'currency_id' => (string) $currencies[$currencyId]->id,
+ 'currency_id' => (string)$currencies[$currencyId]->id,
'currency_code' => $currencies[$currencyId]->code,
'currency_symbol' => $currencies[$currencyId]->symbol,
'currency_decimal_places' => $currencies[$currencyId]->decimal_places,
@@ -350,24 +349,24 @@ final class BasicController extends Controller
'sub_title' => Amount::formatFlat(
$currencies[$currencyId]->symbol,
$currencies[$currencyId]->decimal_places,
- bcdiv($availableBudget, (string) $days),
+ bcdiv($availableBudget, (string)$days),
false
),
];
}
foreach ($spent as $row) {
// either an amount was budgeted or 0 is available.
- $currencyId = (int) $row['currency_id'];
- $amount = (string) ($available[$currencyId] ?? '0');
+ $currencyId = (int)$row['currency_id'];
+ $amount = (string)($available[$currencyId] ?? '0');
if (0 === bccomp($amount, '0')) {
// #9858 skip over currencies with no available budget.
continue;
}
- $spentInCurrency = $row['sum'];
- $leftToSpend = bcadd($amount, (string) $spentInCurrency);
- $perDay = '0';
+ $spentInCurrency = $row['sum'];
+ $leftToSpend = bcadd($amount, (string)$spentInCurrency);
+ $perDay = '0';
if (0 !== $days && bccomp($leftToSpend, '0') > -1) {
- $perDay = bcdiv($leftToSpend, (string) $days);
+ $perDay = bcdiv($leftToSpend, (string)$days);
}
Log::debug(sprintf('Spent %s %s', $row['currency_code'], $row['sum']));
@@ -377,7 +376,7 @@ final class BasicController extends Controller
'title' => trans('firefly.box_left_to_spend_in_currency', ['currency' => $row['currency_symbol']]),
'no_available_budgets' => false,
'monetary_value' => $leftToSpend,
- 'currency_id' => (string) $row['currency_id'],
+ 'currency_id' => (string)$row['currency_id'],
'currency_code' => $row['currency_code'],
'currency_symbol' => $row['currency_symbol'],
'currency_decimal_places' => $row['currency_decimal_places'],
@@ -388,16 +387,16 @@ final class BasicController extends Controller
}
unset($leftToSpend);
if (0 === count($return)) {
- $days = (int) $start->diffInDays($end, true) + 1;
+ $days = (int)$start->diffInDays($end, true) + 1;
// a small trick to get every expense in this period, regardless of budget.
$spent = $this->opsRepository->sumExpenses($start, $end, null, new Collection());
foreach ($spent as $row) {
// either an amount was budgeted or 0 is available.
- $currencyId = (int) $row['currency_id'];
- $spentInCurrency = $row['sum'];
- $perDay = '0';
- if (0 !== $days && -1 === bccomp((string) $spentInCurrency, '0')) {
- $perDay = bcdiv((string) $spentInCurrency, (string) $days);
+ $currencyId = (int)$row['currency_id'];
+ $spentInCurrency = $row['sum'];
+ $perDay = '0';
+ if (0 !== $days && -1 === bccomp((string)$spentInCurrency, '0')) {
+ $perDay = bcdiv((string)$spentInCurrency, (string)$days);
}
Log::debug(sprintf('Spent %s %s', $row['currency_code'], $row['sum']));
@@ -407,7 +406,7 @@ final class BasicController extends Controller
'title' => trans('firefly.spent'),
'no_available_budgets' => true,
'monetary_value' => $spentInCurrency,
- 'currency_id' => (string) $row['currency_id'],
+ 'currency_id' => (string)$row['currency_id'],
'currency_code' => $row['currency_code'],
'currency_symbol' => $row['currency_symbol'],
'currency_decimal_places' => $row['currency_decimal_places'],
@@ -447,35 +446,35 @@ final class BasicController extends Controller
private function getNetWorthInfo(Carbon $end): array
{
/** @var User $user */
- $user = auth()->user();
+ $user = auth()->user();
Log::debug(sprintf('getNetWorthInfo up until "%s".', $end->format('Y-m-d H:i:s')));
/** @var NetWorthInterface $netWorthHelper */
$netWorthHelper = app(NetWorthInterface::class);
$netWorthHelper->setUser($user);
- $allAccounts = $this->accountRepository->getActiveAccountsByType([
- AccountTypeEnum::ASSET->value,
- AccountTypeEnum::DEFAULT->value,
- AccountTypeEnum::LOAN->value,
- AccountTypeEnum::MORTGAGE->value,
- AccountTypeEnum::DEBT->value,
- ]);
+ $allAccounts = $this->accountRepository->getActiveAccountsByType([
+ AccountTypeEnum::ASSET->value,
+ AccountTypeEnum::DEFAULT->value,
+ AccountTypeEnum::LOAN->value,
+ AccountTypeEnum::MORTGAGE->value,
+ AccountTypeEnum::DEBT->value,
+ ]);
// filter list on preference of being included.
- $filtered = $allAccounts->filter(function (Account $account): bool {
+ $filtered = $allAccounts->filter(function (Account $account): bool {
$includeNetWorth = $this->accountRepository->getMetaValue($account, 'include_net_worth');
return null === $includeNetWorth || '1' === $includeNetWorth;
});
- $netWorthSet = $netWorthHelper->byAccounts($filtered, $end);
- $return = [];
+ $netWorthSet = $netWorthHelper->byAccounts($filtered, $end);
+ $return = [];
foreach ($netWorthSet as $key => $data) {
if ('pc' === $key) {
continue;
}
- $amount = $data['balance'];
- if (0 === bccomp((string) $amount, '0')) {
+ $amount = $data['balance'];
+ if (0 === bccomp((string)$amount, '0')) {
continue;
}
// return stuff
@@ -483,7 +482,7 @@ final class BasicController extends Controller
'key' => sprintf('net-worth-in-%s', $data['currency_code']),
'title' => trans('firefly.box_net_worth_in_currency', ['currency' => $data['currency_symbol']]),
'monetary_value' => $amount,
- 'currency_id' => (string) $data['currency_id'],
+ 'currency_id' => (string)$data['currency_id'],
'currency_code' => $data['currency_code'],
'currency_symbol' => $data['currency_symbol'],
'currency_decimal_places' => $data['currency_decimal_places'],
@@ -497,7 +496,7 @@ final class BasicController extends Controller
'key' => sprintf('net-worth-in-%s', $this->primaryCurrency->code),
'title' => trans('firefly.box_net_worth_in_currency', ['currency' => $this->primaryCurrency->symbol]),
'monetary_value' => '0',
- 'currency_id' => (string) $this->primaryCurrency->id,
+ 'currency_id' => (string)$this->primaryCurrency->id,
'currency_code' => $this->primaryCurrency->code,
'currency_symbol' => $this->primaryCurrency->symbol,
'currency_decimal_places' => $this->primaryCurrency->decimal_places,
@@ -524,31 +523,31 @@ final class BasicController extends Controller
$currencies = [$this->primaryCurrency->id => $this->primaryCurrency];
if ($this->convertToPrimary) {
- $converter = new ExchangeRateConverter();
- $newPaidAmount = [[
- 'id' => $this->primaryCurrency->id,
- 'name' => $this->primaryCurrency->name,
- 'symbol' => $this->primaryCurrency->symbol,
- 'code' => $this->primaryCurrency->code,
- 'decimal_places' => $this->primaryCurrency->decimal_places,
- 'sum' => '0',
- ]];
+ $converter = new ExchangeRateConverter();
+ $newPaidAmount = [[
+ 'id' => $this->primaryCurrency->id,
+ 'name' => $this->primaryCurrency->name,
+ 'symbol' => $this->primaryCurrency->symbol,
+ 'code' => $this->primaryCurrency->code,
+ 'decimal_places' => $this->primaryCurrency->decimal_places,
+ 'sum' => '0',
+ ]];
$newUnpaidAmount = [[
- 'id' => $this->primaryCurrency->id,
- 'name' => $this->primaryCurrency->name,
- 'symbol' => $this->primaryCurrency->symbol,
- 'code' => $this->primaryCurrency->code,
- 'decimal_places' => $this->primaryCurrency->decimal_places,
- 'sum' => '0',
- ]];
+ 'id' => $this->primaryCurrency->id,
+ 'name' => $this->primaryCurrency->name,
+ 'symbol' => $this->primaryCurrency->symbol,
+ 'code' => $this->primaryCurrency->code,
+ 'decimal_places' => $this->primaryCurrency->decimal_places,
+ 'sum' => '0',
+ ]];
foreach ([$paidAmount, $unpaidAmount] as $index => $array) {
foreach ($array as $item) {
- $currencyId = (int) $item['id'];
+ $currencyId = (int)$item['id'];
if (0 === $index) {
// paid amount
if ($currencyId === $this->primaryCurrency->id) {
- $newPaidAmount[0]['sum'] = bcadd($newPaidAmount[0]['sum'], (string) $item['sum']);
+ $newPaidAmount[0]['sum'] = bcadd($newPaidAmount[0]['sum'], (string)$item['sum']);
continue;
}
@@ -560,35 +559,35 @@ final class BasicController extends Controller
}
// unpaid amount
if ($currencyId === $this->primaryCurrency->id) {
- $newUnpaidAmount[0]['sum'] = bcadd($newUnpaidAmount[0]['sum'], (string) $item['sum']);
+ $newUnpaidAmount[0]['sum'] = bcadd($newUnpaidAmount[0]['sum'], (string)$item['sum']);
continue;
}
- $currencies[$currencyId] ??= $this->currencyRepos->find($currencyId);
+ $currencies[$currencyId] ??= $this->currencyRepos->find($currencyId);
$convertedAmount = $converter->convert($currencies[$currencyId], $this->primaryCurrency, $start, $item['sum']);
$newUnpaidAmount[0]['sum'] = bcadd($newUnpaidAmount[0]['sum'], $convertedAmount);
}
}
- $paidAmount = $newPaidAmount;
- $unpaidAmount = $newUnpaidAmount;
+ $paidAmount = $newPaidAmount;
+ $unpaidAmount = $newUnpaidAmount;
}
// var_dump($paidAmount);
// var_dump($unpaidAmount);
// exit;
- $return = [];
+ $return = [];
/**
* @var array $info
*/
foreach ($paidAmount as $info) {
- $amount = bcmul((string) $info['sum'], '-1');
+ $amount = bcmul((string)$info['sum'], '-1');
$return[] = [
'key' => sprintf('bills-paid-in-%s', $info['code']),
'title' => trans('firefly.box_bill_paid_in_currency', ['currency' => $info['symbol']]),
'monetary_value' => $amount,
- 'currency_id' => (string) $info['id'],
+ 'currency_id' => (string)$info['id'],
'currency_code' => $info['code'],
'currency_symbol' => $info['symbol'],
'currency_decimal_places' => $info['decimal_places'],
@@ -602,12 +601,12 @@ final class BasicController extends Controller
* @var array $info
*/
foreach ($unpaidAmount as $info) {
- $amount = bcmul((string) $info['sum'], '-1');
+ $amount = bcmul((string)$info['sum'], '-1');
$return[] = [
'key' => sprintf('bills-unpaid-in-%s', $info['code']),
'title' => trans('firefly.box_bill_unpaid_in_currency', ['currency' => $info['symbol']]),
'monetary_value' => $amount,
- 'currency_id' => (string) $info['id'],
+ 'currency_id' => (string)$info['id'],
'currency_code' => $info['code'],
'currency_symbol' => $info['symbol'],
'currency_decimal_places' => $info['decimal_places'],
@@ -626,7 +625,7 @@ final class BasicController extends Controller
'key' => sprintf('bills-paid-in-%s', $currency->code),
'title' => trans('firefly.box_bill_paid_in_currency', ['currency' => $currency->symbol]),
'monetary_value' => '0',
- 'currency_id' => (string) $currency->id,
+ 'currency_id' => (string)$currency->id,
'currency_code' => $currency->code,
'currency_symbol' => $currency->symbol,
'currency_decimal_places' => $currency->decimal_places,
@@ -638,7 +637,7 @@ final class BasicController extends Controller
'key' => sprintf('bills-unpaid-in-%s', $currency->code),
'title' => trans('firefly.box_bill_unpaid_in_currency', ['currency' => $currency->symbol]),
'monetary_value' => '0',
- 'currency_id' => (string) $currency->id,
+ 'currency_id' => (string)$currency->id,
'currency_code' => $currency->code,
'currency_symbol' => $currency->symbol,
'currency_decimal_places' => $currency->decimal_places,
diff --git a/app/Api/V1/Controllers/System/AboutController.php b/app/Api/V1/Controllers/System/AboutController.php
index 7157d9266d..25e06ca644 100644
--- a/app/Api/V1/Controllers/System/AboutController.php
+++ b/app/Api/V1/Controllers/System/AboutController.php
@@ -69,13 +69,13 @@ final class AboutController extends Controller
*/
public function user(): JsonResponse
{
- $manager = $this->getManager();
+ $manager = $this->getManager();
/** @var UserTransformer $transformer */
$transformer = app(UserTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item(auth()->user(), $transformer, 'users');
+ $resource = new Item(auth()->user(), $transformer, 'users');
return response()->api($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/System/BatchController.php b/app/Api/V1/Controllers/System/BatchController.php
index a4172a7e1f..96dd1ce1e2 100644
--- a/app/Api/V1/Controllers/System/BatchController.php
+++ b/app/Api/V1/Controllers/System/BatchController.php
@@ -54,7 +54,7 @@ final class BatchController extends Controller
public function finishBatch(Request $request): JsonResponse
{
Log::debug('Now in finishBatch.');
- $journals = $this->repository->getUncompletedJournals();
+ $journals = $this->repository->getUncompletedJournals();
if (0 === count($journals)) {
Log::debug('Counted zero journals, return.');
@@ -63,8 +63,8 @@ final class BatchController extends Controller
Log::debug(sprintf('Counted %d journals.', count($journals)));
/** @var null|TransactionJournal $first */
- $first = $journals->first();
- $group = $first?->transactionGroup;
+ $first = $journals->first();
+ $group = $first?->transactionGroup;
if (null === $group) {
Log::debug('First group is NULL.');
diff --git a/app/Api/V1/Controllers/System/ConfigurationController.php b/app/Api/V1/Controllers/System/ConfigurationController.php
index ee8457fecd..f5a981a3ce 100644
--- a/app/Api/V1/Controllers/System/ConfigurationController.php
+++ b/app/Api/V1/Controllers/System/ConfigurationController.php
@@ -102,7 +102,7 @@ final class ConfigurationController extends Controller
}
// fallback
- $data = [
+ $data = [
'title' => $configKey,
'value' => config($shortKey),
'editable' => false,
@@ -159,9 +159,9 @@ final class ConfigurationController extends Controller
return [
'is_demo_site' => $isDemoSite?->data,
- 'permission_update_check' => null === $updateCheck ? null : (int) $updateCheck->data,
+ 'permission_update_check' => null === $updateCheck ? null : (int)$updateCheck->data,
'single_user_mode' => $singleUser?->data,
- 'last_update_check' => null === $lastCheck ? null : (int) $lastCheck->data,
+ 'last_update_check' => null === $lastCheck ? null : (int)$lastCheck->data,
'enable_exchange_rates' => $enableExchangeRates?->data,
'use_running_balance' => $useRunningBalance?->data,
'enable_external_map' => $enableExternalMap?->data,
diff --git a/app/Api/V1/Controllers/System/CronController.php b/app/Api/V1/Controllers/System/CronController.php
index fc54231269..a095b222d1 100644
--- a/app/Api/V1/Controllers/System/CronController.php
+++ b/app/Api/V1/Controllers/System/CronController.php
@@ -43,8 +43,8 @@ final class CronController extends Controller
public function cron(CronRequest $request, #[SensitiveParameter] string $cliToken): JsonResponse
{
CLIToken::routeBinder($cliToken, $request->route());
- $config = $request->getAll();
- $user = CLIToken::findUserByToken($cliToken);
+ $config = $request->getAll();
+ $user = CLIToken::findUserByToken($cliToken);
Log::debug(sprintf('Now in %s', __METHOD__));
Log::debug(sprintf('Date is %s', $config['date']->toIsoString()));
@@ -54,8 +54,8 @@ final class CronController extends Controller
if (true === AppConfiguration::get('enable_external_rates', config('cer.download_enabled'))->data) {
$return['exchange_rates'] = $this->exchangeRatesCronJob($user, $config['force'], $config['date']);
}
- $return['bill_notifications'] = $this->billWarningCronJob($user, $config['force'], $config['date']);
- $return['webhooks'] = $this->webhookCronJob($user, $config['force'], $config['date']);
+ $return['bill_notifications'] = $this->billWarningCronJob($user, $config['force'], $config['date']);
+ $return['webhooks'] = $this->webhookCronJob($user, $config['force'], $config['date']);
return response()->api($return);
}
diff --git a/app/Api/V1/Controllers/System/UserController.php b/app/Api/V1/Controllers/System/UserController.php
index 4d42348d48..3d6aeebb52 100644
--- a/app/Api/V1/Controllers/System/UserController.php
+++ b/app/Api/V1/Controllers/System/UserController.php
@@ -90,24 +90,24 @@ final class UserController extends Controller
public function index(): JsonResponse
{
// user preferences
- $pageSize = $this->parameters->get('limit');
- $manager = $this->getManager();
+ $pageSize = $this->parameters->get('limit');
+ $manager = $this->getManager();
// build collection
- $collection = $this->repository->all();
- $count = $collection->count();
- $users = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
+ $collection = $this->repository->all();
+ $count = $collection->count();
+ $users = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
// make paginator:
- $paginator = new LengthAwarePaginator($users, $count, $pageSize, $this->parameters->get('page'));
- $paginator->setPath(route('api.v1.users.index').$this->buildParams());
+ $paginator = new LengthAwarePaginator($users, $count, $pageSize, $this->parameters->get('page'));
+ $paginator->setPath(route('api.v1.users.index') . $this->buildParams());
// make resource
/** @var UserTransformer $transformer */
$transformer = app(UserTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($users, $transformer, 'users');
+ $resource = new FractalCollection($users, $transformer, 'users');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -122,14 +122,14 @@ final class UserController extends Controller
public function show(User $user): JsonResponse
{
// make manager
- $manager = $this->getManager();
+ $manager = $this->getManager();
// make resource
/** @var UserTransformer $transformer */
$transformer = app(UserTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($user, $transformer, 'users');
+ $resource = new Item($user, $transformer, 'users');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
@@ -142,21 +142,21 @@ final class UserController extends Controller
*/
public function store(UserStoreRequest $request): JsonResponse
{
- $data = $request->getAll();
- $user = $this->repository->store($data);
+ $data = $request->getAll();
+ $user = $this->repository->store($data);
Log::info(sprintf('Registered new user %s', $user->email));
- $owner = new OwnerNotifiable();
+ $owner = new OwnerNotifiable();
event(new NewUserRegistered($owner, $user));
- $manager = $this->getManager();
+ $manager = $this->getManager();
// make resource
/** @var UserTransformer $transformer */
$transformer = app(UserTransformer::class);
- $resource = new Item($user, $transformer, 'users');
+ $resource = new Item($user, $transformer, 'users');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
@@ -169,7 +169,7 @@ final class UserController extends Controller
*/
public function update(UserUpdateRequest $request, User $user): JsonResponse
{
- $data = $request->getAll();
+ $data = $request->getAll();
// can only update 'blocked' when user is admin.
if (!$this->repository->hasRole(auth()->user(), 'owner')) {
@@ -177,15 +177,15 @@ final class UserController extends Controller
unset($data['blocked'], $data['blocked_code']);
}
- $user = $this->repository->update($user, $data);
- $manager = $this->getManager();
+ $user = $this->repository->update($user, $data);
+ $manager = $this->getManager();
// make resource
/** @var UserTransformer $transformer */
$transformer = app(UserTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($user, $transformer, 'users');
+ $resource = new Item($user, $transformer, 'users');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/User/PreferencesController.php b/app/Api/V1/Controllers/User/PreferencesController.php
index dad237eb4e..ebfa16cb95 100644
--- a/app/Api/V1/Controllers/User/PreferencesController.php
+++ b/app/Api/V1/Controllers/User/PreferencesController.php
@@ -61,14 +61,14 @@ final class PreferencesController extends Controller
$preferences = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
// make paginator:
- $paginator = new LengthAwarePaginator($preferences, $count, $pageSize, $this->parameters->get('page'));
- $paginator->setPath(route('api.v1.preferences.index').$this->buildParams());
+ $paginator = new LengthAwarePaginator($preferences, $count, $pageSize, $this->parameters->get('page'));
+ $paginator->setPath(route('api.v1.preferences.index') . $this->buildParams());
/** @var PreferenceTransformer $transformer */
$transformer = app(PreferenceTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($preferences, $transformer, self::RESOURCE_KEY);
+ $resource = new FractalCollection($preferences, $transformer, self::RESOURCE_KEY);
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -82,7 +82,7 @@ final class PreferencesController extends Controller
*/
public function show(Preference $preference): JsonResponse
{
- $manager = $this->getManager();
+ $manager = $this->getManager();
if ('currencyPreference' === $preference->name) {
throw new FireflyException('Please use api/v1/currencies/primary instead.');
@@ -92,25 +92,25 @@ final class PreferencesController extends Controller
$transformer = app(PreferenceTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($preference, $transformer, 'preferences');
+ $resource = new Item($preference, $transformer, 'preferences');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
public function showList(Collection $preferenceList): JsonResponse
{
- $manager = $this->getManager();
- $count = $preferenceList->count();
- $names = implode(',', $preferenceList->pluck('name')->toArray());
+ $manager = $this->getManager();
+ $count = $preferenceList->count();
+ $names = implode(',', $preferenceList->pluck('name')->toArray());
// make paginator:
- $paginator = new LengthAwarePaginator($preferenceList, $count, 31_337, 1);
- $paginator->setPath(route('api.v1.preferences-list.show', [$names]).$this->buildParams());
+ $paginator = new LengthAwarePaginator($preferenceList, $count, 31_337, 1);
+ $paginator->setPath(route('api.v1.preferences-list.show', [$names]) . $this->buildParams());
/** @var PreferenceTransformer $transformer */
$transformer = app(PreferenceTransformer::class);
- $resource = new FractalCollection($preferenceList, $transformer, self::RESOURCE_KEY);
+ $resource = new FractalCollection($preferenceList, $transformer, self::RESOURCE_KEY);
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -124,19 +124,25 @@ final class PreferencesController extends Controller
*/
public function store(PreferenceStoreRequest $request): JsonResponse
{
- $manager = $this->getManager();
- $data = $request->getAll();
+ $manager = $this->getManager();
+ $data = $request->getAll();
if ('currencyPreference' === $data['name']) {
throw new FireflyException('Please use api/v1/currencies/default instead.');
}
+ if ('language' === $data['name'] && !in_array($data['data'], array_keys(config('firefly.languages')))) {
+ throw new FireflyException('Invalid language specified.');
+ }
+ if ('locale' === $data['name'] && 'equal' !== $data['data'] && false === preg_match('/^[A-Za-z0-9_.@-]+$/', $data['data'])) {
+ throw new FireflyException('Invalid locale specified.');
+ }
- $pref = Preferences::set($data['name'], $data['data']);
+ $pref = Preferences::set($data['name'], $data['data']);
/** @var PreferenceTransformer $transformer */
$transformer = app(PreferenceTransformer::class);
- $resource = new Item($pref, $transformer, 'preferences');
+ $resource = new Item($pref, $transformer, 'preferences');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
@@ -153,15 +159,15 @@ final class PreferencesController extends Controller
throw new FireflyException('Please use api/v1/currencies/primary instead.');
}
- $manager = $this->getManager();
- $data = $request->getAll();
- $pref = Preferences::set($preference->name, $data['data']);
+ $manager = $this->getManager();
+ $data = $request->getAll();
+ $pref = Preferences::set($preference->name, $data['data']);
/** @var PreferenceTransformer $transformer */
$transformer = app(PreferenceTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($pref, $transformer, 'preferences');
+ $resource = new Item($pref, $transformer, 'preferences');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Webhook/AttemptController.php b/app/Api/V1/Controllers/Webhook/AttemptController.php
index 3e4c6a2d20..49745d4f17 100644
--- a/app/Api/V1/Controllers/Webhook/AttemptController.php
+++ b/app/Api/V1/Controllers/Webhook/AttemptController.php
@@ -73,30 +73,30 @@ final class AttemptController extends Controller
}
if (false === AppConfiguration::get('allow_webhooks', config('firefly.allow_webhooks'))->data) {
Log::channel('audit')->warning(sprintf(
- 'User lists webhook attempts of webhook #%d and message #%d, but webhooks are DISABLED.',
- $webhook->id,
- $message->id
- ));
+ 'User lists webhook attempts of webhook #%d and message #%d, but webhooks are DISABLED.',
+ $webhook->id,
+ $message->id
+ ));
throw new NotFoundHttpException('Webhooks are not enabled.');
}
Log::channel('audit')->info(sprintf('User lists webhook attempts of webhook #%d and message #%d.', $webhook->id, $message->id));
- $manager = $this->getManager();
- $pageSize = $this->parameters->get('limit');
- $collection = $this->repository->getAttempts($message);
- $count = $collection->count();
- $attempts = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
+ $manager = $this->getManager();
+ $pageSize = $this->parameters->get('limit');
+ $collection = $this->repository->getAttempts($message);
+ $count = $collection->count();
+ $attempts = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
// make paginator:
- $paginator = new LengthAwarePaginator($attempts, $count, $pageSize, $this->parameters->get('page'));
- $paginator->setPath(route('api.v1.webhooks.attempts.index', [$webhook->id, $message->id]).$this->buildParams());
+ $paginator = new LengthAwarePaginator($attempts, $count, $pageSize, $this->parameters->get('page'));
+ $paginator->setPath(route('api.v1.webhooks.attempts.index', [$webhook->id, $message->id]) . $this->buildParams());
/** @var WebhookAttemptTransformer $transformer */
$transformer = app(WebhookAttemptTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($attempts, $transformer, 'webhook_attempts');
+ $resource = new FractalCollection($attempts, $transformer, 'webhook_attempts');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -121,23 +121,23 @@ final class AttemptController extends Controller
if (false === AppConfiguration::get('allow_webhooks', config('firefly.allow_webhooks'))->data) {
Log::channel('audit')->warning(sprintf(
- 'User views single webhook attempt #%d of webhook #%d and message #%d, but webhooks are DISABLED',
- $attempt->id,
- $webhook->id,
- $message->id
- ));
+ 'User views single webhook attempt #%d of webhook #%d and message #%d, but webhooks are DISABLED',
+ $attempt->id,
+ $webhook->id,
+ $message->id
+ ));
throw new NotFoundHttpException('Webhooks are not enabled.');
}
Log::channel('audit')->info(sprintf('User views single webhook attempt #%d of webhook #%d and message #%d.', $attempt->id, $webhook->id, $message->id));
- $manager = $this->getManager();
+ $manager = $this->getManager();
/** @var WebhookAttemptTransformer $transformer */
$transformer = app(WebhookAttemptTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($attempt, $transformer, self::RESOURCE_KEY);
+ $resource = new Item($attempt, $transformer, self::RESOURCE_KEY);
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Webhook/DestroyController.php b/app/Api/V1/Controllers/Webhook/DestroyController.php
index 25855845b5..424b52f0b1 100644
--- a/app/Api/V1/Controllers/Webhook/DestroyController.php
+++ b/app/Api/V1/Controllers/Webhook/DestroyController.php
@@ -94,11 +94,11 @@ final class DestroyController extends Controller
if (false === AppConfiguration::get('allow_webhooks', config('firefly.allow_webhooks'))->data) {
Log::channel('audit')->warning(sprintf(
- 'User tries to destroy webhook #%d, message #%d, attempt #%d, but webhooks are DISABLED.',
- $webhook->id,
- $message->id,
- $attempt->id
- ));
+ 'User tries to destroy webhook #%d, message #%d, attempt #%d, but webhooks are DISABLED.',
+ $webhook->id,
+ $message->id,
+ $attempt->id
+ ));
throw new NotFoundHttpException('Webhooks are not enabled.');
}
diff --git a/app/Api/V1/Controllers/Webhook/MessageController.php b/app/Api/V1/Controllers/Webhook/MessageController.php
index 5208666a70..9d3f5486f3 100644
--- a/app/Api/V1/Controllers/Webhook/MessageController.php
+++ b/app/Api/V1/Controllers/Webhook/MessageController.php
@@ -71,22 +71,22 @@ final class MessageController extends Controller
throw new NotFoundHttpException('Webhooks are not enabled.');
}
Log::channel('audit')->info(sprintf('User views messages of webhook #%d.', $webhook->id));
- $manager = $this->getManager();
- $pageSize = $this->parameters->get('limit');
- $collection = $this->repository->getMessages($webhook);
+ $manager = $this->getManager();
+ $pageSize = $this->parameters->get('limit');
+ $collection = $this->repository->getMessages($webhook);
- $count = $collection->count();
- $messages = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
+ $count = $collection->count();
+ $messages = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
// make paginator:
- $paginator = new LengthAwarePaginator($messages, $count, $pageSize, $this->parameters->get('page'));
- $paginator->setPath(route('api.v1.webhooks.messages.index', [$webhook->id]).$this->buildParams());
+ $paginator = new LengthAwarePaginator($messages, $count, $pageSize, $this->parameters->get('page'));
+ $paginator->setPath(route('api.v1.webhooks.messages.index', [$webhook->id]) . $this->buildParams());
/** @var WebhookMessageTransformer $transformer */
$transformer = app(WebhookMessageTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($messages, $transformer, 'webhook_messages');
+ $resource = new FractalCollection($messages, $transformer, 'webhook_messages');
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -113,12 +113,12 @@ final class MessageController extends Controller
Log::channel('audit')->info(sprintf('User views message #%d of webhook #%d.', $message->id, $webhook->id));
- $manager = $this->getManager();
+ $manager = $this->getManager();
/** @var WebhookMessageTransformer $transformer */
$transformer = app(WebhookMessageTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($message, $transformer, self::RESOURCE_KEY);
+ $resource = new Item($message, $transformer, self::RESOURCE_KEY);
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Webhook/ShowController.php b/app/Api/V1/Controllers/Webhook/ShowController.php
index 4c44f7e753..cd66248717 100644
--- a/app/Api/V1/Controllers/Webhook/ShowController.php
+++ b/app/Api/V1/Controllers/Webhook/ShowController.php
@@ -79,28 +79,28 @@ final class ShowController extends Controller
}
Log::channel('audit')->info('User views all webhooks.');
- $manager = $this->getManager();
- $collection = $this->repository->all();
- $pageSize = $this->parameters->get('limit');
- $count = $collection->count();
- $webhooks = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
+ $manager = $this->getManager();
+ $collection = $this->repository->all();
+ $pageSize = $this->parameters->get('limit');
+ $count = $collection->count();
+ $webhooks = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
// make paginator:
- $paginator = new LengthAwarePaginator($webhooks, $count, $pageSize, $this->parameters->get('page'));
- $paginator->setPath(route('api.v1.webhooks.index').$this->buildParams());
+ $paginator = new LengthAwarePaginator($webhooks, $count, $pageSize, $this->parameters->get('page'));
+ $paginator->setPath(route('api.v1.webhooks.index') . $this->buildParams());
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new WebhookEnrichment();
+ $admin = auth()->user();
+ $enrichment = new WebhookEnrichment();
$enrichment->setUser($admin);
- $webhooks = $enrichment->enrich($webhooks);
+ $webhooks = $enrichment->enrich($webhooks);
/** @var WebhookTransformer $transformer */
$transformer = app(WebhookTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new FractalCollection($webhooks, $transformer, self::RESOURCE_KEY);
+ $resource = new FractalCollection($webhooks, $transformer, self::RESOURCE_KEY);
$resource->setPaginator(new IlluminatePaginatorAdapter($paginator));
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
@@ -121,19 +121,19 @@ final class ShowController extends Controller
}
Log::channel('audit')->info(sprintf('User views webhook #%d.', $webhook->id));
- $manager = $this->getManager();
+ $manager = $this->getManager();
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new WebhookEnrichment();
+ $admin = auth()->user();
+ $enrichment = new WebhookEnrichment();
$enrichment->setUser($admin);
- $webhook = $enrichment->enrichSingle($webhook);
+ $webhook = $enrichment->enrichSingle($webhook);
/** @var WebhookTransformer $transformer */
$transformer = app(WebhookTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($webhook, $transformer, self::RESOURCE_KEY);
+ $resource = new Item($webhook, $transformer, self::RESOURCE_KEY);
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
@@ -148,10 +148,10 @@ final class ShowController extends Controller
{
if (false === AppConfiguration::get('allow_webhooks', config('firefly.allow_webhooks'))->data) {
Log::channel('audit')->info(sprintf(
- 'User tries to trigger webhook #%d on transaction group #%d, but webhooks are DISABLED.',
- $webhook->id,
- $group->id
- ));
+ 'User tries to trigger webhook #%d on transaction group #%d, but webhooks are DISABLED.',
+ $webhook->id,
+ $group->id
+ ));
throw new NotFoundHttpException('Webhooks are not enabled.');
}
@@ -166,7 +166,7 @@ final class ShowController extends Controller
$engine->setUser(auth()->user());
// tell the generator which trigger it should look for
- $engine->setTrigger(WebhookTrigger::tryFrom((int) $trigger->key));
+ $engine->setTrigger(WebhookTrigger::tryFrom((int)$trigger->key));
// tell the generator which objects to process
$engine->setObjects(new Collection()->push($group));
// set the webhook to trigger
diff --git a/app/Api/V1/Controllers/Webhook/StoreController.php b/app/Api/V1/Controllers/Webhook/StoreController.php
index 25a334f807..e9712b1108 100644
--- a/app/Api/V1/Controllers/Webhook/StoreController.php
+++ b/app/Api/V1/Controllers/Webhook/StoreController.php
@@ -62,23 +62,23 @@ final class StoreController extends Controller
*/
public function store(CreateRequest $request): JsonResponse
{
- $data = $request->getData();
+ $data = $request->getData();
if (false === AppConfiguration::get('allow_webhooks', config('firefly.allow_webhooks'))->data) {
Log::channel('audit')->info('User tries to store new webhook, but webhooks are DISABLED.', $data);
throw new NotFoundHttpException('Webhooks are not enabled.');
}
- $webhook = $this->repository->store($data);
+ $webhook = $this->repository->store($data);
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new WebhookEnrichment();
+ $admin = auth()->user();
+ $enrichment = new WebhookEnrichment();
$enrichment->setUser($admin);
- $webhook = $enrichment->enrichSingle($webhook);
+ $webhook = $enrichment->enrichSingle($webhook);
- $manager = $this->getManager();
+ $manager = $this->getManager();
Log::channel('audit')->info('User stores new webhook', $data);
@@ -86,7 +86,7 @@ final class StoreController extends Controller
$transformer = app(WebhookTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($webhook, $transformer, 'webhooks');
+ $resource = new Item($webhook, $transformer, 'webhooks');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Controllers/Webhook/UpdateController.php b/app/Api/V1/Controllers/Webhook/UpdateController.php
index b2c8efbfeb..d1a12daa25 100644
--- a/app/Api/V1/Controllers/Webhook/UpdateController.php
+++ b/app/Api/V1/Controllers/Webhook/UpdateController.php
@@ -61,24 +61,24 @@ final class UpdateController extends Controller
*/
public function update(Webhook $webhook, UpdateRequest $request): JsonResponse
{
- $data = $request->getData();
+ $data = $request->getData();
if (false === AppConfiguration::get('allow_webhooks', config('firefly.allow_webhooks'))->data) {
Log::channel('audit')->info(sprintf('User tries to update webhook #%d, but webhooks are DISABLED.', $webhook->id), $data);
throw new NotFoundHttpException('Webhooks are not enabled.');
}
- $webhook = $this->repository->update($webhook, $data);
- $manager = $this->getManager();
+ $webhook = $this->repository->update($webhook, $data);
+ $manager = $this->getManager();
// enrich
/** @var User $admin */
- $admin = auth()->user();
- $enrichment = new WebhookEnrichment();
+ $admin = auth()->user();
+ $enrichment = new WebhookEnrichment();
$enrichment->setUser($admin);
/** @var Webhook $webhook */
- $webhook = $enrichment->enrichSingle($webhook);
+ $webhook = $enrichment->enrichSingle($webhook);
Log::channel('audit')->info(sprintf('User updates webhook #%d', $webhook->id), $data);
@@ -86,7 +86,7 @@ final class UpdateController extends Controller
$transformer = app(WebhookTransformer::class);
$transformer->setParameters($this->parameters);
- $resource = new Item($webhook, $transformer, 'webhooks');
+ $resource = new Item($webhook, $transformer, 'webhooks');
return response()->json($manager->createData($resource)->toArray())->header('Content-Type', self::CONTENT_TYPE);
}
diff --git a/app/Api/V1/Requests/AggregateFormRequest.php b/app/Api/V1/Requests/AggregateFormRequest.php
index 9409d33382..8298d88a92 100644
--- a/app/Api/V1/Requests/AggregateFormRequest.php
+++ b/app/Api/V1/Requests/AggregateFormRequest.php
@@ -31,13 +31,12 @@ use RuntimeException;
abstract class AggregateFormRequest extends ApiRequest
{
+ #[Override]
+ protected array $acceptedRoles = [];
/**
* @var Request[]
*/
- protected array $requests = [];
-
- #[Override]
- protected array $acceptedRoles = [];
+ protected array $requests = [];
#[Override]
public function initialize(
@@ -47,8 +46,9 @@ abstract class AggregateFormRequest extends ApiRequest
array $cookies = [],
array $files = [],
array $server = [],
- $content = null
- ): void {
+ $content = null
+ ): void
+ {
parent::initialize($query, $request, $attributes, $cookies, $files, $server, $content);
// instantiate all subrequests and share current requests' bags with them
@@ -56,7 +56,7 @@ abstract class AggregateFormRequest extends ApiRequest
/** @var array|string $config */
foreach ($this->getRequests() as $config) {
- $requestClass = is_array($config) ? array_shift($config) : $config;
+ $requestClass = is_array($config) ? array_shift($config) : $config;
if (!is_a($requestClass, Request::class, true)) {
throw new RuntimeException('getRequests() must return class-strings of subclasses of Request');
@@ -86,7 +86,7 @@ abstract class AggregateFormRequest extends ApiRequest
// check all subrequests for rules and combine them
return array_reduce(
$this->requests,
- static fn (array $rules, FormRequest $request): array => $rules + (method_exists($request, 'rules') ? $request->rules() : []),
+ static fn(array $rules, FormRequest $request): array => $rules + (method_exists($request, 'rules') ? $request->rules() : []),
[]
);
}
diff --git a/app/Api/V1/Requests/ApiRequest.php b/app/Api/V1/Requests/ApiRequest.php
index cec26a5a73..ea08010725 100644
--- a/app/Api/V1/Requests/ApiRequest.php
+++ b/app/Api/V1/Requests/ApiRequest.php
@@ -34,7 +34,7 @@ class ApiRequest extends FormRequest
protected array $acceptedRoles = [];
- protected string $required = '';
+ protected string $required = '';
public function handleConfig(array $config): void
{
diff --git a/app/Api/V1/Requests/Autocomplete/AutocompleteRequest.php b/app/Api/V1/Requests/Autocomplete/AutocompleteRequest.php
index 4ab1ed1291..c923c7768a 100644
--- a/app/Api/V1/Requests/Autocomplete/AutocompleteRequest.php
+++ b/app/Api/V1/Requests/Autocomplete/AutocompleteRequest.php
@@ -52,7 +52,7 @@ class AutocompleteRequest extends FormRequest
// remove 'initial balance' from allowed types. its internal
$array = array_diff($array, [AccountTypeEnum::INITIAL_BALANCE->value, AccountTypeEnum::RECONCILIATION->value]);
- $date = $this->getCarbonDate('date') ?? today(config('app.timezone'));
+ $date = $this->getCarbonDate('date') ?? today(config('app.timezone'));
return ['types' => $array, 'query' => $this->convertString('query'), 'date' => $date->endOfDay()];
}
diff --git a/app/Api/V1/Requests/Data/Bulk/MoveTransactionsRequest.php b/app/Api/V1/Requests/Data/Bulk/MoveTransactionsRequest.php
index fdc3e77b44..64bcb267ee 100644
--- a/app/Api/V1/Requests/Data/Bulk/MoveTransactionsRequest.php
+++ b/app/Api/V1/Requests/Data/Bulk/MoveTransactionsRequest.php
@@ -74,15 +74,15 @@ class MoveTransactionsRequest extends FormRequest
private function validateMove(FireflyValidator $validator): void
{
- $data = $validator->getData();
- $repository = app(AccountRepositoryInterface::class);
+ $data = $validator->getData();
+ $repository = app(AccountRepositoryInterface::class);
$repository->setUser(auth()->user());
- $original = $repository->find((int) $data['original_account']);
- $destination = $repository->find((int) $data['destination_account']);
+ $original = $repository->find((int)$data['original_account']);
+ $destination = $repository->find((int)$data['destination_account']);
// not the same type:
if ($original->accountType->type !== $destination->accountType->type) {
- $validator->errors()->add('title', (string) trans('validation.same_account_type'));
+ $validator->errors()->add('title', (string)trans('validation.same_account_type'));
return;
}
@@ -92,7 +92,7 @@ class MoveTransactionsRequest extends FormRequest
// check different scenario's.
if (null === $originalCurrency xor null === $destinationCurrency) {
- $validator->errors()->add('title', (string) trans('validation.same_account_currency'));
+ $validator->errors()->add('title', (string)trans('validation.same_account_currency'));
return;
}
@@ -101,7 +101,7 @@ class MoveTransactionsRequest extends FormRequest
return;
}
if ($originalCurrency->code !== $destinationCurrency->code) {
- $validator->errors()->add('title', (string) trans('validation.same_account_currency'));
+ $validator->errors()->add('title', (string)trans('validation.same_account_currency'));
}
}
}
diff --git a/app/Api/V1/Requests/Data/Bulk/TransactionRequest.php b/app/Api/V1/Requests/Data/Bulk/TransactionRequest.php
index 93c1247a21..2ecba16283 100644
--- a/app/Api/V1/Requests/Data/Bulk/TransactionRequest.php
+++ b/app/Api/V1/Requests/Data/Bulk/TransactionRequest.php
@@ -33,7 +33,6 @@ use Illuminate\Contracts\Validation\Validator;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Log;
use JsonException;
-
use function Safe\json_decode;
/**
diff --git a/app/Api/V1/Requests/Data/DestroyRequest.php b/app/Api/V1/Requests/Data/DestroyRequest.php
index dc5b77c04c..c6c13ea99b 100644
--- a/app/Api/V1/Requests/Data/DestroyRequest.php
+++ b/app/Api/V1/Requests/Data/DestroyRequest.php
@@ -53,8 +53,8 @@ class DestroyRequest extends FormRequest
{
$valid
= 'budgets,bills,piggy_banks,rules,recurring,categories,tags,object_groups'
- .',accounts,asset_accounts,expense_accounts,revenue_accounts,liabilities,transactions,withdrawals,deposits,transfers'
- .',not_assets_liabilities';
+ . ',accounts,asset_accounts,expense_accounts,revenue_accounts,liabilities,transactions,withdrawals,deposits,transfers'
+ . ',not_assets_liabilities';
return ['objects' => sprintf('required|max:255|min:1|string|in:%s', $valid), 'unused' => 'in:true,false'];
}
diff --git a/app/Api/V1/Requests/Data/Export/ExportRequest.php b/app/Api/V1/Requests/Data/Export/ExportRequest.php
index aa3d8a0e8b..744417312e 100644
--- a/app/Api/V1/Requests/Data/Export/ExportRequest.php
+++ b/app/Api/V1/Requests/Data/Export/ExportRequest.php
@@ -43,18 +43,18 @@ class ExportRequest extends FormRequest
public function getAll(): array
{
- $result = [
+ $result = [
'start' => $this->getCarbonDate('start') ?? today(config('app.timezone'))->subYear(),
'end' => $this->getCarbonDate('end') ?? today(config('app.timezone')),
'type' => $this->convertString('type'),
];
- $parts = explode(',', $this->convertString('accounts'));
- $repository = app(AccountRepositoryInterface::class);
+ $parts = explode(',', $this->convertString('accounts'));
+ $repository = app(AccountRepositoryInterface::class);
$repository->setUser(auth()->user());
- $accounts = new Collection();
+ $accounts = new Collection();
foreach ($parts as $part) {
- $accountId = (int) $part;
+ $accountId = (int)$part;
if (0 !== $accountId) {
$account = $repository->find($accountId);
if (null !== $account && AccountTypeEnum::ASSET->value === $account->accountType->type) {
diff --git a/app/Api/V1/Requests/DateRequest.php b/app/Api/V1/Requests/DateRequest.php
index 6b9cd4956f..63588dcb32 100644
--- a/app/Api/V1/Requests/DateRequest.php
+++ b/app/Api/V1/Requests/DateRequest.php
@@ -30,7 +30,7 @@ class DateRequest extends ApiRequest
{
public function rules(): array
{
- return ['date' => 'date|after:1970-01-02|before:2038-01-17|'.$this->required];
+ return ['date' => 'date|after:1970-01-02|before:2038-01-17|' . $this->required];
}
public function withValidator(Validator $validator): void
@@ -39,13 +39,13 @@ class DateRequest extends ApiRequest
if (count($validator->failed()) > 0) {
return;
}
- $date = $this->getCarbonDate('date')?->endOfDay();
+ $date = $this->getCarbonDate('date')?->endOfDay();
// if we also have a range, date must be in that range
$start = $this->attributes->get('start');
$end = $this->attributes->get('end');
if ($date instanceof Carbon && $start instanceof Carbon && $end instanceof Carbon && !$date->between($start, $end)) {
- $validator->errors()->add('date', (string) trans('validation.between_date'));
+ $validator->errors()->add('date', (string)trans('validation.between_date'));
}
$this->attributes->set('date', $date);
diff --git a/app/Api/V1/Requests/Generic/ObjectTypeApiRequest.php b/app/Api/V1/Requests/Generic/ObjectTypeApiRequest.php
index f3ed08f188..00280ddfeb 100644
--- a/app/Api/V1/Requests/Generic/ObjectTypeApiRequest.php
+++ b/app/Api/V1/Requests/Generic/ObjectTypeApiRequest.php
@@ -57,7 +57,7 @@ class ObjectTypeApiRequest extends ApiRequest
public function rules(): array
{
- $rule = null;
+ $rule = null;
if (Account::class === $this->objectType) {
$rule = new IsValidAccountTypeList();
}
@@ -85,7 +85,7 @@ class ObjectTypeApiRequest extends ApiRequest
default:
$this->attributes->set('types', []);
- // no break
+ // no break
case Account::class:
$types = $this->mapAccountTypes($type);
diff --git a/app/Api/V1/Requests/Insight/GenericRequest.php b/app/Api/V1/Requests/Insight/GenericRequest.php
index a44eb1cf40..c0ca32acc7 100644
--- a/app/Api/V1/Requests/Insight/GenericRequest.php
+++ b/app/Api/V1/Requests/Insight/GenericRequest.php
@@ -70,8 +70,8 @@ class GenericRequest extends FormRequest
foreach ($this->accounts as $account) {
$type = $account->accountType->type;
if (in_array(
- $type,
- [AccountTypeEnum::ASSET->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value],
+ $type,
+ [AccountTypeEnum::ASSET->value, AccountTypeEnum::LOAN->value, AccountTypeEnum::DEBT->value, AccountTypeEnum::MORTGAGE->value],
strict: true
)) {
$return->push($account);
@@ -179,10 +179,10 @@ class GenericRequest extends FormRequest
}
$repository = app(AccountRepositoryInterface::class);
$repository->setUser(auth()->user());
- $array = $this->get('accounts');
+ $array = $this->get('accounts');
if (is_array($array)) {
foreach ($array as $accountId) {
- $accountId = (int) $accountId;
+ $accountId = (int)$accountId;
$account = $repository->find($accountId);
if (null !== $account) {
$this->accounts->push($account);
@@ -198,10 +198,10 @@ class GenericRequest extends FormRequest
}
$repository = app(BillRepositoryInterface::class);
$repository->setUser(auth()->user());
- $array = $this->get('bills');
+ $array = $this->get('bills');
if (is_array($array)) {
foreach ($array as $billId) {
- $billId = (int) $billId;
+ $billId = (int)$billId;
$bill = $repository->find($billId);
if (null !== $bill) {
$this->bills->push($bill);
@@ -217,10 +217,10 @@ class GenericRequest extends FormRequest
}
$repository = app(BudgetRepositoryInterface::class);
$repository->setUser(auth()->user());
- $array = $this->get('budgets');
+ $array = $this->get('budgets');
if (is_array($array)) {
foreach ($array as $budgetId) {
- $budgetId = (int) $budgetId;
+ $budgetId = (int)$budgetId;
$budget = $repository->find($budgetId);
if (null !== $budget) {
$this->budgets->push($budget);
@@ -236,10 +236,10 @@ class GenericRequest extends FormRequest
}
$repository = app(CategoryRepositoryInterface::class);
$repository->setUser(auth()->user());
- $array = $this->get('categories');
+ $array = $this->get('categories');
if (is_array($array)) {
foreach ($array as $categoryId) {
- $categoryId = (int) $categoryId;
+ $categoryId = (int)$categoryId;
$category = $repository->find($categoryId);
if (null !== $category) {
$this->categories->push($category);
@@ -255,10 +255,10 @@ class GenericRequest extends FormRequest
}
$repository = app(TagRepositoryInterface::class);
$repository->setUser(auth()->user());
- $array = $this->get('tags');
+ $array = $this->get('tags');
if (is_array($array)) {
foreach ($array as $tagId) {
- $tagId = (int) $tagId;
+ $tagId = (int)$tagId;
$tag = $repository->find($tagId);
if (null !== $tag) {
$this->tags->push($tag);
diff --git a/app/Api/V1/Requests/Models/Account/StoreRequest.php b/app/Api/V1/Requests/Models/Account/StoreRequest.php
index 1db2bfb5aa..75199833fd 100644
--- a/app/Api/V1/Requests/Models/Account/StoreRequest.php
+++ b/app/Api/V1/Requests/Models/Account/StoreRequest.php
@@ -55,7 +55,7 @@ class StoreRequest extends FormRequest
if (null !== $this->get('include_net_worth')) {
$includeNetWorth = $this->boolean('include_net_worth');
}
- $data = [
+ $data = [
'name' => $this->convertString('name'),
'active' => $active,
'include_net_worth' => $includeNetWorth,
@@ -78,7 +78,7 @@ class StoreRequest extends FormRequest
'interest_period' => $this->convertString('interest_period'),
];
// append location information.
- $data = $this->appendLocationData($data, null);
+ $data = $this->appendLocationData($data, null);
if ('liability' === $data['account_type_name'] || 'liabilities' === $data['account_type_name']) {
$data['account_type_name'] = $this->convertString('liability_type');
diff --git a/app/Api/V1/Requests/Models/Account/UpdateRequest.php b/app/Api/V1/Requests/Models/Account/UpdateRequest.php
index 5d184f2969..9d76b48741 100644
--- a/app/Api/V1/Requests/Models/Account/UpdateRequest.php
+++ b/app/Api/V1/Requests/Models/Account/UpdateRequest.php
@@ -91,7 +91,7 @@ class UpdateRequest extends FormRequest
$types = implode(',', array_keys(config('firefly.subTitlesByIdentifier')));
$ccPaymentTypes = implode(',', array_keys(config('firefly.ccTypes')));
- $rules = [
+ $rules = [
'name' => sprintf('min:1|max:1024|uniqueAccountForUser:%d', $account->id),
'type' => sprintf('in:%s', $types),
'iban' => ['iban', 'nullable', new UniqueIban($account, $this->convertString('type'))],
@@ -125,10 +125,10 @@ class UpdateRequest extends FormRequest
{
$validator->after(function (FireflyValidator $validator): void {
// validate start before end only if both are there.
- $data = $validator->getData();
+ $data = $validator->getData();
/** @var Account $account */
- $account = $this->route()->parameter('account');
+ $account = $this->route()->parameter('account');
/** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class);
@@ -137,10 +137,10 @@ class UpdateRequest extends FormRequest
// how many piggies are attached?
$piggyBanks = $account->piggyBanks()->count();
if ($piggyBanks > 0 && array_key_exists('currency_code', $data) && $data['currency_code'] !== $currency->code) {
- $validator->errors()->add('currency_code', (string) trans('validation.piggy_no_change_currency'));
+ $validator->errors()->add('currency_code', (string)trans('validation.piggy_no_change_currency'));
}
- if ($piggyBanks > 0 && array_key_exists('currency_id', $data) && (int) $data['currency_id'] !== $currency->id) {
- $validator->errors()->add('currency_id', (string) trans('validation.piggy_no_change_currency'));
+ if ($piggyBanks > 0 && array_key_exists('currency_id', $data) && (int)$data['currency_id'] !== $currency->id) {
+ $validator->errors()->add('currency_id', (string)trans('validation.piggy_no_change_currency'));
}
});
if ($validator->fails()) {
diff --git a/app/Api/V1/Requests/Models/Attachment/StoreRequest.php b/app/Api/V1/Requests/Models/Attachment/StoreRequest.php
index 63fe2a69c6..61e545c284 100644
--- a/app/Api/V1/Requests/Models/Attachment/StoreRequest.php
+++ b/app/Api/V1/Requests/Models/Attachment/StoreRequest.php
@@ -59,7 +59,7 @@ class StoreRequest extends FormRequest
public function rules(): array
{
$models = config('firefly.valid_attachment_models');
- $models = array_map(static fn (string $className): string => str_replace('FireflyIII\Models\\', '', $className), $models);
+ $models = array_map(static fn(string $className): string => str_replace('FireflyIII\Models\\', '', $className), $models);
$models = implode(',', $models);
$model = $this->convertString('attachable_type');
diff --git a/app/Api/V1/Requests/Models/Attachment/UpdateRequest.php b/app/Api/V1/Requests/Models/Attachment/UpdateRequest.php
index b230c226dc..59266f4490 100644
--- a/app/Api/V1/Requests/Models/Attachment/UpdateRequest.php
+++ b/app/Api/V1/Requests/Models/Attachment/UpdateRequest.php
@@ -61,7 +61,7 @@ class UpdateRequest extends FormRequest
public function rules(): array
{
$models = config('firefly.valid_attachment_models');
- $models = array_map(static fn (string $className): string => str_replace('FireflyIII\Models\\', '', $className), $models);
+ $models = array_map(static fn(string $className): string => str_replace('FireflyIII\Models\\', '', $className), $models);
$models = implode(',', $models);
$model = $this->convertString('attachable_type');
diff --git a/app/Api/V1/Requests/Models/AvailableBudget/Request.php b/app/Api/V1/Requests/Models/AvailableBudget/Request.php
index 14541253a8..0c3a8342ba 100644
--- a/app/Api/V1/Requests/Models/AvailableBudget/Request.php
+++ b/app/Api/V1/Requests/Models/AvailableBudget/Request.php
@@ -85,7 +85,7 @@ class Request extends FormRequest
$start = new Carbon($data['start']);
$end = new Carbon($data['end']);
if ($end->isBefore($start)) {
- $validator->errors()->add('end', (string) trans('validation.date_after'));
+ $validator->errors()->add('end', (string)trans('validation.date_after'));
}
}
});
diff --git a/app/Api/V1/Requests/Models/Bill/StoreRequest.php b/app/Api/V1/Requests/Models/Bill/StoreRequest.php
index 38e042d4e7..a518c437aa 100644
--- a/app/Api/V1/Requests/Models/Bill/StoreRequest.php
+++ b/app/Api/V1/Requests/Models/Bill/StoreRequest.php
@@ -98,13 +98,13 @@ class StoreRequest extends FormRequest
public function withValidator(Validator $validator): void
{
$validator->after(static function (Validator $validator): void {
- $data = $validator->getData();
- $min = $data['amount_min'] ?? '0';
- $max = $data['amount_max'] ?? '0';
+ $data = $validator->getData();
+ $min = $data['amount_min'] ?? '0';
+ $max = $data['amount_max'] ?? '0';
if (is_array($min) || is_array($max)) {
- $validator->errors()->add('amount_min', (string) trans('validation.generic_invalid'));
- $validator->errors()->add('amount_max', (string) trans('validation.generic_invalid'));
+ $validator->errors()->add('amount_min', (string)trans('validation.generic_invalid'));
+ $validator->errors()->add('amount_max', (string)trans('validation.generic_invalid'));
$min = '0';
$max = '0';
}
@@ -114,12 +114,12 @@ class StoreRequest extends FormRequest
$result = bccomp($min, $max);
} catch (ValueError $e) {
Log::error($e->getMessage());
- $validator->errors()->add('amount_min', (string) trans('validation.generic_invalid'));
- $validator->errors()->add('amount_max', (string) trans('validation.generic_invalid'));
+ $validator->errors()->add('amount_min', (string)trans('validation.generic_invalid'));
+ $validator->errors()->add('amount_max', (string)trans('validation.generic_invalid'));
}
if (1 === $result) {
- $validator->errors()->add('amount_min', (string) trans('validation.amount_min_over_max'));
+ $validator->errors()->add('amount_min', (string)trans('validation.amount_min_over_max'));
}
});
$failed = false;
diff --git a/app/Api/V1/Requests/Models/Bill/UpdateRequest.php b/app/Api/V1/Requests/Models/Bill/UpdateRequest.php
index 6f2faab885..1e4de7156c 100644
--- a/app/Api/V1/Requests/Models/Bill/UpdateRequest.php
+++ b/app/Api/V1/Requests/Models/Bill/UpdateRequest.php
@@ -105,7 +105,7 @@ class UpdateRequest extends FormRequest
$max = $data['amount_max'] ?? '0';
if (1 === bccomp($min, $max)) {
- $validator->errors()->add('amount_min', (string) trans('validation.amount_min_over_max'));
+ $validator->errors()->add('amount_min', (string)trans('validation.amount_min_over_max'));
}
}
});
diff --git a/app/Api/V1/Requests/Models/BudgetLimit/StoreRequest.php b/app/Api/V1/Requests/Models/BudgetLimit/StoreRequest.php
index 6703df8783..4953282f2f 100644
--- a/app/Api/V1/Requests/Models/BudgetLimit/StoreRequest.php
+++ b/app/Api/V1/Requests/Models/BudgetLimit/StoreRequest.php
@@ -94,12 +94,12 @@ class StoreRequest extends FormRequest
if (0 !== count($validator->failed())) {
return;
}
- $data = $validator->getData();
+ $data = $validator->getData();
// if no currency has been provided, use the user's default currency:
/** @var TransactionCurrencyFactory $factory */
- $factory = app(TransactionCurrencyFactory::class);
- $currency = $factory->find($data['currency_id'] ?? null, $data['currency_code'] ?? null);
+ $factory = app(TransactionCurrencyFactory::class);
+ $currency = $factory->find($data['currency_id'] ?? null, $data['currency_code'] ?? null);
if (null === $currency) {
$currency = Amount::getPrimaryCurrency();
}
@@ -107,17 +107,16 @@ class StoreRequest extends FormRequest
$repository->enable($currency);
// validator already concluded start and end are valid dates:
- $start = Carbon::parse($data['start'], config('app.timezone'));
- $end = Carbon::parse($data['end'], config('app.timezone'));
+ $start = Carbon::parse($data['start'], config('app.timezone'));
+ $end = Carbon::parse($data['end'], config('app.timezone'));
// find limit with same date range and currency.
- $limit = $budget
+ $limit = $budget
->budgetlimits()
->where('budget_limits.start_date', $start->format('Y-m-d'))
->where('budget_limits.end_date', $end->format('Y-m-d'))
->where('budget_limits.transaction_currency_id', $currency->id)
- ->first(['budget_limits.*'])
- ;
+ ->first(['budget_limits.*']);
if (null !== $limit) {
$validator->errors()->add('start', trans('validation.limit_exists'));
}
diff --git a/app/Api/V1/Requests/Models/BudgetLimit/UpdateRequest.php b/app/Api/V1/Requests/Models/BudgetLimit/UpdateRequest.php
index 3ed1e838c2..9f518c1f15 100644
--- a/app/Api/V1/Requests/Models/BudgetLimit/UpdateRequest.php
+++ b/app/Api/V1/Requests/Models/BudgetLimit/UpdateRequest.php
@@ -98,7 +98,7 @@ class UpdateRequest extends FormRequest
$start = new Carbon($data['start']);
$end = new Carbon($data['end']);
if ($end->isBefore($start)) {
- $validator->errors()->add('end', (string) trans('validation.date_after'));
+ $validator->errors()->add('end', (string)trans('validation.date_after'));
}
}
});
diff --git a/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreByDateRequest.php b/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreByDateRequest.php
index 04f7fe40de..39d32596a5 100644
--- a/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreByDateRequest.php
+++ b/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreByDateRequest.php
@@ -49,7 +49,7 @@ class StoreByDateRequest extends FormRequest
public function getFromCurrency(): TransactionCurrency
{
- return Amount::getTransactionCurrencyByCode((string) $this->get('from'));
+ return Amount::getTransactionCurrencyByCode((string)$this->get('from'));
}
/**
@@ -84,7 +84,7 @@ class StoreByDateRequest extends FormRequest
}
try {
- Amount::getTransactionCurrencyByCode((string) $key);
+ Amount::getTransactionCurrencyByCode((string)$key);
} catch (FireflyException) {
$validator->errors()->add(sprintf('rates.%s', $key), trans('validation.invalid_currency_code', ['code' => $key]));
}
diff --git a/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreRequest.php b/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreRequest.php
index bad8b8b7e6..80069f4fe1 100644
--- a/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreRequest.php
+++ b/app/Api/V1/Requests/Models/CurrencyExchangeRate/StoreRequest.php
@@ -45,17 +45,17 @@ class StoreRequest extends FormRequest
public function getFromCurrency(): TransactionCurrency
{
- return Amount::getTransactionCurrencyByCode((string) $this->get('from'));
+ return Amount::getTransactionCurrencyByCode((string)$this->get('from'));
}
public function getRate(): string
{
- return (string) $this->get('rate');
+ return (string)$this->get('rate');
}
public function getToCurrency(): TransactionCurrency
{
- return Amount::getTransactionCurrencyByCode((string) $this->get('to'));
+ return Amount::getTransactionCurrencyByCode((string)$this->get('to'));
}
/**
diff --git a/app/Api/V1/Requests/Models/CurrencyExchangeRate/UpdateRequest.php b/app/Api/V1/Requests/Models/CurrencyExchangeRate/UpdateRequest.php
index 2a92c35513..7600786d3e 100644
--- a/app/Api/V1/Requests/Models/CurrencyExchangeRate/UpdateRequest.php
+++ b/app/Api/V1/Requests/Models/CurrencyExchangeRate/UpdateRequest.php
@@ -43,7 +43,7 @@ class UpdateRequest extends FormRequest
public function getRate(): string
{
- return (string) $this->get('rate');
+ return (string)$this->get('rate');
}
/**
diff --git a/app/Api/V1/Requests/Models/PiggyBank/StoreRequest.php b/app/Api/V1/Requests/Models/PiggyBank/StoreRequest.php
index e93e708401..95ee2baa52 100644
--- a/app/Api/V1/Requests/Models/PiggyBank/StoreRequest.php
+++ b/app/Api/V1/Requests/Models/PiggyBank/StoreRequest.php
@@ -94,28 +94,28 @@ class StoreRequest extends FormRequest
{
$validator->after(function (Validator $validator): void {
// validate start before end only if both are there.
- $data = $validator->getData();
- $currency = $this->getCurrencyFromData($validator, $data);
+ $data = $validator->getData();
+ $currency = $this->getCurrencyFromData($validator, $data);
if (!$currency instanceof TransactionCurrency) {
return;
}
- $targetAmount = (string) ($data['target_amount'] ?? '0');
+ $targetAmount = (string)($data['target_amount'] ?? '0');
$currentAmount = '0';
if (array_key_exists('accounts', $data) && is_array($data['accounts'])) {
$repository = app(AccountRepositoryInterface::class);
$types = config('firefly.piggy_bank_account_types');
foreach ($data['accounts'] as $index => $array) {
- $accountId = (int) ($array['account_id'] ?? 0);
+ $accountId = (int)($array['account_id'] ?? 0);
$account = $repository->find($accountId);
if (null !== $account) {
// check currency here.
$accountCurrency = $repository->getAccountCurrency($account);
$isMultiCurrency = $repository->getMetaValue($account, 'is_multi_currency');
- $currentAmount = bcadd($currentAmount, (string) ($array['current_amount'] ?? '0'));
+ $currentAmount = bcadd($currentAmount, (string)($array['current_amount'] ?? '0'));
if ($accountCurrency->id !== $currency->id && 'true' !== $isMultiCurrency) {
$validator->errors()->add(sprintf('accounts.%d', $index), trans('validation.invalid_account_currency'));
}
- $type = $account->accountType->type;
+ $type = $account->accountType->type;
if (!in_array($type, $types, strict: true)) {
$validator->errors()->add(sprintf('accounts.%d', $index), trans('validation.invalid_account_type'));
}
@@ -133,11 +133,11 @@ class StoreRequest extends FormRequest
private function getCurrencyFromData(Validator $validator, array $data): ?TransactionCurrency
{
- if (array_key_exists('transaction_currency_code', $data) && '' !== (string) $data['transaction_currency_code']) {
- return Amount::getTransactionCurrencyByCode((string) $data['transaction_currency_code']);
+ if (array_key_exists('transaction_currency_code', $data) && '' !== (string)$data['transaction_currency_code']) {
+ return Amount::getTransactionCurrencyByCode((string)$data['transaction_currency_code']);
}
- if (array_key_exists('transaction_currency_id', $data) && '' !== (string) $data['transaction_currency_id']) {
- return Amount::getTransactionCurrencyById((int) $data['transaction_currency_id']);
+ if (array_key_exists('transaction_currency_id', $data) && '' !== (string)$data['transaction_currency_id']) {
+ return Amount::getTransactionCurrencyById((int)$data['transaction_currency_id']);
}
$validator->errors()->add('transaction_currency_id', trans('validation.require_currency_id_code'));
diff --git a/app/Api/V1/Requests/Models/PiggyBank/UpdateRequest.php b/app/Api/V1/Requests/Models/PiggyBank/UpdateRequest.php
index f7fe234148..da3618a26b 100644
--- a/app/Api/V1/Requests/Models/PiggyBank/UpdateRequest.php
+++ b/app/Api/V1/Requests/Models/PiggyBank/UpdateRequest.php
@@ -48,7 +48,7 @@ class UpdateRequest extends FormRequest
*/
public function getAll(): array
{
- $fields = [
+ $fields = [
'name' => ['name', 'convertString'],
'target_amount' => ['target_amount', 'convertString'],
'start_date' => ['start_date', 'convertDateTime'],
@@ -76,7 +76,7 @@ class UpdateRequest extends FormRequest
$piggyBank = $this->route()->parameter('piggyBank');
return [
- 'name' => 'min:1|max:255|uniquePiggyBankForUser:'.$piggyBank->id,
+ 'name' => 'min:1|max:255|uniquePiggyBankForUser:' . $piggyBank->id,
'current_amount' => ['nullable', new LessThanPiggyTarget(), new IsValidPositiveAmount()],
'target_amount' => ['nullable', new IsValidZeroOrMoreAmount()],
'start_date' => ['date', 'nullable'],
diff --git a/app/Api/V1/Requests/Models/Recurrence/StoreRequest.php b/app/Api/V1/Requests/Models/Recurrence/StoreRequest.php
index ebc871979f..1415fa13a2 100644
--- a/app/Api/V1/Requests/Models/Recurrence/StoreRequest.php
+++ b/app/Api/V1/Requests/Models/Recurrence/StoreRequest.php
@@ -78,19 +78,19 @@ class StoreRequest extends FormRequest
public function rules(): array
{
return [
- 'type' => ['required', 'in:withdrawal,transfer,deposit'],
- 'title' => ['required', 'min:1', 'max:255', 'uniqueObjectForUser:recurrences,title'],
- 'description' => ['min:1', 'max:32768'],
- 'first_date' => ['required', 'date'],
- 'apply_rules' => [new IsBoolean()],
- 'active' => [new IsBoolean()],
- 'repeat_until' => ['nullable', 'date'],
- 'nr_of_repetitions' => ['nullable', 'numeric', 'min:1', 'max:255'],
-
- 'repetitions.*.type' => ['required', 'in:daily,weekly,ndom,monthly,yearly'],
- 'repetitions.*.moment' => ['string', 'min:0', 'max:10'],
- 'repetitions.*.skip' => ['nullable', 'numeric', 'min:0', 'max:31'],
- 'repetitions.*.weekend' => ['numeric', 'min:1', 'max:4'],
+ 'type' => ['required', 'in:withdrawal,transfer,deposit'],
+ 'title' => ['required', 'min:1', 'max:255', 'uniqueObjectForUser:recurrences,title'],
+ 'description' => ['min:1', 'max:32768'],
+ 'first_date' => ['required', 'date'],
+ 'apply_rules' => [new IsBoolean()],
+ 'active' => [new IsBoolean()],
+ 'repeat_until' => ['nullable', 'date'],
+ 'nr_of_repetitions' => ['nullable', 'numeric', 'min:1', 'max:255'],
+
+ 'repetitions.*.type' => ['required', 'in:daily,weekly,ndom,monthly,yearly'],
+ 'repetitions.*.moment' => ['string', 'min:0', 'max:10'],
+ 'repetitions.*.skip' => ['nullable', 'numeric', 'min:0', 'max:31'],
+ 'repetitions.*.weekend' => ['numeric', 'min:1', 'max:4'],
'transactions.*.description' => ['required', 'min:1', 'max:255'],
'transactions.*.amount' => ['required', new IsValidPositiveAmount()],
@@ -139,7 +139,7 @@ class StoreRequest extends FormRequest
*/
private function getRepetitionData(): array
{
- $return = [];
+ $return = [];
// repetition data:
/** @var null|array $repetitions */
@@ -150,7 +150,7 @@ class StoreRequest extends FormRequest
/** @var array $repetition */
foreach ($repetitions as $repetition) {
- $current = [];
+ $current = [];
if (array_key_exists('type', $repetition)) {
$current['type'] = $repetition['type'];
}
@@ -158,10 +158,10 @@ class StoreRequest extends FormRequest
$current['moment'] = $repetition['moment'];
}
if (array_key_exists('skip', $repetition)) {
- $current['skip'] = (int) $repetition['skip'];
+ $current['skip'] = (int)$repetition['skip'];
}
if (array_key_exists('weekend', $repetition)) {
- $current['weekend'] = (int) $repetition['weekend'];
+ $current['weekend'] = (int)$repetition['weekend'];
}
$return[] = $current;
@@ -176,7 +176,7 @@ class StoreRequest extends FormRequest
*/
private function getTransactionData(): array
{
- $return = [];
+ $return = [];
// transaction data:
/** @var null|array $transactions */
diff --git a/app/Api/V1/Requests/Models/Recurrence/UpdateRequest.php b/app/Api/V1/Requests/Models/Recurrence/UpdateRequest.php
index 1a9a01bb4f..f5eabe8ac4 100644
--- a/app/Api/V1/Requests/Models/Recurrence/UpdateRequest.php
+++ b/app/Api/V1/Requests/Models/Recurrence/UpdateRequest.php
@@ -58,7 +58,7 @@ class UpdateRequest extends FormRequest
public function getAll(): array
{
// this is the way:
- $fields = [
+ $fields = [
'title' => ['title', 'convertString'],
'description' => ['description', 'convertString'],
'first_date' => ['first_date', 'convertDateTime'],
@@ -68,9 +68,9 @@ class UpdateRequest extends FormRequest
'active' => ['active', 'boolean'],
'notes' => ['notes', 'convertString'],
];
- $reps = $this->getRepetitionData();
- $transactions = $this->getTransactionData();
- $return = ['recurrence' => $this->getAllData($fields)];
+ $reps = $this->getRepetitionData();
+ $transactions = $this->getTransactionData();
+ $return = ['recurrence' => $this->getAllData($fields)];
if (null !== $reps) {
$return['repetitions'] = $reps;
}
@@ -88,18 +88,18 @@ class UpdateRequest extends FormRequest
$recurrence = $this->route()->parameter('recurrence');
return [
- 'title' => sprintf('min:1|max:255|uniqueObjectForUser:recurrences,title,%d', $recurrence->id),
- 'description' => ['min:1', 'max:32768'],
- 'first_date' => ['date', 'after:1970-01-02', 'before:2038-01-17'],
- 'apply_rules' => [new IsBoolean()],
- 'active' => [new IsBoolean()],
- 'repeat_until' => ['nullable', 'date'],
- 'nr_of_repetitions' => ['nullable', 'numeric', 'min:1', 'max:255'],
-
- 'repetitions.*.type' => 'in:daily,weekly,ndom,monthly,yearly',
- 'repetitions.*.moment' => ['string', 'min:0', 'max:10'],
- 'repetitions.*.skip' => ['nullable', 'numeric', 'min:0', 'max:31'],
- 'repetitions.*.weekend' => ['nullable', 'numeric', 'min:1', 'max:4'],
+ 'title' => sprintf('min:1|max:255|uniqueObjectForUser:recurrences,title,%d', $recurrence->id),
+ 'description' => ['min:1', 'max:32768'],
+ 'first_date' => ['date', 'after:1970-01-02', 'before:2038-01-17'],
+ 'apply_rules' => [new IsBoolean()],
+ 'active' => [new IsBoolean()],
+ 'repeat_until' => ['nullable', 'date'],
+ 'nr_of_repetitions' => ['nullable', 'numeric', 'min:1', 'max:255'],
+
+ 'repetitions.*.type' => 'in:daily,weekly,ndom,monthly,yearly',
+ 'repetitions.*.moment' => ['string', 'min:0', 'max:10'],
+ 'repetitions.*.skip' => ['nullable', 'numeric', 'min:0', 'max:31'],
+ 'repetitions.*.weekend' => ['nullable', 'numeric', 'min:1', 'max:4'],
'transactions.*.description' => ['min:1', 'max:255'],
'transactions.*.amount' => [new IsValidPositiveAmount()],
@@ -151,7 +151,7 @@ class UpdateRequest extends FormRequest
*/
private function getRepetitionData(): ?array
{
- $return = [];
+ $return = [];
// repetition data:
/** @var null|array $repetitions */
@@ -162,21 +162,21 @@ class UpdateRequest extends FormRequest
/** @var array $repetition */
foreach ($repetitions as $repetition) {
- $current = [];
+ $current = [];
if (array_key_exists('type', $repetition)) {
$current['type'] = $repetition['type'];
}
if (array_key_exists('moment', $repetition)) {
- $current['moment'] = (string) $repetition['moment'];
+ $current['moment'] = (string)$repetition['moment'];
}
if (array_key_exists('skip', $repetition)) {
- $current['skip'] = (int) $repetition['skip'];
+ $current['skip'] = (int)$repetition['skip'];
}
if (array_key_exists('weekend', $repetition)) {
- $current['weekend'] = (int) $repetition['weekend'];
+ $current['weekend'] = (int)$repetition['weekend'];
}
$return[] = $current;
}
@@ -193,7 +193,7 @@ class UpdateRequest extends FormRequest
*/
private function getTransactionData(): array
{
- $return = [];
+ $return = [];
// transaction data:
/** @var null|array $transactions */
diff --git a/app/Api/V1/Requests/Models/Rule/StoreRequest.php b/app/Api/V1/Requests/Models/Rule/StoreRequest.php
index d26ef8b8a5..e04cf5eb71 100644
--- a/app/Api/V1/Requests/Models/Rule/StoreRequest.php
+++ b/app/Api/V1/Requests/Models/Rule/StoreRequest.php
@@ -72,8 +72,8 @@ class StoreRequest extends FormRequest
*/
public function rules(): array
{
- $validTriggers = $this->getTriggers();
- $validActions = array_keys(config('firefly.rule-actions'));
+ $validTriggers = $this->getTriggers();
+ $validActions = array_keys(config('firefly.rule-actions'));
// some triggers and actions require text:
$contextTriggers = implode(',', $this->getTriggersWithContext());
@@ -85,11 +85,11 @@ class StoreRequest extends FormRequest
'rule_group_id' => ['belongsToUser:rule_groups', 'required_without:rule_group_title'],
'rule_group_title' => ['nullable', 'min:1', 'max:255', 'required_without:rule_group_id', 'belongsToUser:rule_groups,title'],
'trigger' => ['required', 'in:store-journal,update-journal,manual-activation'],
- 'triggers.*.type' => 'required|in:'.implode(',', $validTriggers),
- 'triggers.*.value' => 'required_if:actions.*.type,'.$contextTriggers.'|min:1|ruleTriggerValue|max:1024',
+ 'triggers.*.type' => 'required|in:' . implode(',', $validTriggers),
+ 'triggers.*.value' => 'required_if:actions.*.type,' . $contextTriggers . '|min:1|ruleTriggerValue|max:1024',
'triggers.*.stop_processing' => [new IsBoolean()],
'triggers.*.active' => [new IsBoolean()],
- 'actions.*.type' => 'required|in:'.implode(',', $validActions),
+ 'actions.*.type' => 'required|in:' . implode(',', $validActions),
'actions.*.value' => [sprintf('required_if:actions.*.type,%s', $contextActions), new IsValidActionExpression(), 'ruleActionValue'],
'actions.*.stop_processing' => [new IsBoolean()],
'actions.*.active' => [new IsBoolean()],
@@ -124,7 +124,7 @@ class StoreRequest extends FormRequest
$actions = $data['actions'] ?? [];
// need at least one trigger
if (!is_countable($actions) || 0 === count($actions)) {
- $validator->errors()->add('title', (string) trans('validation.at_least_one_action'));
+ $validator->errors()->add('title', (string)trans('validation.at_least_one_action'));
}
}
@@ -133,10 +133,10 @@ class StoreRequest extends FormRequest
*/
protected function atLeastOneActiveAction(Validator $validator): void
{
- $data = $validator->getData();
+ $data = $validator->getData();
/** @var null|array|int|string $actions */
- $actions = $data['actions'] ?? [];
+ $actions = $data['actions'] ?? [];
// need at least one trigger
if (!is_countable($actions) || 0 === count($actions)) {
return;
@@ -153,7 +153,7 @@ class StoreRequest extends FormRequest
}
}
if ($allInactive) {
- $validator->errors()->add(sprintf('actions.%d.active', $inactiveIndex), (string) trans('validation.at_least_one_active_action'));
+ $validator->errors()->add(sprintf('actions.%d.active', $inactiveIndex), (string)trans('validation.at_least_one_active_action'));
}
}
@@ -162,10 +162,10 @@ class StoreRequest extends FormRequest
*/
protected function atLeastOneActiveTrigger(Validator $validator): void
{
- $data = $validator->getData();
+ $data = $validator->getData();
/** @var null|array|int|string $triggers */
- $triggers = $data['triggers'] ?? [];
+ $triggers = $data['triggers'] ?? [];
// need at least one trigger
if (!is_countable($triggers) || 0 === count($triggers)) {
return;
@@ -182,7 +182,7 @@ class StoreRequest extends FormRequest
}
}
if ($allInactive) {
- $validator->errors()->add(sprintf('triggers.%d.active', $inactiveIndex), (string) trans('validation.at_least_one_active_trigger'));
+ $validator->errors()->add(sprintf('triggers.%d.active', $inactiveIndex), (string)trans('validation.at_least_one_active_trigger'));
}
}
@@ -195,7 +195,7 @@ class StoreRequest extends FormRequest
$triggers = $data['triggers'] ?? [];
// need at least one trigger
if (!is_countable($triggers) || 0 === count($triggers)) {
- $validator->errors()->add('title', (string) trans('validation.at_least_one_trigger'));
+ $validator->errors()->add('title', (string)trans('validation.at_least_one_trigger'));
}
}
@@ -208,8 +208,8 @@ class StoreRequest extends FormRequest
$return[] = [
'type' => $action['type'],
'value' => $action['value'],
- 'active' => $this->convertBoolean((string) ($action['active'] ?? 'true')),
- 'stop_processing' => $this->convertBoolean((string) ($action['stop_processing'] ?? 'false')),
+ 'active' => $this->convertBoolean((string)($action['active'] ?? 'true')),
+ 'stop_processing' => $this->convertBoolean((string)($action['stop_processing'] ?? 'false')),
];
}
}
@@ -226,9 +226,9 @@ class StoreRequest extends FormRequest
$return[] = [
'type' => $trigger['type'] ?? '',
'value' => $trigger['value'] ?? null,
- 'prohibited' => $this->convertBoolean((string) ($trigger['prohibited'] ?? 'false')),
- 'active' => $this->convertBoolean((string) ($trigger['active'] ?? 'true')),
- 'stop_processing' => $this->convertBoolean((string) ($trigger['stop_processing'] ?? 'false')),
+ 'prohibited' => $this->convertBoolean((string)($trigger['prohibited'] ?? 'false')),
+ 'active' => $this->convertBoolean((string)($trigger['active'] ?? 'true')),
+ 'stop_processing' => $this->convertBoolean((string)($trigger['stop_processing'] ?? 'false')),
];
}
}
diff --git a/app/Api/V1/Requests/Models/Rule/TestRequest.php b/app/Api/V1/Requests/Models/Rule/TestRequest.php
index 5565946dc6..9f97c1df5e 100644
--- a/app/Api/V1/Requests/Models/Rule/TestRequest.php
+++ b/app/Api/V1/Requests/Models/Rule/TestRequest.php
@@ -65,13 +65,13 @@ class TestRequest extends FormRequest
if (is_array($value)) {
return null;
}
- $value = (string) $value;
+ $value = (string)$value;
return null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', substr($value, 0, 10));
}
private function getPage(): int
{
- return 0 === (int) $this->query('page') ? 1 : (int) $this->query('page');
+ return 0 === (int)$this->query('page') ? 1 : (int)$this->query('page');
}
}
diff --git a/app/Api/V1/Requests/Models/Rule/TriggerRequest.php b/app/Api/V1/Requests/Models/Rule/TriggerRequest.php
index 13f623fdc4..eeee240466 100644
--- a/app/Api/V1/Requests/Models/Rule/TriggerRequest.php
+++ b/app/Api/V1/Requests/Models/Rule/TriggerRequest.php
@@ -65,7 +65,7 @@ class TriggerRequest extends FormRequest
if (is_array($value)) {
return null;
}
- $value = (string) $value;
+ $value = (string)$value;
return null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', substr($value, 0, 10));
}
diff --git a/app/Api/V1/Requests/Models/Rule/UpdateRequest.php b/app/Api/V1/Requests/Models/Rule/UpdateRequest.php
index f835e87098..f7a0ef5d1c 100644
--- a/app/Api/V1/Requests/Models/Rule/UpdateRequest.php
+++ b/app/Api/V1/Requests/Models/Rule/UpdateRequest.php
@@ -50,7 +50,7 @@ class UpdateRequest extends FormRequest
*/
public function getAll(): array
{
- $fields = [
+ $fields = [
'title' => ['title', 'convertString'],
'description' => ['description', 'stringWithNewlines'],
'rule_group_id' => ['rule_group_id', 'convertInteger'],
@@ -79,11 +79,11 @@ class UpdateRequest extends FormRequest
*/
public function rules(): array
{
- $validTriggers = $this->getTriggers();
- $validActions = array_keys(config('firefly.rule-actions'));
+ $validTriggers = $this->getTriggers();
+ $validActions = array_keys(config('firefly.rule-actions'));
/** @var Rule $rule */
- $rule = $this->route()->parameter('rule');
+ $rule = $this->route()->parameter('rule');
// some triggers and actions require text:
$contextTriggers = implode(',', $this->getTriggersWithContext());
@@ -95,11 +95,11 @@ class UpdateRequest extends FormRequest
'rule_group_id' => 'belongsToUser:rule_groups',
'rule_group_title' => ['nullable', 'min:1', 'max:255', 'belongsToUser:rule_groups,title'],
'trigger' => 'in:store-journal,update-journal,manual-activation',
- 'triggers.*.type' => 'required|in:'.implode(',', $validTriggers),
- 'triggers.*.value' => 'required_if:actions.*.type,'.$contextTriggers.'|min:1|ruleTriggerValue|max:1024',
+ 'triggers.*.type' => 'required|in:' . implode(',', $validTriggers),
+ 'triggers.*.value' => 'required_if:actions.*.type,' . $contextTriggers . '|min:1|ruleTriggerValue|max:1024',
'triggers.*.stop_processing' => [new IsBoolean()],
'triggers.*.active' => [new IsBoolean()],
- 'actions.*.type' => 'required|in:'.implode(',', $validActions),
+ 'actions.*.type' => 'required|in:' . implode(',', $validActions),
'actions.*.value' => [sprintf('required_if:actions.*.type,%s', $contextActions), new IsValidActionExpression(), 'ruleActionValue'],
'actions.*.stop_processing' => [new IsBoolean()],
'actions.*.active' => [new IsBoolean()],
@@ -135,7 +135,7 @@ class UpdateRequest extends FormRequest
$actions = $data['actions'] ?? null;
// need at least one action
if (is_array($actions) && 0 === count($actions)) {
- $validator->errors()->add('title', (string) trans('validation.at_least_one_action'));
+ $validator->errors()->add('title', (string)trans('validation.at_least_one_action'));
}
}
@@ -148,7 +148,7 @@ class UpdateRequest extends FormRequest
$triggers = $data['triggers'] ?? null;
// need at least one trigger
if (is_array($triggers) && 0 === count($triggers)) {
- $validator->errors()->add('title', (string) trans('validation.at_least_one_trigger'));
+ $validator->errors()->add('title', (string)trans('validation.at_least_one_trigger'));
}
}
@@ -176,7 +176,7 @@ class UpdateRequest extends FormRequest
}
}
if ($allInactive) {
- $validator->errors()->add(sprintf('actions.%d.active', $inactiveIndex), (string) trans('validation.at_least_one_active_action'));
+ $validator->errors()->add(sprintf('actions.%d.active', $inactiveIndex), (string)trans('validation.at_least_one_active_action'));
}
}
@@ -203,7 +203,7 @@ class UpdateRequest extends FormRequest
}
}
if ($allInactive) {
- $validator->errors()->add(sprintf('triggers.%d.active', $inactiveIndex), (string) trans('validation.at_least_one_active_trigger'));
+ $validator->errors()->add(sprintf('triggers.%d.active', $inactiveIndex), (string)trans('validation.at_least_one_active_trigger'));
}
}
@@ -219,8 +219,8 @@ class UpdateRequest extends FormRequest
$return[] = [
'type' => $action['type'],
'value' => $action['value'],
- 'active' => $this->convertBoolean((string) ($action['active'] ?? 'false')),
- 'stop_processing' => $this->convertBoolean((string) ($action['stop_processing'] ?? 'false')),
+ 'active' => $this->convertBoolean((string)($action['active'] ?? 'false')),
+ 'stop_processing' => $this->convertBoolean((string)($action['stop_processing'] ?? 'false')),
];
}
}
diff --git a/app/Api/V1/Requests/Models/RuleGroup/TestRequest.php b/app/Api/V1/Requests/Models/RuleGroup/TestRequest.php
index 466b6a6f3b..b4223e00ff 100644
--- a/app/Api/V1/Requests/Models/RuleGroup/TestRequest.php
+++ b/app/Api/V1/Requests/Models/RuleGroup/TestRequest.php
@@ -65,7 +65,7 @@ class TestRequest extends FormRequest
if (is_array($value)) {
return null;
}
- $value = (string) $value;
+ $value = (string)$value;
return null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', substr($value, 0, 10));
}
diff --git a/app/Api/V1/Requests/Models/RuleGroup/TriggerRequest.php b/app/Api/V1/Requests/Models/RuleGroup/TriggerRequest.php
index db4edcb1e4..bc62a391e4 100644
--- a/app/Api/V1/Requests/Models/RuleGroup/TriggerRequest.php
+++ b/app/Api/V1/Requests/Models/RuleGroup/TriggerRequest.php
@@ -67,7 +67,7 @@ class TriggerRequest extends FormRequest
if (is_array($value)) {
return null;
}
- $value = (string) $value;
+ $value = (string)$value;
return null === $this->query($field) ? null : Carbon::createFromFormat('Y-m-d', substr($value, 0, 10));
}
diff --git a/app/Api/V1/Requests/Models/RuleGroup/UpdateRequest.php b/app/Api/V1/Requests/Models/RuleGroup/UpdateRequest.php
index 33c737f1b6..fe9a1d1573 100644
--- a/app/Api/V1/Requests/Models/RuleGroup/UpdateRequest.php
+++ b/app/Api/V1/Requests/Models/RuleGroup/UpdateRequest.php
@@ -65,7 +65,7 @@ class UpdateRequest extends FormRequest
$ruleGroup = $this->route()->parameter('ruleGroup');
return [
- 'title' => 'min:1|max:100|uniqueObjectForUser:rule_groups,title,'.$ruleGroup->id,
+ 'title' => 'min:1|max:100|uniqueObjectForUser:rule_groups,title,' . $ruleGroup->id,
'description' => ['min:1', 'max:32768', 'nullable'],
'active' => [new IsBoolean()],
];
diff --git a/app/Api/V1/Requests/Models/Tag/UpdateRequest.php b/app/Api/V1/Requests/Models/Tag/UpdateRequest.php
index c5deb1b95f..ae477e3a3b 100644
--- a/app/Api/V1/Requests/Models/Tag/UpdateRequest.php
+++ b/app/Api/V1/Requests/Models/Tag/UpdateRequest.php
@@ -62,7 +62,7 @@ class UpdateRequest extends FormRequest
/** @var Tag $tag */
$tag = $this->route()->parameter('tagOrId');
$rules = [
- 'tag' => 'min:1|max:1024|uniqueObjectForUser:tags,tag,'.$tag->id,
+ 'tag' => 'min:1|max:1024|uniqueObjectForUser:tags,tag,' . $tag->id,
'description' => ['min:1', 'nullable', 'max:32768'],
'date' => ['date', 'nullable', 'after:1970-01-02', 'before:2038-01-17'],
];
diff --git a/app/Api/V1/Requests/Models/Transaction/StoreRequest.php b/app/Api/V1/Requests/Models/Transaction/StoreRequest.php
index 314031af88..3c9bff30ed 100644
--- a/app/Api/V1/Requests/Models/Transaction/StoreRequest.php
+++ b/app/Api/V1/Requests/Models/Transaction/StoreRequest.php
@@ -221,87 +221,87 @@ class StoreRequest extends FormRequest
foreach ($this->get('transactions') as $transaction) {
$object = new NullArrayObject($transaction);
$return[] = [
- 'type' => $this->clearString($object['type']),
- 'date' => $this->dateFromValue($object['date']),
- 'order' => $this->integerFromValue((string) $object['order']),
+ 'type' => $this->clearString($object['type']),
+ 'date' => $this->dateFromValue($object['date']),
+ 'order' => $this->integerFromValue((string)$object['order']),
- 'currency_id' => $this->integerFromValue((string) $object['currency_id']),
- 'currency_code' => $this->clearString((string) $object['currency_code']),
+ 'currency_id' => $this->integerFromValue((string)$object['currency_id']),
+ 'currency_code' => $this->clearString((string)$object['currency_code']),
// location
- 'latitude' => $this->floatFromValue((string) $object['latitude']),
- 'longitude' => $this->floatFromValue((string) $object['longitude']),
- 'zoom_level' => $this->integerFromValue((string) $object['zoom_level']),
+ 'latitude' => $this->floatFromValue((string)$object['latitude']),
+ 'longitude' => $this->floatFromValue((string)$object['longitude']),
+ 'zoom_level' => $this->integerFromValue((string)$object['zoom_level']),
// foreign currency info:
- 'foreign_currency_id' => $this->integerFromValue((string) $object['foreign_currency_id']),
- 'foreign_currency_code' => $this->clearString((string) $object['foreign_currency_code']),
+ 'foreign_currency_id' => $this->integerFromValue((string)$object['foreign_currency_id']),
+ 'foreign_currency_code' => $this->clearString((string)$object['foreign_currency_code']),
// amount and foreign amount. Cannot be 0.
- 'amount' => $this->clearString((string) $object['amount']),
- 'foreign_amount' => $this->clearString((string) $object['foreign_amount']),
+ 'amount' => $this->clearString((string)$object['amount']),
+ 'foreign_amount' => $this->clearString((string)$object['foreign_amount']),
// description.
'description' => $this->clearString($object['description']),
// source of transaction. If everything is null, assume cash account.
- 'source_id' => $this->integerFromValue((string) $object['source_id']),
- 'source_name' => $this->clearString((string) $object['source_name']),
- 'source_iban' => $this->clearIban((string) $object['source_iban']),
- 'source_number' => $this->clearString((string) $object['source_number']),
- 'source_bic' => $this->clearString((string) $object['source_bic']),
+ 'source_id' => $this->integerFromValue((string)$object['source_id']),
+ 'source_name' => $this->clearString((string)$object['source_name']),
+ 'source_iban' => $this->clearIban((string)$object['source_iban']),
+ 'source_number' => $this->clearString((string)$object['source_number']),
+ 'source_bic' => $this->clearString((string)$object['source_bic']),
// destination of transaction. If everything is null, assume cash account.
- 'destination_id' => $this->integerFromValue((string) $object['destination_id']),
- 'destination_name' => $this->clearString((string) $object['destination_name']),
- 'destination_iban' => $this->clearIban((string) $object['destination_iban']),
- 'destination_number' => $this->clearString((string) $object['destination_number']),
- 'destination_bic' => $this->clearString((string) $object['destination_bic']),
+ 'destination_id' => $this->integerFromValue((string)$object['destination_id']),
+ 'destination_name' => $this->clearString((string)$object['destination_name']),
+ 'destination_iban' => $this->clearIban((string)$object['destination_iban']),
+ 'destination_number' => $this->clearString((string)$object['destination_number']),
+ 'destination_bic' => $this->clearString((string)$object['destination_bic']),
// budget info
- 'budget_id' => $this->integerFromValue((string) $object['budget_id']),
- 'budget_name' => $this->clearString((string) $object['budget_name']),
+ 'budget_id' => $this->integerFromValue((string)$object['budget_id']),
+ 'budget_name' => $this->clearString((string)$object['budget_name']),
// category info
- 'category_id' => $this->integerFromValue((string) $object['category_id']),
- 'category_name' => $this->clearString((string) $object['category_name']),
+ 'category_id' => $this->integerFromValue((string)$object['category_id']),
+ 'category_name' => $this->clearString((string)$object['category_name']),
// journal bill reference. Optional. Will only work for withdrawals
- 'bill_id' => $this->integerFromValue((string) $object['bill_id']),
- 'bill_name' => $this->clearString((string) $object['bill_name']),
+ 'bill_id' => $this->integerFromValue((string)$object['bill_id']),
+ 'bill_name' => $this->clearString((string)$object['bill_name']),
// piggy bank reference. Optional. Will only work for transfers
- 'piggy_bank_id' => $this->integerFromValue((string) $object['piggy_bank_id']),
- 'piggy_bank_name' => $this->clearString((string) $object['piggy_bank_name']),
+ 'piggy_bank_id' => $this->integerFromValue((string)$object['piggy_bank_id']),
+ 'piggy_bank_name' => $this->clearString((string)$object['piggy_bank_name']),
// some other interesting properties
- 'reconciled' => $this->convertBoolean((string) $object['reconciled']),
- 'notes' => $this->clearStringKeepNewlines((string) $object['notes']),
+ 'reconciled' => $this->convertBoolean((string)$object['reconciled']),
+ 'notes' => $this->clearStringKeepNewlines((string)$object['notes']),
'tags' => $this->arrayFromValue($object['tags']),
// all custom fields:
- 'internal_reference' => $this->clearString((string) $object['internal_reference']),
- 'external_id' => $this->clearString((string) $object['external_id']),
+ 'internal_reference' => $this->clearString((string)$object['internal_reference']),
+ 'external_id' => $this->clearString((string)$object['external_id']),
'original_source' => sprintf('ff3-v%s', config('firefly.version')),
'recurrence_id' => $this->integerFromValue($object['recurrence_id']),
- 'bunq_payment_id' => $this->clearString((string) $object['bunq_payment_id']),
- 'external_url' => $this->clearString((string) $object['external_url']),
-
- 'sepa_cc' => $this->clearString((string) $object['sepa_cc']),
- 'sepa_ct_op' => $this->clearString((string) $object['sepa_ct_op']),
- 'sepa_ct_id' => $this->clearString((string) $object['sepa_ct_id']),
- 'sepa_db' => $this->clearString((string) $object['sepa_db']),
- 'sepa_country' => $this->clearString((string) $object['sepa_country']),
- 'sepa_ep' => $this->clearString((string) $object['sepa_ep']),
- 'sepa_ci' => $this->clearString((string) $object['sepa_ci']),
- 'sepa_batch_id' => $this->clearString((string) $object['sepa_batch_id']),
+ 'bunq_payment_id' => $this->clearString((string)$object['bunq_payment_id']),
+ 'external_url' => $this->clearString((string)$object['external_url']),
+
+ 'sepa_cc' => $this->clearString((string)$object['sepa_cc']),
+ 'sepa_ct_op' => $this->clearString((string)$object['sepa_ct_op']),
+ 'sepa_ct_id' => $this->clearString((string)$object['sepa_ct_id']),
+ 'sepa_db' => $this->clearString((string)$object['sepa_db']),
+ 'sepa_country' => $this->clearString((string)$object['sepa_country']),
+ 'sepa_ep' => $this->clearString((string)$object['sepa_ep']),
+ 'sepa_ci' => $this->clearString((string)$object['sepa_ci']),
+ 'sepa_batch_id' => $this->clearString((string)$object['sepa_batch_id']),
// custom date fields. Must be Carbon objects. Presence is optional.
- 'interest_date' => $this->dateFromValue($object['interest_date']),
- 'book_date' => $this->dateFromValue($object['book_date']),
- 'process_date' => $this->dateFromValue($object['process_date']),
- 'due_date' => $this->dateFromValue($object['due_date']),
- 'payment_date' => $this->dateFromValue($object['payment_date']),
- 'invoice_date' => $this->dateFromValue($object['invoice_date']),
+ 'interest_date' => $this->dateFromValue($object['interest_date']),
+ 'book_date' => $this->dateFromValue($object['book_date']),
+ 'process_date' => $this->dateFromValue($object['process_date']),
+ 'due_date' => $this->dateFromValue($object['due_date']),
+ 'payment_date' => $this->dateFromValue($object['payment_date']),
+ 'invoice_date' => $this->dateFromValue($object['invoice_date']),
];
}
diff --git a/app/Api/V1/Requests/Models/Transaction/UpdateRequest.php b/app/Api/V1/Requests/Models/Transaction/UpdateRequest.php
index bc65904add..f3aa2c94a9 100644
--- a/app/Api/V1/Requests/Models/Transaction/UpdateRequest.php
+++ b/app/Api/V1/Requests/Models/Transaction/UpdateRequest.php
@@ -84,8 +84,8 @@ class UpdateRequest extends FormRequest
$this->dateFields = ['date', 'interest_date', 'book_date', 'process_date', 'due_date', 'payment_date', 'invoice_date'];
$this->textareaFields = ['notes'];
// not really floats, for validation.
- $this->floatFields = ['amount', 'foreign_amount', 'longitude', 'latitude'];
- $this->stringFields = [
+ $this->floatFields = ['amount', 'foreign_amount', 'longitude', 'latitude'];
+ $this->stringFields = [
'type',
'currency_code',
'foreign_currency_code',
@@ -114,9 +114,9 @@ class UpdateRequest extends FormRequest
'sepa_batch_id',
'external_url',
];
- $this->booleanFields = ['reconciled'];
- $this->arrayFields = ['tags'];
- $data = ['batch_submission' => false];
+ $this->booleanFields = ['reconciled'];
+ $this->arrayFields = ['tags'];
+ $data = ['batch_submission' => false];
if ($this->has('transactions')) {
$data['transactions'] = $this->getTransactionData();
}
@@ -281,7 +281,7 @@ class UpdateRequest extends FormRequest
{
foreach ($this->booleanFields as $fieldName) {
if (array_key_exists($fieldName, $transaction)) {
- $current[$fieldName] = $this->convertBoolean((string) $transaction[$fieldName]);
+ $current[$fieldName] = $this->convertBoolean((string)$transaction[$fieldName]);
}
}
@@ -298,7 +298,7 @@ class UpdateRequest extends FormRequest
Log::debug(sprintf('Now at date field %s', $fieldName));
if (array_key_exists($fieldName, $transaction)) {
Log::debug(sprintf('New value: "%s"', $transaction[$fieldName]));
- $current[$fieldName] = $this->dateFromValue((string) $transaction[$fieldName]);
+ $current[$fieldName] = $this->dateFromValue((string)$transaction[$fieldName]);
}
}
@@ -318,7 +318,7 @@ class UpdateRequest extends FormRequest
$current[$fieldName] = sprintf('%.12f', $value);
}
if (!is_float($value)) {
- $current[$fieldName] = (string) $value;
+ $current[$fieldName] = (string)$value;
}
}
}
@@ -336,7 +336,7 @@ class UpdateRequest extends FormRequest
{
foreach ($this->integerFields as $fieldName) {
if (array_key_exists($fieldName, $transaction)) {
- $current[$fieldName] = $this->integerFromValue((string) $transaction[$fieldName]);
+ $current[$fieldName] = $this->integerFromValue((string)$transaction[$fieldName]);
}
}
@@ -351,7 +351,7 @@ class UpdateRequest extends FormRequest
{
foreach ($this->textareaFields as $fieldName) {
if (array_key_exists($fieldName, $transaction)) {
- $current[$fieldName] = $this->clearStringKeepNewlines((string) $transaction[$fieldName]); // keep newlines
+ $current[$fieldName] = $this->clearStringKeepNewlines((string)$transaction[$fieldName]); // keep newlines
}
}
@@ -366,7 +366,7 @@ class UpdateRequest extends FormRequest
{
foreach ($this->stringFields as $fieldName) {
if (array_key_exists($fieldName, $transaction)) {
- $current[$fieldName] = $this->clearString((string) $transaction[$fieldName]);
+ $current[$fieldName] = $this->clearString((string)$transaction[$fieldName]);
}
}
@@ -381,7 +381,7 @@ class UpdateRequest extends FormRequest
private function getTransactionData(): array
{
Log::debug(sprintf('Now in %s', __METHOD__));
- $return = [];
+ $return = [];
/** @var null|array $transactions */
$transactions = $this->get('transactions');
diff --git a/app/Api/V1/Requests/Models/TransactionCurrency/UpdateRequest.php b/app/Api/V1/Requests/Models/TransactionCurrency/UpdateRequest.php
index 5c30faa6d6..1646409ebb 100644
--- a/app/Api/V1/Requests/Models/TransactionCurrency/UpdateRequest.php
+++ b/app/Api/V1/Requests/Models/TransactionCurrency/UpdateRequest.php
@@ -50,7 +50,7 @@ class UpdateRequest extends FormRequest
$user = auth()->user();
$isAdmin = $user->hasRole('owner');
- $fields = [
+ $fields = [
'enabled' => ['enabled', 'boolean'],
];
if ($isAdmin) {
diff --git a/app/Api/V1/Requests/Models/TransactionLink/StoreRequest.php b/app/Api/V1/Requests/Models/TransactionLink/StoreRequest.php
index d6d1db01b0..1c1437e587 100644
--- a/app/Api/V1/Requests/Models/TransactionLink/StoreRequest.php
+++ b/app/Api/V1/Requests/Models/TransactionLink/StoreRequest.php
@@ -87,21 +87,21 @@ class StoreRequest extends FormRequest
private function validateExistingLink(Validator $validator): void
{
/** @var User $user */
- $user = auth()->user();
+ $user = auth()->user();
/** @var LinkTypeRepositoryInterface $repository */
- $repository = app(LinkTypeRepositoryInterface::class);
+ $repository = app(LinkTypeRepositoryInterface::class);
$repository->setUser($user);
/** @var JournalRepositoryInterface $journalRepos */
$journalRepos = app(JournalRepositoryInterface::class);
$journalRepos->setUser($user);
- $data = $validator->getData();
- $inwardId = (int) ($data['inward_id'] ?? 0);
- $outwardId = (int) ($data['outward_id'] ?? 0);
- $inward = $journalRepos->find($inwardId);
- $outward = $journalRepos->find($outwardId);
+ $data = $validator->getData();
+ $inwardId = (int)($data['inward_id'] ?? 0);
+ $outwardId = (int)($data['outward_id'] ?? 0);
+ $inward = $journalRepos->find($inwardId);
+ $outward = $journalRepos->find($outwardId);
if (null === $inward) {
$validator->errors()->add('inward_id', 'Invalid inward ID.');
diff --git a/app/Api/V1/Requests/Models/TransactionLink/UpdateRequest.php b/app/Api/V1/Requests/Models/TransactionLink/UpdateRequest.php
index f4a6743417..7678c04d38 100644
--- a/app/Api/V1/Requests/Models/TransactionLink/UpdateRequest.php
+++ b/app/Api/V1/Requests/Models/TransactionLink/UpdateRequest.php
@@ -87,21 +87,21 @@ class UpdateRequest extends FormRequest
private function validateUpdate(Validator $validator): void
{
/** @var TransactionJournalLink $existing */
- $existing = $this->route()->parameter('journalLink');
- $data = $validator->getData();
+ $existing = $this->route()->parameter('journalLink');
+ $data = $validator->getData();
/** @var LinkTypeRepositoryInterface $repository */
- $repository = app(LinkTypeRepositoryInterface::class);
+ $repository = app(LinkTypeRepositoryInterface::class);
$repository->setUser(auth()->user());
/** @var JournalRepositoryInterface $journalRepos */
$journalRepos = app(JournalRepositoryInterface::class);
$journalRepos->setUser(auth()->user());
- $inwardId = $data['inward_id'] ?? $existing->source_id;
- $outwardId = $data['outward_id'] ?? $existing->destination_id;
- $inward = $journalRepos->find((int) $inwardId);
- $outward = $journalRepos->find((int) $outwardId);
+ $inwardId = $data['inward_id'] ?? $existing->source_id;
+ $outwardId = $data['outward_id'] ?? $existing->destination_id;
+ $inward = $journalRepos->find((int)$inwardId);
+ $outward = $journalRepos->find((int)$outwardId);
if (null === $inward) {
$inward = $existing->source;
}
@@ -113,7 +113,7 @@ class UpdateRequest extends FormRequest
$validator->errors()->add('outward_id', 'Inward ID must be different from outward ID.');
}
- $inDB = $repository->findSpecificLink($existing->linkType, $inward, $outward);
+ $inDB = $repository->findSpecificLink($existing->linkType, $inward, $outward);
if (null === $inDB) {
return;
}
diff --git a/app/Api/V1/Requests/Models/Webhook/CreateRequest.php b/app/Api/V1/Requests/Models/Webhook/CreateRequest.php
index a4aa6ef879..610ab2b8db 100644
--- a/app/Api/V1/Requests/Models/Webhook/CreateRequest.php
+++ b/app/Api/V1/Requests/Models/Webhook/CreateRequest.php
@@ -47,10 +47,10 @@ class CreateRequest extends FormRequest
public function getData(): array
{
- $fields = ['title' => ['title', 'convertString'], 'active' => ['active', 'boolean'], 'url' => ['url', 'convertString']];
- $triggers = $this->get('triggers', []);
- $responses = $this->get('responses', []);
- $deliveries = $this->get('deliveries', []);
+ $fields = ['title' => ['title', 'convertString'], 'active' => ['active', 'boolean'], 'url' => ['url', 'convertString']];
+ $triggers = $this->get('triggers', []);
+ $responses = $this->get('responses', []);
+ $deliveries = $this->get('deliveries', []);
if (in_array(0, [count($triggers), count($responses), count($deliveries)], strict: true)) {
throw new FireflyException('Unexpectedly got no responses, triggers or deliveries.');
diff --git a/app/Api/V1/Requests/Models/Webhook/UpdateRequest.php b/app/Api/V1/Requests/Models/Webhook/UpdateRequest.php
index 0feed24a0d..90718b9306 100644
--- a/app/Api/V1/Requests/Models/Webhook/UpdateRequest.php
+++ b/app/Api/V1/Requests/Models/Webhook/UpdateRequest.php
@@ -47,11 +47,11 @@ class UpdateRequest extends FormRequest
public function getData(): array
{
- $fields = ['title' => ['title', 'convertString'], 'active' => ['active', 'boolean'], 'url' => ['url', 'convertString']];
+ $fields = ['title' => ['title', 'convertString'], 'active' => ['active', 'boolean'], 'url' => ['url', 'convertString']];
- $triggers = $this->get('triggers', []);
- $responses = $this->get('responses', []);
- $deliveries = $this->get('deliveries', []);
+ $triggers = $this->get('triggers', []);
+ $responses = $this->get('responses', []);
+ $deliveries = $this->get('deliveries', []);
if (in_array(0, [count($triggers), count($responses), count($deliveries)], strict: true)) {
throw new FireflyException('Unexpectedly got no responses, triggers or deliveries.');
@@ -76,7 +76,7 @@ class UpdateRequest extends FormRequest
$validProtocols = AppConfiguration::get('valid_url_protocols', config('firefly.valid_url_protocols'))->data;
/** @var Webhook $webhook */
- $webhook = $this->route()->parameter('webhook');
+ $webhook = $this->route()->parameter('webhook');
return [
'title' => sprintf('min:1|max:255|uniqueObjectForUser:webhooks,title,%d', $webhook->id),
diff --git a/app/Api/V1/Requests/PaginationRequest.php b/app/Api/V1/Requests/PaginationRequest.php
index cd1f7d7579..5cf66fad48 100644
--- a/app/Api/V1/Requests/PaginationRequest.php
+++ b/app/Api/V1/Requests/PaginationRequest.php
@@ -49,7 +49,7 @@ class PaginationRequest extends ApiRequest
public function rules(): array
{
return [
- 'sort' => ['nullable', new IsValidSortInstruction((string) $this->sortClass)],
+ 'sort' => ['nullable', new IsValidSortInstruction((string)$this->sortClass)],
'limit' => ['numeric', 'min:1', 'max:131337'],
'page' => ['numeric', 'min:1', 'max:131337'],
];
@@ -62,12 +62,12 @@ class PaginationRequest extends ApiRequest
return;
}
- $limit = $this->convertInteger('limit');
+ $limit = $this->convertInteger('limit');
if (0 === $limit) {
// get default for user:
/** @var User $user */
$user = auth()->user();
- $limit = (int) Preferences::getForUser($user, 'listPageSize', 50)->data;
+ $limit = (int)Preferences::getForUser($user, 'listPageSize', 50)->data;
}
$page = $this->convertInteger('page');
$page = clamp(value: $page, min: 1, max: 2 ** 16);
diff --git a/app/Api/V1/Requests/System/UpdateRequest.php b/app/Api/V1/Requests/System/UpdateRequest.php
index cb01863154..f9d44cff9a 100644
--- a/app/Api/V1/Requests/System/UpdateRequest.php
+++ b/app/Api/V1/Requests/System/UpdateRequest.php
@@ -39,16 +39,17 @@ class UpdateRequest extends FormRequest
protected array $acceptedRoles = [];
- private array $booleans = [
- 'configuration.is_demo_site',
- 'configuration.single_user_mode',
- 'configuration.enable_exchange_rates',
- 'configuration.use_running_balance',
- 'configuration.enable_external_map',
- 'configuration.enable_external_rates',
- 'configuration.allow_webhooks',
- ];
- private array $integers = ['configuration.permission_update_check', 'configuration.last_update_check'];
+ private array $booleans
+ = [
+ 'configuration.is_demo_site',
+ 'configuration.single_user_mode',
+ 'configuration.enable_exchange_rates',
+ 'configuration.use_running_balance',
+ 'configuration.enable_external_map',
+ 'configuration.enable_external_rates',
+ 'configuration.allow_webhooks',
+ ];
+ private array $integers = ['configuration.permission_update_check', 'configuration.last_update_check'];
/**
* Get all data from the request.
diff --git a/app/Api/V1/Requests/System/UserUpdateRequest.php b/app/Api/V1/Requests/System/UserUpdateRequest.php
index 8dd7da01e0..ccafd6e5ed 100644
--- a/app/Api/V1/Requests/System/UserUpdateRequest.php
+++ b/app/Api/V1/Requests/System/UserUpdateRequest.php
@@ -95,7 +95,7 @@ class UserUpdateRequest extends FormRequest
$isAdmin = auth()->user()->hasRole('owner');
// not admin, and not own user?
if (auth()->check() && false === $isAdmin && $current?->id !== auth()->user()->id) {
- $validator->errors()->add('email', (string) trans('validation.invalid_selection'));
+ $validator->errors()->add('email', (string)trans('validation.invalid_selection'));
}
});
if ($validator->fails()) {
diff --git a/app/Api/V1/Requests/User/PreferenceStoreRequest.php b/app/Api/V1/Requests/User/PreferenceStoreRequest.php
index 20802fa518..305193be09 100644
--- a/app/Api/V1/Requests/User/PreferenceStoreRequest.php
+++ b/app/Api/V1/Requests/User/PreferenceStoreRequest.php
@@ -48,7 +48,7 @@ class PreferenceStoreRequest extends FormRequest
$array['data'] = false;
}
if (is_numeric($array['data'])) {
- $array['data'] = (float) $array['data']; // intentional float.
+ $array['data'] = (float)$array['data']; // intentional float.
}
return $array;
diff --git a/app/Api/V1/Requests/User/PreferenceUpdateRequest.php b/app/Api/V1/Requests/User/PreferenceUpdateRequest.php
index 8174b2547e..e467d2b86f 100644
--- a/app/Api/V1/Requests/User/PreferenceUpdateRequest.php
+++ b/app/Api/V1/Requests/User/PreferenceUpdateRequest.php
@@ -48,7 +48,7 @@ class PreferenceUpdateRequest extends FormRequest
$array['data'] = false;
}
if (is_numeric($array['data'])) {
- $array['data'] = (float) $array['data']; // intentional float.
+ $array['data'] = (float)$array['data']; // intentional float.
}
return $array;
diff --git a/app/Http/Controllers/Auth/TwoFactorController.php b/app/Http/Controllers/Auth/TwoFactorController.php
index b603695b14..1242192601 100644
--- a/app/Http/Controllers/Auth/TwoFactorController.php
+++ b/app/Http/Controllers/Auth/TwoFactorController.php
@@ -131,6 +131,7 @@ final class TwoFactorController extends Controller
++$preference;
Log::channel('audit')->info(sprintf('MFA failure count is set to %d.', $preference));
Preferences::set('mfa_failure_count', $preference, true);
+ sleep(2 ** $preference);
}
private function addToMFAHistory(string $mfaCode): void
diff --git a/app/Http/Controllers/DebugController.php b/app/Http/Controllers/DebugController.php
index a4d164020d..0f507d8c3f 100644
--- a/app/Http/Controllers/DebugController.php
+++ b/app/Http/Controllers/DebugController.php
@@ -65,8 +65,8 @@ use const PHP_SAPI;
*/
final class DebugController extends Controller
{
- use GetConfigurationData;
use IsOldVersion;
+ use GetConfigurationData;
/**
* DebugController constructor.
@@ -144,23 +144,26 @@ final class DebugController extends Controller
$table = $this->generateTable();
$table = str_replace(["\n", "\t", ' '], '', $table);
$now = now(config('app.timezone'))->format('Y-m-d H:i:s');
-
- // get latest log file:
- $logger = Log::driver();
- // PHPstan doesn't recognize the method because of its polymorphic nature.
- $handlers = $logger->getHandlers();
$logContent = '';
- foreach ($handlers as $handler) {
- if ($handler instanceof RotatingFileHandler) {
- $logFile = $handler->getUrl();
- if (null !== $logFile && file_exists($logFile)) {
- $logContent = file_get_contents($logFile);
+
+ if(auth()->check() && auth()->user()->hasRole('owner')) {
+ // get latest log file:
+ $logger = Log::driver();
+ // PHPstan doesn't recognize the method because of its polymorphic nature.
+ $handlers = $logger->getHandlers();
+
+ foreach ($handlers as $handler) {
+ if ($handler instanceof RotatingFileHandler) {
+ $logFile = $handler->getUrl();
+ if (null !== $logFile && file_exists($logFile)) {
+ $logContent = file_get_contents($logFile);
+ }
}
}
- }
- if ('' !== $logContent) {
- // last few lines
- $logContent = 'Truncated from this point <----|'.substr($logContent, -16_384);
+ if ('' !== $logContent) {
+ // last few lines
+ $logContent = 'Truncated from this point <----|' . substr($logContent, -16_384);
+ }
}
return view('debug', ['table' => $table, 'now' => $now, 'logContent' => $logContent]);
diff --git a/app/Rules/Webhook/IsValidWebhookUrl.php b/app/Rules/Webhook/IsValidWebhookUrl.php
index fe9cc5b155..dc0c93333c 100644
--- a/app/Rules/Webhook/IsValidWebhookUrl.php
+++ b/app/Rules/Webhook/IsValidWebhookUrl.php
@@ -40,7 +40,11 @@ class IsValidWebhookUrl implements ValidationRule
public function validate(string $attribute, mixed $value, Closure $fail): void
{
$value = (string) $value;
- $resolved = gethostbyname(parse_url($value, PHP_URL_HOST));
+ $parsed = parse_url($value, PHP_URL_HOST);
+ if(!is_string($parsed)) {
+ $fail('validation.bad_url')->translate();
+ }
+ $resolved = gethostbyname($parsed);
Log::debug(sprintf('Now validating URL "%s" with IP "%s".', $value, $resolved));
/*
@@ -66,8 +70,9 @@ class IsValidWebhookUrl implements ValidationRule
$validProtocols = AppConfiguration::get('valid_url_protocols', config('firefly.valid_url_protocols'))->data;
$parts = explode(',', $validProtocols);
$valid = false;
+ $scheme = parse_url($value, PHP_URL_SCHEME);
foreach ($parts as $part) {
- if (str_starts_with($value, $part)) {
+ if (is_string($scheme) && str_starts_with($scheme, $part)) {
$valid = true;
}
}