Reformat various code.

This commit is contained in:
James Cole 2022-03-29 14:56:27 +02:00
parent 9cdaf7076a
commit 1209c4e76a
No known key found for this signature in database
GPG Key ID: B49A324B7EAD6D80
145 changed files with 472 additions and 472 deletions

View File

@ -81,7 +81,7 @@ class AccountController extends Controller
$date = $data['date'] ?? today(config('app.timezone'));
$return = [];
$result = $this->repository->searchAccount((string)$query, $types, $data['limit']);
$result = $this->repository->searchAccount((string) $query, $types, $data['limit']);
$defaultCurrency = app('amount')->getDefaultCurrency();
/** @var Account $account */
@ -95,7 +95,7 @@ class AccountController extends Controller
}
$return[] = [
'id' => (string)$account->id,
'id' => (string) $account->id,
'name' => $account->name,
'name_with_balance' => $nameWithBalance,
'type' => $account->accountType->type,

View File

@ -70,7 +70,7 @@ class BillController extends Controller
$filtered = $result->map(
static function (Bill $item) {
return [
'id' => (string)$item->id,
'id' => (string) $item->id,
'name' => $item->name,
];
}

View File

@ -70,7 +70,7 @@ class BudgetController extends Controller
$filtered = $result->map(
static function (Budget $item) {
return [
'id' => (string)$item->id,
'id' => (string) $item->id,
'name' => $item->name,
];
}

View File

@ -70,7 +70,7 @@ class CategoryController extends Controller
$filtered = $result->map(
static function (Category $item) {
return [
'id' => (string)$item->id,
'id' => (string) $item->id,
'name' => $item->name,
];
}

View File

@ -72,7 +72,7 @@ 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,
@ -101,7 +101,7 @@ 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,

View File

@ -72,7 +72,7 @@ class ObjectGroupController extends Controller
/** @var ObjectGroup $objectGroup */
foreach ($result as $objectGroup) {
$return[] = [
'id' => (string)$objectGroup->id,
'id' => (string) $objectGroup->id,
'name' => $objectGroup->title,
'title' => $objectGroup->title,
];

View File

@ -78,7 +78,7 @@ class PiggyBankController extends Controller
foreach ($piggies as $piggy) {
$currency = $this->accountRepository->getAccountCurrency($piggy->account) ?? $defaultCurrency;
$response[] = [
'id' => (string)$piggy->id,
'id' => (string) $piggy->id,
'name' => $piggy->name,
'currency_id' => $currency->id,
'currency_name' => $currency->name,
@ -110,7 +110,7 @@ class PiggyBankController extends Controller
$currency = $this->accountRepository->getAccountCurrency($piggy->account) ?? $defaultCurrency;
$currentAmount = $this->piggyRepository->getRepetition($piggy)->currentamount ?? '0';
$response[] = [
'id' => (string)$piggy->id,
'id' => (string) $piggy->id,
'name' => $piggy->name,
'name_with_balance' => sprintf(
'%s (%s / %s)', $piggy->name, app('amount')->formatAnything($currency, $currentAmount, false),

View File

@ -69,7 +69,7 @@ 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,
];

View File

@ -69,7 +69,7 @@ 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,
];

View File

@ -69,7 +69,7 @@ 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,
];

View File

@ -72,7 +72,7 @@ class TagController extends Controller
/** @var Tag $tag */
foreach ($result as $tag) {
$array[] = [
'id' => (string)$tag->id,
'id' => (string) $tag->id,
'name' => $tag->tag,
'tag' => $tag->tag,
];

View File

@ -80,8 +80,8 @@ 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,
];
@ -104,7 +104,7 @@ class TransactionController extends Controller
$result = new Collection;
if (is_numeric($data['query'])) {
// search for group, not journal.
$firstResult = $this->groupRepository->find((int)$data['query']);
$firstResult = $this->groupRepository->find((int) $data['query']);
if (null !== $firstResult) {
// group may contain multiple journals, each a result:
foreach ($firstResult->transactionJournals as $journal) {
@ -122,8 +122,8 @@ class TransactionController extends Controller
/** @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),
];

View File

@ -70,7 +70,7 @@ class TransactionTypeController extends Controller
foreach ($types as $type) {
// different key for consistency.
$array[] = [
'id' => (string)$type->id,
'id' => (string) $type->id,
'name' => $type->type,
'type' => $type->type,
];

View File

@ -109,7 +109,7 @@ class AccountController extends Controller
}
$currentSet = [
'label' => $account->name,
'currency_id' => (string)$currency->id,
'currency_id' => (string) $currency->id,
'currency_code' => $currency->code,
'currency_symbol' => $currency->symbol,
'currency_decimal_places' => $currency->decimal_places,
@ -121,11 +121,11 @@ class AccountController extends Controller
];
$currentStart = clone $start;
$range = app('steam')->balanceInRange($account, $start, clone $end);
$previous = round((float)array_values($range)[0], 12);
$previous = round((float) array_values($range)[0], 12);
while ($currentStart <= $end) {
$format = $currentStart->format('Y-m-d');
$label = $currentStart->toAtomString();
$balance = array_key_exists($format, $range) ? round((float)$range[$format], 12) : $previous;
$balance = array_key_exists($format, $range) ? round((float) $range[$format], 12) : $previous;
$previous = $balance;
$currentStart->addDay();
$currentSet['entries'][$label] = $balance;

View File

@ -66,8 +66,8 @@ class AccountController extends Controller
*/
public function moveTransactions(MoveTransactionsRequest $request): JsonResponse
{
$accountIds = $request->getAll();
$original = $this->repository->find($accountIds['original_account']);
$accountIds = $request->getAll();
$original = $this->repository->find($accountIds['original_account']);
$destination = $this->repository->find($accountIds['destination_account']);
/** @var AccountDestroyService $service */

View File

@ -76,8 +76,8 @@ 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->updatesTransactionAccount($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);

View File

@ -78,9 +78,9 @@ class ExportController extends Controller
*/
private function returnExport(string $key): LaravelResponse
{
$date = date('Y-m-d-H-i-s');
$date = date('Y-m-d-H-i-s');
$fileName = sprintf('%s-export-%s.csv', $date, $key);
$data = $this->exporter->export();
$data = $this->exporter->export();
/** @var LaravelResponse $response */
$response = response($data[$key]);
@ -93,7 +93,7 @@ class ExportController extends Controller
->header('Expires', '0')
->header('Cache-Control', 'must-revalidate, post-check=0, pre-check=0')
->header('Pragma', 'public')
->header('Content-Length', (string)strlen($data[$key]));
->header('Content-Length', (string) strlen($data[$key]));
return $response;
}

View File

@ -91,11 +91,11 @@ 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'],
'currency_id' => (string)$expense['currency_id'],
'difference_float' => (float) $expense['sum'],
'currency_id' => (string) $expense['currency_id'],
'currency_code' => $expense['currency_code'],
];
}
@ -123,11 +123,11 @@ 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'],
'currency_id' => (string)$expense['currency_id'],
'difference_float' => (float) $expense['sum'],
'currency_id' => (string) $expense['currency_id'],
'currency_code' => $expense['currency_code'],
];
}

View File

@ -85,33 +85,33 @@ class BillController extends Controller
$genericSet = $collector->getExtractedJournals();
foreach ($genericSet as $journal) {
$billId = (int)$journal['bill_id'];
$currencyId = (int)$journal['currency_id'];
$foreignCurrencyId = (int)$journal['foreign_currency_id'];
$billId = (int) $journal['bill_id'];
$currencyId = (int) $journal['currency_id'];
$foreignCurrencyId = (int) $journal['foreign_currency_id'];
$key = sprintf('%d-%d', $billId, $currencyId);
$foreignKey = sprintf('%d-%d', $billId, $foreignCurrencyId);
if (0 !== $currencyId) {
$response[$key] = $response[$key] ?? [
'id' => (string)$billId,
'id' => (string) $billId,
'name' => $journal['bill_name'],
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$currencyId,
'currency_id' => (string) $currencyId,
'currency_code' => $journal['currency_code'],
];
$response[$key]['difference'] = bcadd($response[$key]['difference'], $journal['amount']);
$response[$key]['difference_float'] = (float)$response[$key]['difference'];
$response[$key]['difference_float'] = (float) $response[$key]['difference'];
}
if (0 !== $foreignCurrencyId) {
$response[$foreignKey] = $response[$foreignKey] ?? [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$foreignCurrencyId,
'currency_id' => (string) $foreignCurrencyId,
'currency_code' => $journal['foreign_currency_code'],
];
$response[$foreignKey]['difference'] = bcadd($response[$foreignKey]['difference'], $journal['foreign_amount']);
$response[$foreignKey]['difference_float'] = (float)$response[$foreignKey]['difference'];
$response[$foreignKey]['difference_float'] = (float) $response[$foreignKey]['difference'];
}
}
@ -143,28 +143,28 @@ class BillController extends Controller
$genericSet = $collector->getExtractedJournals();
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'];
if (0 !== $currencyId) {
$response[$currencyId] = $response[$currencyId] ?? [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$currencyId,
'currency_id' => (string) $currencyId,
'currency_code' => $journal['currency_code'],
];
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], $journal['amount']);
$response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference'];
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference'];
}
if (0 !== $foreignCurrencyId) {
$response[$foreignCurrencyId] = $response[$foreignCurrencyId] ?? [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$foreignCurrencyId,
'currency_id' => (string) $foreignCurrencyId,
'currency_code' => $journal['foreign_currency_code'],
];
$response[$foreignCurrencyId]['difference'] = bcadd($response[$foreignCurrencyId]['difference'], $journal['foreign_amount']);
$response[$foreignCurrencyId]['difference_float'] = (float)$response[$foreignCurrencyId]['difference'];
$response[$foreignCurrencyId]['difference_float'] = (float) $response[$foreignCurrencyId]['difference'];
}
}

View File

@ -88,11 +88,11 @@ 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'],
'currency_id' => (string)$expense['currency_id'],
'difference_float' => (float) $expense['sum'],
'currency_id' => (string) $expense['currency_id'],
'currency_code' => $expense['currency_code'],
];
}
@ -120,8 +120,8 @@ class BudgetController 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'],
];
}

View File

@ -89,11 +89,11 @@ 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'],
];
}
@ -121,8 +121,8 @@ 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'],
];
}

View File

@ -55,28 +55,28 @@ class PeriodController extends Controller
$collector->setTypes([TransactionType::WITHDRAWAL])->setRange($start, $end)->setSourceAccounts($accounts);
$genericSet = $collector->getExtractedJournals();
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'];
if (0 !== $currencyId) {
$response[$currencyId] = $response[$currencyId] ?? [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$currencyId,
'currency_id' => (string) $currencyId,
'currency_code' => $journal['currency_code'],
];
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], $journal['amount']);
$response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference'];
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference'];
}
if (0 !== $foreignCurrencyId) {
$response[$foreignCurrencyId] = $response[$foreignCurrencyId] ?? [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$foreignCurrencyId,
'currency_id' => (string) $foreignCurrencyId,
'currency_code' => $journal['foreign_currency_code'],
];
$response[$foreignCurrencyId]['difference'] = bcadd($response[$foreignCurrencyId]['difference'], $journal['foreign_amount']);
$response[$foreignCurrencyId]['difference_float'] = (float)$response[$foreignCurrencyId]['difference'];
$response[$foreignCurrencyId]['difference_float'] = (float) $response[$foreignCurrencyId]['difference'];
}
}

View File

@ -79,28 +79,28 @@ class TagController extends Controller
$genericSet = $collector->getExtractedJournals();
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'];
if (0 !== $currencyId) {
$response[$currencyId] = $response[$currencyId] ?? [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$currencyId,
'currency_id' => (string) $currencyId,
'currency_code' => $journal['currency_code'],
];
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], $journal['amount']);
$response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference'];
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference'];
}
if (0 !== $foreignCurrencyId) {
$response[$foreignCurrencyId] = $response[$foreignCurrencyId] ?? [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$foreignCurrencyId,
'currency_id' => (string) $foreignCurrencyId,
'currency_code' => $journal['foreign_currency_code'],
];
$response[$foreignCurrencyId]['difference'] = bcadd($response[$foreignCurrencyId]['difference'], $journal['foreign_amount']);
$response[$foreignCurrencyId]['difference_float'] = (float)$response[$foreignCurrencyId]['difference'];
$response[$foreignCurrencyId]['difference_float'] = (float) $response[$foreignCurrencyId]['difference'];
}
}
@ -137,8 +137,8 @@ class TagController extends Controller
$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) {
@ -149,15 +149,15 @@ class TagController extends Controller
// on currency ID
if (0 !== $currencyId) {
$response[$key] = $response[$key] ?? [
'id' => (string)$tagId,
'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($response[$key]['difference'], $journal['amount']);
$response[$key]['difference_float'] = (float)$response[$key]['difference'];
$response[$key]['difference_float'] = (float) $response[$key]['difference'];
}
// on foreign ID
@ -165,11 +165,11 @@ 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($response[$foreignKey]['difference'], $journal['foreign_amount']);
$response[$foreignKey]['difference_float'] = (float)$response[$foreignKey]['difference'];
$response[$foreignKey]['difference_float'] = (float) $response[$foreignKey]['difference'];
}
}
}

View File

@ -90,11 +90,11 @@ 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'],
'currency_id' => (string)$entry['currency_id'],
'difference_float' => (float) $entry['sum'],
'currency_id' => (string) $entry['currency_id'],
'currency_code' => $entry['currency_code'],
];
}
@ -122,11 +122,11 @@ 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'],
'currency_id' => (string)$entry['currency_id'],
'difference_float' => (float) $entry['sum'],
'currency_id' => (string) $entry['currency_id'],
'currency_code' => $entry['currency_code'],
];
}

View File

@ -89,11 +89,11 @@ 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'],
];
}
@ -121,8 +121,8 @@ 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'],
];
}

View File

@ -55,30 +55,30 @@ class PeriodController extends Controller
$collector->setTypes([TransactionType::DEPOSIT])->setRange($start, $end)->setDestinationAccounts($accounts);
$genericSet = $collector->getExtractedJournals();
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'];
if (0 !== $currencyId) {
$response[$currencyId] = $response[$currencyId] ?? [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$currencyId,
'currency_id' => (string) $currencyId,
'currency_code' => $journal['currency_code'],
];
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], app('steam')->positive($journal['amount']));
$response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference'];
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference'];
}
if (0 !== $foreignCurrencyId) {
$response[$foreignCurrencyId] = $response[$foreignCurrencyId] ?? [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$foreignCurrencyId,
'currency_id' => (string) $foreignCurrencyId,
'currency_code' => $journal['foreign_currency_code'],
];
$response[$foreignCurrencyId]['difference'] = bcadd(
$response[$foreignCurrencyId]['difference'], app('steam')->positive($journal['foreign_amount'])
);
$response[$foreignCurrencyId]['difference_float'] = (float)$response[$foreignCurrencyId]['difference'];
$response[$foreignCurrencyId]['difference_float'] = (float) $response[$foreignCurrencyId]['difference'];
}
}

View File

@ -80,30 +80,30 @@ class TagController extends Controller
$genericSet = $collector->getExtractedJournals();
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'];
if (0 !== $currencyId) {
$response[$currencyId] = $response[$currencyId] ?? [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$currencyId,
'currency_id' => (string) $currencyId,
'currency_code' => $journal['currency_code'],
];
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], app('steam')->positive($journal['amount']));
$response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference'];
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference'];
}
if (0 !== $foreignCurrencyId) {
$response[$foreignCurrencyId] = $response[$foreignCurrencyId] ?? [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$foreignCurrencyId,
'currency_id' => (string) $foreignCurrencyId,
'currency_code' => $journal['foreign_currency_code'],
];
$response[$foreignCurrencyId]['difference'] = bcadd(
$response[$foreignCurrencyId]['difference'], app('steam')->positive($journal['foreign_amount'])
);
$response[$foreignCurrencyId]['difference_float'] = (float)$response[$foreignCurrencyId]['difference'];
$response[$foreignCurrencyId]['difference_float'] = (float) $response[$foreignCurrencyId]['difference'];
}
}
@ -140,8 +140,8 @@ class TagController extends Controller
$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) {
@ -152,15 +152,15 @@ class TagController extends Controller
// on currency ID
if (0 !== $currencyId) {
$response[$key] = $response[$key] ?? [
'id' => (string)$tagId,
'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($response[$key]['difference'], app('steam')->positive($journal['amount']));
$response[$key]['difference_float'] = (float)$response[$key]['difference'];
$response[$key]['difference_float'] = (float) $response[$key]['difference'];
}
// on foreign ID
@ -168,13 +168,13 @@ 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(
$response[$foreignKey]['difference'], app('steam')->positive($journal['foreign_amount'])
);
$response[$foreignKey]['difference_float'] = (float)$response[$foreignKey]['difference'];
$response[$foreignKey]['difference_float'] = (float) $response[$foreignKey]['difference'];
}
}
}

View File

@ -88,11 +88,11 @@ 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'],
];
}
@ -120,8 +120,8 @@ 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'],
];
}

View File

@ -55,30 +55,30 @@ class PeriodController extends Controller
$collector->setTypes([TransactionType::TRANSFER])->setRange($start, $end)->setDestinationAccounts($accounts);
$genericSet = $collector->getExtractedJournals();
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'];
if (0 !== $currencyId) {
$response[$currencyId] = $response[$currencyId] ?? [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$currencyId,
'currency_id' => (string) $currencyId,
'currency_code' => $journal['currency_code'],
];
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], app('steam')->positive($journal['amount']));
$response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference'];
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference'];
}
if (0 !== $foreignCurrencyId) {
$response[$foreignCurrencyId] = $response[$foreignCurrencyId] ?? [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$foreignCurrencyId,
'currency_id' => (string) $foreignCurrencyId,
'currency_code' => $journal['foreign_currency_code'],
];
$response[$foreignCurrencyId]['difference'] = bcadd(
$response[$foreignCurrencyId]['difference'], app('steam')->positive($journal['foreign_amount'])
);
$response[$foreignCurrencyId]['difference_float'] = (float)$response[$foreignCurrencyId]['difference'];
$response[$foreignCurrencyId]['difference_float'] = (float) $response[$foreignCurrencyId]['difference'];
}
}

View File

@ -77,30 +77,30 @@ class TagController extends Controller
$genericSet = $collector->getExtractedJournals();
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'];
if (0 !== $currencyId) {
$response[$currencyId] = $response[$currencyId] ?? [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$currencyId,
'currency_id' => (string) $currencyId,
'currency_code' => $journal['currency_code'],
];
$response[$currencyId]['difference'] = bcadd($response[$currencyId]['difference'], app('steam')->positive($journal['amount']));
$response[$currencyId]['difference_float'] = (float)$response[$currencyId]['difference'];
$response[$currencyId]['difference_float'] = (float) $response[$currencyId]['difference'];
}
if (0 !== $foreignCurrencyId) {
$response[$foreignCurrencyId] = $response[$foreignCurrencyId] ?? [
'difference' => '0',
'difference_float' => 0,
'currency_id' => (string)$foreignCurrencyId,
'currency_id' => (string) $foreignCurrencyId,
'currency_code' => $journal['foreign_currency_code'],
];
$response[$foreignCurrencyId]['difference'] = bcadd(
$response[$foreignCurrencyId]['difference'], app('steam')->positive($journal['foreign_amount'])
);
$response[$foreignCurrencyId]['difference_float'] = (float)$response[$foreignCurrencyId]['difference'];
$response[$foreignCurrencyId]['difference_float'] = (float) $response[$foreignCurrencyId]['difference'];
}
}
@ -137,8 +137,8 @@ class TagController extends Controller
$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) {
@ -149,15 +149,15 @@ class TagController extends Controller
// on currency ID
if (0 !== $currencyId) {
$response[$key] = $response[$key] ?? [
'id' => (string)$tagId,
'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($response[$key]['difference'], app('steam')->positive($journal['amount']));
$response[$key]['difference_float'] = (float)$response[$key]['difference'];
$response[$key]['difference_float'] = (float) $response[$key]['difference'];
}
// on foreign ID
@ -165,13 +165,13 @@ 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(
$response[$foreignKey]['difference'], app('steam')->positive($journal['foreign_amount'])
);
$response[$foreignKey]['difference_float'] = (float)$response[$foreignKey]['difference'];
$response[$foreignKey]['difference_float'] = (float) $response[$foreignKey]['difference'];
}
}
}

View File

@ -82,7 +82,7 @@ class ListController extends Controller
public function attachments(Account $account): JsonResponse
{
$manager = $this->getManager();
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$collection = $this->repository->getAttachments($account);
$count = $collection->count();
@ -118,7 +118,7 @@ class ListController extends Controller
$manager = $this->getManager();
// types to get, page size:
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
// get list of budgets. Count it and split it.
$collection = $this->repository->getPiggyBanks($account);
@ -156,7 +156,7 @@ class ListController extends Controller
*/
public function transactions(Request $request, Account $account): JsonResponse
{
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$type = $request->get('type') ?? 'default';
$this->parameters->set('type', $type);

View File

@ -84,8 +84,8 @@ class ShowController extends Controller
$this->parameters->set('type', $type);
// types to get, page size:
$types = $this->mapAccountTypes($this->parameters->get('type'));
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$types = $this->mapAccountTypes($this->parameters->get('type'));
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
// get list of accounts. Count it and split it.
$this->repository->resetAccountOrder();

View File

@ -74,10 +74,10 @@ class UpdateController extends Controller
public function update(UpdateRequest $request, Account $account): JsonResponse
{
Log::debug(sprintf('Now in %s', __METHOD__));
$data = $request->getUpdateData();
$data = $request->getUpdateData();
$data['type'] = config('firefly.shortNamesByFullName.' . $account->accountType->type);
$account = $this->repository->update($account, $data);
$manager = $this->getManager();
$account = $this->repository->update($account, $data);
$manager = $this->getManager();
$account->refresh();
Preferences::mark();

View File

@ -49,7 +49,7 @@ class DestroyController extends Controller
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$user = auth()->user();
$this->repository = app(AttachmentRepositoryInterface::class);
$this->repository->setUser($user);

View File

@ -103,7 +103,7 @@ class ShowController extends Controller
->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;
}
@ -125,7 +125,7 @@ class ShowController extends Controller
$manager = $this->getManager();
// types to get, page size:
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
// get list of attachments. Count it and split it.
$collection = $this->repository->get();

View File

@ -52,7 +52,7 @@ class UpdateController extends Controller
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$user = auth()->user();
$this->repository = app(AttachmentRepositoryInterface::class);
$this->repository->setUser($user);

View File

@ -47,7 +47,7 @@ class DestroyController extends Controller
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$user = auth()->user();
$this->abRepository = app(AvailableBudgetRepositoryInterface::class);
$this->abRepository->setUser($user);

View File

@ -77,7 +77,7 @@ class ShowController extends Controller
$manager = $this->getManager();
// types to get, page size:
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$start = $this->parameters->get('start');
$end = $this->parameters->get('end');

View File

@ -81,7 +81,7 @@ class ListController extends Controller
public function attachments(Bill $bill): JsonResponse
{
$manager = $this->getManager();
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$collection = $this->repository->getAttachments($bill);
$count = $collection->count();
@ -118,7 +118,7 @@ class ListController extends Controller
$manager = $this->getManager();
// types to get, page size:
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
// get list of budgets. Count it and split it.
$collection = $this->repository->getRulesForBill($bill);
@ -155,7 +155,7 @@ class ListController extends Controller
*/
public function transactions(Request $request, Bill $bill): JsonResponse
{
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$type = $request->get('type') ?? 'default';
$this->parameters->set('type', $type);

View File

@ -74,7 +74,7 @@ class ShowController extends Controller
$this->repository->correctOrder();
$bills = $this->repository->getBills();
$manager = $this->getManager();
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$count = $bills->count();
$bills = $bills->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
$paginator = new LengthAwarePaginator($bills, $count, $pageSize, $this->parameters->get('page'));

View File

@ -72,8 +72,8 @@ class StoreController extends Controller
*/
public function store(StoreRequest $request): JsonResponse
{
$data = $request->getAll();
$bill = $this->repository->store($data);
$data = $request->getAll();
$bill = $this->repository->store($data);
$manager = $this->getManager();
/** @var BillTransformer $transformer */

View File

@ -69,8 +69,8 @@ class UpdateController extends Controller
*/
public function update(UpdateRequest $request, Bill $bill): JsonResponse
{
$data = $request->getAll();
$bill = $this->repository->update($bill, $data);
$data = $request->getAll();
$bill = $this->repository->update($bill, $data);
$manager = $this->getManager();
/** @var BillTransformer $transformer */

View File

@ -83,7 +83,7 @@ class ListController extends Controller
public function attachments(Budget $budget): JsonResponse
{
$manager = $this->getManager();
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$collection = $this->repository->getAttachments($budget);
$count = $collection->count();
@ -118,7 +118,7 @@ class ListController extends Controller
public function budgetLimits(Budget $budget): JsonResponse
{
$manager = $this->getManager();
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$this->parameters->set('budget_id', $budget->id);
$collection = $this->blRepository->getBudgetLimits($budget, $this->parameters->get('start'), $this->parameters->get('end'));
$count = $collection->count();
@ -151,7 +151,7 @@ class ListController extends Controller
*/
public function transactions(Request $request, Budget $budget): JsonResponse
{
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
// user can overrule page size with limit parameter.
$limit = $this->parameters->get('limit');
@ -217,7 +217,7 @@ class ListController extends Controller
*/
public function withoutBudget(Request $request): JsonResponse
{
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
// user can overrule page size with limit parameter.
$limit = $this->parameters->get('limit');

View File

@ -53,7 +53,7 @@ class ShowController extends Controller
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(BudgetRepositoryInterface::class);
$this->repository = app(BudgetRepositoryInterface::class);
$this->blRepository = app(BudgetLimitRepositoryInterface::class);
$this->repository->setUser(auth()->user());
$this->blRepository->setUser(auth()->user());
@ -78,7 +78,7 @@ class ShowController extends Controller
$manager = $this->getManager();
// types to get, page size:
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
// get list of budgets. Count it and split it.
$collection = $this->repository->getBudgets();

View File

@ -81,7 +81,7 @@ class ListController extends Controller
*/
public function transactions(Request $request, Budget $budget, BudgetLimit $budgetLimit): JsonResponse
{
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$type = $request->get('type') ?? 'default';
$this->parameters->set('type', $type);

View File

@ -86,7 +86,7 @@ class ShowController extends Controller
{
$manager = $this->getManager();
$manager->parseIncludes('budget');
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$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);
@ -119,7 +119,7 @@ class ShowController extends Controller
{
$manager = $this->getManager();
$manager->parseIncludes('budget');
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$collection = $this->blRepository->getAllBudgetLimits($this->parameters->get('start'), $this->parameters->get('end'));
$count = $collection->count();
$budgetLimits = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
@ -149,7 +149,7 @@ class ShowController extends Controller
*/
public function show(Request $request, Budget $budget, BudgetLimit $budgetLimit): JsonResponse
{
if ((int)$budget->id !== (int)$budgetLimit->budget_id) {
if ((int) $budget->id !== (int) $budgetLimit->budget_id) {
throw new FireflyException('20028: The budget limit does not belong to the budget.');
}
// continue!

View File

@ -77,7 +77,7 @@ class UpdateController extends Controller
public function update(UpdateRequest $request, Budget $budget, BudgetLimit $budgetLimit): JsonResponse
{
if ((int)$budget->id !== (int)$budgetLimit->budget_id) {
if ((int) $budget->id !== (int) $budgetLimit->budget_id) {
throw new FireflyException('20028: The budget limit does not belong to the budget.');
}
$data = $request->getAll();

View File

@ -78,7 +78,7 @@ class ListController extends Controller
public function attachments(Category $category): JsonResponse
{
$manager = $this->getManager();
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$collection = $this->repository->getAttachments($category);
$count = $collection->count();
@ -114,7 +114,7 @@ class ListController extends Controller
*/
public function transactions(Request $request, Category $category): JsonResponse
{
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$type = $request->get('type') ?? 'default';
$this->parameters->set('type', $type);

View File

@ -74,7 +74,7 @@ class ShowController extends Controller
$manager = $this->getManager();
// types to get, page size:
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
// get list of budgets. Count it and split it.
$collection = $this->repository->getCategories();

View File

@ -69,9 +69,9 @@ class UpdateController extends Controller
*/
public function update(UpdateRequest $request, Category $category): JsonResponse
{
$data = $request->getAll();
$data = $request->getAll();
$category = $this->repository->update($category, $data);
$manager = $this->getManager();
$manager = $this->getManager();
/** @var CategoryTransformer $transformer */
$transformer = app(CategoryTransformer::class);

View File

@ -47,7 +47,7 @@ class DestroyController extends Controller
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$user = auth()->user();
$this->repository = app(ObjectGroupRepositoryInterface::class);
$this->repository->setUser($user);

View File

@ -53,7 +53,7 @@ class ListController extends Controller
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$user = auth()->user();
$this->repository = app(ObjectGroupRepositoryInterface::class);
$this->repository->setUser($user);
@ -78,7 +78,7 @@ class ListController extends Controller
{
$manager = $this->getManager();
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
// get list of piggy banks. Count it and split it.
$collection = $this->repository->getBills($objectGroup);
$count = $collection->count();
@ -116,7 +116,7 @@ class ListController extends Controller
$manager = $this->getManager();
// types to get, page size:
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
// get list of piggy banks. Count it and split it.
$collection = $this->repository->getPiggyBanks($objectGroup);

View File

@ -80,7 +80,7 @@ class ShowController extends Controller
$manager = $this->getManager();
// types to get, page size:
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$this->repository->resetOrder();
$collection = $this->repository->get();

View File

@ -50,7 +50,7 @@ class UpdateController extends Controller
$this->middleware(
function ($request, $next) {
/** @var User $user */
$user = auth()->user();
$user = auth()->user();
$this->repository = app(ObjectGroupRepositoryInterface::class);
$this->repository->setUser($user);

View File

@ -72,7 +72,7 @@ class ListController extends Controller
public function attachments(PiggyBank $piggyBank): JsonResponse
{
$manager = $this->getManager();
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$collection = $this->repository->getAttachments($piggyBank);
$count = $collection->count();
@ -107,7 +107,7 @@ class ListController extends Controller
public function piggyBankEvents(PiggyBank $piggyBank): JsonResponse
{
// types to get, page size:
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$manager = $this->getManager();
$collection = $this->repository->getEvents($piggyBank);

View File

@ -73,7 +73,7 @@ class ShowController extends Controller
{
$manager = $this->getManager();
// types to get, page size:
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
// get list of budgets. Count it and split it.
$collection = $this->repository->getPiggyBanks();

View File

@ -69,7 +69,7 @@ class UpdateController extends Controller
*/
public function update(UpdateRequest $request, PiggyBank $piggyBank): JsonResponse
{
$data = $request->getAll();
$data = $request->getAll();
$piggyBank = $this->repository->update($piggyBank, $data);
if (array_key_exists('current_amount', $data) && '' !== $data['current_amount']) {

View File

@ -78,7 +78,7 @@ class ListController extends Controller
*/
public function transactions(Request $request, Recurrence $recurrence): JsonResponse
{
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$type = $request->get('type') ?? 'default';
$this->parameters->set('type', $type);

View File

@ -74,7 +74,7 @@ class ShowController extends Controller
$manager = $this->getManager();
// types to get, page size:
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
// get list of budgets. Count it and split it.
$collection = $this->repository->get();

View File

@ -69,9 +69,9 @@ class StoreController extends Controller
*/
public function store(StoreRequest $request): JsonResponse
{
$data = $request->getAll();
$data = $request->getAll();
$recurrence = $this->repository->store($data);
$manager = $this->getManager();
$manager = $this->getManager();
/** @var RecurrenceTransformer $transformer */
$transformer = app(RecurrenceTransformer::class);

View File

@ -69,9 +69,9 @@ class UpdateController extends Controller
*/
public function update(UpdateRequest $request, Recurrence $recurrence): JsonResponse
{
$data = $request->getAll();
$data = $request->getAll();
$recurrence = $this->repository->update($recurrence, $data);
$manager = $this->getManager();
$manager = $this->getManager();
/** @var RecurrenceTransformer $transformer */
$transformer = app(RecurrenceTransformer::class);

View File

@ -78,7 +78,7 @@ class ShowController extends Controller
$manager = $this->getManager();
// types to get, page size:
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
// get list of budgets. Count it and split it.
$collection = $this->ruleRepository->getAll();

View File

@ -71,7 +71,7 @@ class StoreController extends Controller
*/
public function store(StoreRequest $request): JsonResponse
{
$rule = $this->ruleRepository->store($request->getAll());
$rule = $this->ruleRepository->store($request->getAll());
$manager = $this->getManager();
/** @var RuleTransformer $transformer */
$transformer = app(RuleTransformer::class);

View File

@ -73,8 +73,8 @@ class UpdateController extends Controller
*/
public function update(UpdateRequest $request, Rule $rule): JsonResponse
{
$data = $request->getAll();
$rule = $this->ruleRepository->update($rule, $data);
$data = $request->getAll();
$rule = $this->ruleRepository->update($rule, $data);
$manager = $this->getManager();
/** @var RuleTransformer $transformer */

View File

@ -76,7 +76,7 @@ class ListController extends Controller
{
$manager = $this->getManager();
// types to get, page size:
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
// get list of budgets. Count it and split it.
$collection = $this->ruleGroupRepository->getRules($group);

View File

@ -76,7 +76,7 @@ class ShowController extends Controller
{
$manager = $this->getManager();
// types to get, page size:
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
// get list of rule groups. Count it and split it.
$collection = $this->ruleGroupRepository->get();

View File

@ -38,7 +38,7 @@ use League\Fractal\Resource\Item;
class StoreController extends Controller
{
private AccountRepositoryInterface $accountRepository;
private AccountRepositoryInterface $accountRepository;
private RuleGroupRepositoryInterface $ruleGroupRepository;
/**

View File

@ -81,7 +81,7 @@ class ListController extends Controller
public function attachments(Tag $tag): JsonResponse
{
$manager = $this->getManager();
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$collection = $this->repository->getAttachments($tag);
$count = $collection->count();
@ -116,7 +116,7 @@ class ListController extends Controller
*/
public function transactions(Request $request, Tag $tag): JsonResponse
{
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$type = $request->get('type') ?? 'default';
$this->parameters->set('type', $type);

View File

@ -77,7 +77,7 @@ class ShowController extends Controller
{
$manager = $this->getManager();
// types to get, page size:
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
// get list of budgets. Count it and split it.
$collection = $this->repository->get();

View File

@ -71,7 +71,7 @@ class StoreController extends Controller
*/
public function store(StoreRequest $request): JsonResponse
{
$rule = $this->repository->store($request->getAll());
$rule = $this->repository->store($request->getAll());
$manager = $this->getManager();
/** @var TagTransformer $transformer */
$transformer = app(TagTransformer::class);

View File

@ -73,7 +73,7 @@ class UpdateController extends Controller
*/
public function update(UpdateRequest $request, Tag $tag): JsonResponse
{
$rule = $this->repository->update($tag, $request->getAll());
$rule = $this->repository->update($tag, $request->getAll());
$manager = $this->getManager();
/** @var TagTransformer $transformer */
$transformer = app(TagTransformer::class);

View File

@ -79,7 +79,7 @@ class ListController extends Controller
public function attachments(TransactionGroup $transactionGroup): JsonResponse
{
$manager = $this->getManager();
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$collection = new Collection;
foreach ($transactionGroup->transactionJournals as $transactionJournal) {
$collection = $this->journalAPIRepository->getAttachments($transactionJournal)->merge($collection);
@ -116,7 +116,7 @@ class ListController extends Controller
{
$manager = $this->getManager();
$collection = new Collection;
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
foreach ($transactionGroup->transactionJournals as $transactionJournal) {
$collection = $this->journalAPIRepository->getPiggyBankEvents($transactionJournal)->merge($collection);
}
@ -155,7 +155,7 @@ class ListController extends Controller
{
$manager = $this->getManager();
$collection = $this->journalAPIRepository->getJournalLinks($transactionJournal);
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$count = $collection->count();
$journalLinks = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);

View File

@ -59,7 +59,7 @@ class ShowController extends Controller
*/
public function index(Request $request): JsonResponse
{
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$type = $request->get('type') ?? 'default';
$this->parameters->set('type', $type);

View File

@ -50,7 +50,7 @@ class DestroyController extends Controller
parent::__construct();
$this->middleware(
function ($request, $next) {
$this->repository = app(CurrencyRepositoryInterface::class);
$this->repository = app(CurrencyRepositoryInterface::class);
$this->userRepository = app(UserRepositoryInterface::class);
$this->repository->setUser(auth()->user());

View File

@ -109,7 +109,7 @@ class ListController extends Controller
// types to get, page size:
$types = $this->mapAccountTypes($this->parameters->get('type'));
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
// get list of accounts. Count it and split it.
/** @var AccountRepositoryInterface $accountRepository */
@ -119,7 +119,7 @@ class ListController extends Controller
// filter list on currency preference:
$collection = $unfiltered->filter(
static function (Account $account) use ($currency, $accountRepository) {
$currencyId = (int)$accountRepository->getMetaValue($account, 'currency_id');
$currencyId = (int) $accountRepository->getMetaValue($account, 'currency_id');
return $currencyId === $currency->id;
}
@ -157,7 +157,7 @@ class ListController extends Controller
{
$manager = $this->getManager();
// types to get, page size:
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
// get list of available budgets. Count it and split it.
/** @var AvailableBudgetRepositoryInterface $abRepository */
@ -198,7 +198,7 @@ class ListController extends Controller
/** @var BillRepositoryInterface $billRepos */
$billRepos = app(BillRepositoryInterface::class);
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$unfiltered = $billRepos->getBills();
// filter and paginate list:
@ -242,7 +242,7 @@ class ListController extends Controller
$blRepository = app(BudgetLimitRepositoryInterface::class);
$manager = $this->getManager();
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$collection = $blRepository->getAllBudgetLimitsByCurrency($currency, $this->parameters->get('start'), $this->parameters->get('end'));
$count = $collection->count();
$budgetLimits = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
@ -275,7 +275,7 @@ class ListController extends Controller
{
$manager = $this->getManager();
// types to get, page size:
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
// get list of budgets. Count it and split it.
/** @var RecurringRepositoryInterface $recurringRepos */
@ -328,7 +328,7 @@ class ListController extends Controller
public function rules(TransactionCurrency $currency): JsonResponse
{
$manager = $this->getManager();
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
// get list of budgets. Count it and split it.
/** @var RuleRepositoryInterface $ruleRepos */
@ -382,7 +382,7 @@ class ListController extends Controller
*/
public function transactions(Request $request, TransactionCurrency $currency): JsonResponse
{
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$type = $request->get('type') ?? 'default';
$this->parameters->set('type', $type);

View File

@ -76,7 +76,7 @@ class ShowController extends Controller
*/
public function index(): JsonResponse
{
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$collection = $this->repository->getAll();
$count = $collection->count();
// slice them:

View File

@ -83,12 +83,12 @@ class ShowController extends Controller
$name = $request->get('name');
// types to get, page size:
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$linkType = $this->repository->findByName($name);
// get list of transaction links. Count it and split it.
$collection = $this->repository->getJournalLinks($linkType);
$count = $collection->count();
$collection = $this->repository->getJournalLinks($linkType);
$count = $collection->count();
$journalLinks = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
// make paginator:

View File

@ -82,7 +82,7 @@ class ListController extends Controller
*/
public function transactions(Request $request, LinkType $linkType): JsonResponse
{
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$type = $request->get('type') ?? 'default';
$this->parameters->set('type', $type);

View File

@ -82,7 +82,7 @@ class ShowController extends Controller
{
// create some objects:
$manager = $this->getManager();
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
// get list of accounts. Count it and split it.
$collection = $this->repository->get();

View File

@ -70,8 +70,8 @@ class AccountController extends Controller
{
Log::debug('Now in account search()');
$manager = $this->getManager();
$query = trim((string)$request->get('query'));
$field = trim((string)$request->get('field'));
$query = trim((string) $request->get('query'));
$field = trim((string) $request->get('field'));
$type = $request->get('type') ?? 'all';
if ('' === $query || !in_array($field, $this->validFields, true)) {
return response(null, 422);

View File

@ -51,10 +51,10 @@ class TransactionController extends Controller
public function search(Request $request, SearchInterface $searcher): JsonResponse
{
$manager = $this->getManager();
$fullQuery = (string)$request->get('query');
$page = 0 === (int)$request->get('page') ? 1 : (int)$request->get('page');
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = 0 === (int)$request->get('limit') ? $pageSize : (int)$request->get('limit');
$fullQuery = (string) $request->get('query');
$page = 0 === (int) $request->get('page') ? 1 : (int) $request->get('page');
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = 0 === (int) $request->get('limit') ? $pageSize : (int) $request->get('limit');
$searcher->parseQuery($fullQuery);
$searcher->setPage($page);
$searcher->setLimit($pageSize);

View File

@ -148,7 +148,7 @@ class BasicController extends Controller
$set = $collector->getExtractedJournals();
/** @var array $transactionJournal */
foreach ($set as $transactionJournal) {
$currencyId = (int)$transactionJournal['currency_id'];
$currencyId = (int) $transactionJournal['currency_id'];
$incomes[$currencyId] = $incomes[$currencyId] ?? '0';
$incomes[$currencyId] = bcadd($incomes[$currencyId],
bcmul($transactionJournal['amount'], '-1')
@ -170,7 +170,7 @@ class BasicController extends Controller
/** @var array $transactionJournal */
foreach ($set as $transactionJournal) {
$currencyId = (int)$transactionJournal['currency_id'];
$currencyId = (int) $transactionJournal['currency_id'];
$expenses[$currencyId] = $expenses[$currencyId] ?? '0';
$expenses[$currencyId] = bcadd($expenses[$currencyId], $transactionJournal['amount']);
$sums[$currencyId] = $sums[$currencyId] ?? '0';
@ -188,7 +188,7 @@ class BasicController extends Controller
$return[] = [
'key' => sprintf('balance-in-%s', $currency->code),
'title' => trans('firefly.box_balance_in_currency', ['currency' => $currency->symbol]),
'monetary_value' => round((float)$sums[$currencyId] ?? 0, $currency->decimal_places),
'monetary_value' => round((float) $sums[$currencyId] ?? 0, $currency->decimal_places),
'currency_id' => $currency->id,
'currency_code' => $currency->code,
'currency_symbol' => $currency->symbol,
@ -201,7 +201,7 @@ class BasicController extends Controller
$return[] = [
'key' => sprintf('spent-in-%s', $currency->code),
'title' => trans('firefly.box_spent_in_currency', ['currency' => $currency->symbol]),
'monetary_value' => round((float)($expenses[$currencyId] ?? 0), $currency->decimal_places),
'monetary_value' => round((float) ($expenses[$currencyId] ?? 0), $currency->decimal_places),
'currency_id' => $currency->id,
'currency_code' => $currency->code,
'currency_symbol' => $currency->symbol,
@ -213,7 +213,7 @@ class BasicController extends Controller
$return[] = [
'key' => sprintf('earned-in-%s', $currency->code),
'title' => trans('firefly.box_earned_in_currency', ['currency' => $currency->symbol]),
'monetary_value' => round((float)($incomes[$currencyId] ?? 0), $currency->decimal_places),
'monetary_value' => round((float) ($incomes[$currencyId] ?? 0), $currency->decimal_places),
'currency_id' => $currency->id,
'currency_code' => $currency->code,
'currency_symbol' => $currency->symbol,
@ -244,14 +244,14 @@ class BasicController extends Controller
$return = [];
foreach ($paidAmount as $currencyId => $amount) {
$amount = bcmul($amount, '-1');
$currency = $this->currencyRepos->find((int)$currencyId);
$currency = $this->currencyRepos->find((int) $currencyId);
if (null === $currency) {
continue;
}
$return[] = [
'key' => sprintf('bills-paid-in-%s', $currency->code),
'title' => trans('firefly.box_bill_paid_in_currency', ['currency' => $currency->symbol]),
'monetary_value' => round((float)$amount, $currency->decimal_places),
'monetary_value' => round((float) $amount, $currency->decimal_places),
'currency_id' => $currency->id,
'currency_code' => $currency->code,
'currency_symbol' => $currency->symbol,
@ -264,14 +264,14 @@ class BasicController extends Controller
foreach ($unpaidAmount as $currencyId => $amount) {
$amount = bcmul($amount, '-1');
$currency = $this->currencyRepos->find((int)$currencyId);
$currency = $this->currencyRepos->find((int) $currencyId);
if (null === $currency) {
continue;
}
$return[] = [
'key' => sprintf('bills-unpaid-in-%s', $currency->code),
'title' => trans('firefly.box_bill_unpaid_in_currency', ['currency' => $currency->symbol]),
'monetary_value' => round((float)$amount, $currency->decimal_places),
'monetary_value' => round((float) $amount, $currency->decimal_places),
'currency_id' => $currency->id,
'currency_code' => $currency->code,
'currency_symbol' => $currency->symbol,
@ -309,20 +309,20 @@ class BasicController extends Controller
$days = $today->diffInDays($end) + 1;
$perDay = '0';
if (0 !== $days && bccomp($leftToSpend, '0') > -1) {
$perDay = bcdiv($leftToSpend, (string)$days);
$perDay = bcdiv($leftToSpend, (string) $days);
}
$return[] = [
'key' => sprintf('left-to-spend-in-%s', $row['currency_code']),
'title' => trans('firefly.box_left_to_spend_in_currency', ['currency' => $row['currency_symbol']]),
'monetary_value' => round((float)$leftToSpend, $row['currency_decimal_places']),
'monetary_value' => round((float) $leftToSpend, $row['currency_decimal_places']),
'currency_id' => $row['currency_id'],
'currency_code' => $row['currency_code'],
'currency_symbol' => $row['currency_symbol'],
'currency_decimal_places' => $row['currency_decimal_places'],
'value_parsed' => app('amount')->formatFlat($row['currency_symbol'], $row['currency_decimal_places'], $leftToSpend, false),
'local_icon' => 'money',
'sub_title' => (string)trans(
'sub_title' => (string) trans(
'firefly.box_spend_per_day',
['amount' => app('amount')->formatFlat(
$row['currency_symbol'],
@ -373,7 +373,7 @@ class BasicController extends Controller
foreach ($netWorthSet as $data) {
/** @var TransactionCurrency $currency */
$currency = $data['currency'];
$amount = round((float)$data['balance'], $currency->decimal_places);
$amount = round((float) $data['balance'], $currency->decimal_places);
if (0.0 === $amount) {
continue;
}

View File

@ -104,8 +104,8 @@ class ConfigurationController extends Controller
return [
'is_demo_site' => $isDemoSite?->data,
'permission_update_check' => null === $updateCheck ? null : (int)$updateCheck->data,
'last_update_check' => null === $lastCheck ? null : (int)$lastCheck->data,
'permission_update_check' => null === $updateCheck ? null : (int) $updateCheck->data,
'last_update_check' => null === $lastCheck ? null : (int) $lastCheck->data,
'single_user_mode' => $singleUser?->data,
];
}

View File

@ -102,7 +102,7 @@ class UserController extends Controller
public function index(): JsonResponse
{
// user preferences
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$manager = $this->getManager();
// build collection

View File

@ -59,7 +59,7 @@ class PreferencesController extends Controller
$collection = app('preferences')->all();
$manager = $this->getManager();
$count = $collection->count();
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$preferences = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
// make paginator:

View File

@ -77,7 +77,7 @@ class AttemptController extends Controller
}
$manager = $this->getManager();
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$collection = $this->repository->getAttempts($message);
$count = $collection->count();
$attempts = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);

View File

@ -68,7 +68,7 @@ class MessageController extends Controller
public function index(Webhook $webhook): JsonResponse
{
$manager = $this->getManager();
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$collection = $this->repository->getMessages($webhook);
$count = $collection->count();

View File

@ -70,11 +70,11 @@ class ShowController extends Controller
*/
public function index(): JsonResponse
{
$manager = $this->getManager();
$manager = $this->getManager();
$collection = $this->repository->all();
$pageSize = (int)app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$count = $collection->count();
$webhooks = $collection->slice(($this->parameters->get('page') - 1) * $pageSize, $pageSize);
$pageSize = (int) app('preferences')->getForUser(auth()->user(), 'listPageSize', 50)->data;
$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'));

View File

@ -64,7 +64,7 @@ class StoreController extends Controller
*/
public function store(CreateRequest $request): JsonResponse
{
$data = $request->getData();
$data = $request->getData();
$webhook = $this->repository->store($data);
$manager = $this->getManager();
/** @var WebhookTransformer $transformer */

View File

@ -76,10 +76,10 @@ class MoveTransactionsRequest extends FormRequest
if (array_key_exists('original_account', $data) && array_key_exists('destination_account', $data)) {
$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']);
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;
}
@ -87,7 +87,7 @@ class MoveTransactionsRequest extends FormRequest
$originalCurrency = $repository->getAccountCurrency($original);
$destinationCurrency = $repository->getAccountCurrency($destination);
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;
}
@ -96,7 +96,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'));
}
}
}

View File

@ -51,7 +51,7 @@ class ExportRequest extends FormRequest
$accounts = new Collection;
foreach ($parts as $part) {
$accountId = (int)$part;
$accountId = (int) $part;
if (0 !== $accountId) {
$account = $repository->find($accountId);
if (null !== $account && AccountType::ASSET === $account->accountType->type) {

View File

@ -94,7 +94,7 @@ class GenericRequest extends FormRequest
$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);
@ -126,7 +126,7 @@ class GenericRequest extends FormRequest
$array = $this->get('bills');
if (is_array($array)) {
foreach ($array as $billId) {
$billId = (int)$billId;
$billId = (int) $billId;
$bill = $repository->find($billId);
if (null !== $billId) {
$this->bills->push($bill);
@ -158,7 +158,7 @@ class GenericRequest extends FormRequest
$array = $this->get('budgets');
if (is_array($array)) {
foreach ($array as $budgetId) {
$budgetId = (int)$budgetId;
$budgetId = (int) $budgetId;
$budget = $repository->find($budgetId);
if (null !== $budgetId) {
$this->budgets->push($budget);
@ -190,7 +190,7 @@ class GenericRequest extends FormRequest
$array = $this->get('categories');
if (is_array($array)) {
foreach ($array as $categoryId) {
$categoryId = (int)$categoryId;
$categoryId = (int) $categoryId;
$category = $repository->find($categoryId);
if (null !== $categoryId) {
$this->categories->push($category);
@ -280,7 +280,7 @@ class GenericRequest extends FormRequest
$array = $this->get('tags');
if (is_array($array)) {
foreach ($array as $tagId) {
$tagId = (int)$tagId;
$tagId = (int) $tagId;
$tag = $repository->find($tagId);
if (null !== $tagId) {
$this->tags->push($tag);

View File

@ -90,7 +90,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'));
}
}
}

View File

@ -104,10 +104,10 @@ class StoreRequest extends FormRequest
$validator->after(
static function (Validator $validator) {
$data = $validator->getData();
$min = (float)($data['amount_min'] ?? 0);
$max = (float)($data['amount_max'] ?? 0);
$min = (float) ($data['amount_min'] ?? 0);
$max = (float) ($data['amount_max'] ?? 0);
if ($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'));
}
}
);

View File

@ -105,10 +105,10 @@ class UpdateRequest extends FormRequest
static function (Validator $validator) {
$data = $validator->getData();
if (array_key_exists('amount_min', $data) && array_key_exists('amount_max', $data)) {
$min = (float)($data['amount_min'] ?? 0);
$max = (float)($data['amount_max'] ?? 0);
$min = (float) ($data['amount_min'] ?? 0);
$max = (float) ($data['amount_max'] ?? 0);
if ($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'));
}
}
}

View File

@ -90,7 +90,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'));
}
}
}

View File

@ -115,10 +115,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;
@ -135,19 +135,19 @@ class StoreRequest extends FormRequest
public function rules(): array
{
return [
'type' => 'required|in:withdrawal,transfer,deposit',
'title' => 'required|between:1,255|uniqueObjectForUser:recurrences,title',
'description' => 'between:1,65000',
'first_date' => 'required|date',
'apply_rules' => [new IsBoolean],
'active' => [new IsBoolean],
'repeat_until' => 'nullable|date',
'nr_of_repetitions' => 'nullable|numeric|between:1,31',
'type' => 'required|in:withdrawal,transfer,deposit',
'title' => 'required|between:1,255|uniqueObjectForUser:recurrences,title',
'description' => 'between:1,65000',
'first_date' => 'required|date',
'apply_rules' => [new IsBoolean],
'active' => [new IsBoolean],
'repeat_until' => 'nullable|date',
'nr_of_repetitions' => 'nullable|numeric|between:1,31',
'repetitions.*.type' => 'required|in:daily,weekly,ndom,monthly,yearly',
'repetitions.*.moment' => 'between:0,10',
'repetitions.*.skip' => 'nullable|numeric|between:0,31',
'repetitions.*.weekend' => 'numeric|min:1|max:4',
'repetitions.*.type' => 'required|in:daily,weekly,ndom,monthly,yearly',
'repetitions.*.moment' => 'between:0,10',
'repetitions.*.skip' => 'nullable|numeric|between:0,31',
'repetitions.*.weekend' => 'numeric|min:1|max:4',
'transactions.*.description' => 'required|between:1,255',
'transactions.*.amount' => 'required|numeric|gt:0',
@ -162,11 +162,11 @@ class StoreRequest extends FormRequest
'transactions.*.destination_name' => 'between:1,255|nullable',
// new and updated fields:
'transactions.*.budget_id' => ['nullable','mustExist:budgets,id', new BelongsUser],
'transactions.*.budget_id' => ['nullable', 'mustExist:budgets,id', new BelongsUser],
'transactions.*.budget_name' => ['between:1,255', 'nullable', new BelongsUser],
'transactions.*.category_id' => ['nullable','mustExist:categories,id', new BelongsUser],
'transactions.*.category_id' => ['nullable', 'mustExist:categories,id', new BelongsUser],
'transactions.*.category_name' => 'between:1,255|nullable',
'transactions.*.piggy_bank_id' => ['nullable','numeric', 'mustExist:piggy_banks,id', new BelongsUser],
'transactions.*.piggy_bank_id' => ['nullable', 'numeric', 'mustExist:piggy_banks,id', new BelongsUser],
'transactions.*.piggy_bank_name' => ['between:1,255', 'nullable', new BelongsUser],
'transactions.*.tags' => 'nullable|between:1,64000',
];

View File

@ -97,15 +97,15 @@ class UpdateRequest extends FormRequest
}
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;
}
@ -150,13 +150,13 @@ class UpdateRequest extends FormRequest
$recurrence = $this->route()->parameter('recurrence');
return [
'title' => sprintf('between:1,255|uniqueObjectForUser:recurrences,title,%d', $recurrence->id),
'description' => 'between:1,65000',
'first_date' => 'date',
'apply_rules' => [new IsBoolean],
'active' => [new IsBoolean],
'repeat_until' => 'nullable|date',
'nr_of_repetitions' => 'nullable|numeric|between:1,31',
'title' => sprintf('between:1,255|uniqueObjectForUser:recurrences,title,%d', $recurrence->id),
'description' => 'between:1,65000',
'first_date' => 'date',
'apply_rules' => [new IsBoolean],
'active' => [new IsBoolean],
'repeat_until' => 'nullable|date',
'nr_of_repetitions' => 'nullable|numeric|between:1,31',
'repetitions.*.type' => 'in:daily,weekly,ndom,monthly,yearly',
'repetitions.*.moment' => 'between:0,10',
@ -176,11 +176,11 @@ class UpdateRequest extends FormRequest
'transactions.*.destination_name' => 'between:1,255|nullable',
// new and updated fields:
'transactions.*.budget_id' => ['nullable','mustExist:budgets,id', new BelongsUser],
'transactions.*.budget_id' => ['nullable', 'mustExist:budgets,id', new BelongsUser],
'transactions.*.budget_name' => ['between:1,255', 'nullable', new BelongsUser],
'transactions.*.category_id' => ['nullable','mustExist:categories,id', new BelongsUser],
'transactions.*.category_id' => ['nullable', 'mustExist:categories,id', new BelongsUser],
'transactions.*.category_name' => 'between:1,255|nullable',
'transactions.*.piggy_bank_id' => ['nullable','numeric', 'mustExist:piggy_banks,id', new BelongsUser],
'transactions.*.piggy_bank_id' => ['nullable', 'numeric', 'mustExist:piggy_banks,id', new BelongsUser],
'transactions.*.piggy_bank_name' => ['between:1,255', 'nullable', new BelongsUser],
'transactions.*.tags' => 'nullable|between:1,64000',

View File

@ -76,8 +76,8 @@ class StoreRequest extends FormRequest
$return[] = [
'type' => $trigger['type'],
'value' => $trigger['value'],
'active' => $this->convertBoolean((string)($trigger['active'] ?? 'false')),
'stop_processing' => $this->convertBoolean((string)($trigger['stop_processing'] ?? 'false')),
'active' => $this->convertBoolean((string) ($trigger['active'] ?? 'false')),
'stop_processing' => $this->convertBoolean((string) ($trigger['stop_processing'] ?? 'false')),
];
}
}
@ -97,8 +97,8 @@ class StoreRequest 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')),
];
}
}
@ -170,7 +170,22 @@ class StoreRequest extends FormRequest
$triggers = $data['triggers'] ?? [];
// need at least one trigger
if (!is_countable($triggers) || empty($triggers)) {
$validator->errors()->add('title', (string)trans('validation.at_least_one_trigger'));
$validator->errors()->add('title', (string) trans('validation.at_least_one_trigger'));
}
}
/**
* Adds an error to the validator when there are no repetitions in the array of data.
*
* @param Validator $validator
*/
protected function atLeastOneAction(Validator $validator): void
{
$data = $validator->getData();
$actions = $data['actions'] ?? [];
// need at least one trigger
if (!is_countable($actions) || empty($actions)) {
$validator->errors()->add('title', (string) trans('validation.at_least_one_action'));
}
}
@ -199,7 +214,7 @@ class StoreRequest extends FormRequest
}
}
if (true === $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'));
}
}
@ -228,22 +243,7 @@ class StoreRequest extends FormRequest
}
}
if (true === $allInactive) {
$validator->errors()->add(sprintf('actions.%d.active', $inactiveIndex), (string)trans('validation.at_least_one_active_action'));
}
}
/**
* Adds an error to the validator when there are no repetitions in the array of data.
*
* @param Validator $validator
*/
protected function atLeastOneAction(Validator $validator): void
{
$data = $validator->getData();
$actions = $data['actions'] ?? [];
// need at least one trigger
if (!is_countable($actions) || empty($actions)) {
$validator->errors()->add('title', (string)trans('validation.at_least_one_action'));
$validator->errors()->add(sprintf('actions.%d.active', $inactiveIndex), (string) trans('validation.at_least_one_active_action'));
}
}
}

View File

@ -55,7 +55,7 @@ class TestRequest extends FormRequest
*/
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');
}

Some files were not shown because too many files have changed in this diff Show More