Fix bad call to method.

This commit is contained in:
James Cole
2022-05-02 19:35:35 +02:00
parent cf89d93cec
commit 2b615cf757
49 changed files with 157 additions and 157 deletions

View File

@@ -40,7 +40,7 @@ class AutocompleteRequest extends FormRequest
*/ */
public function getData(): array public function getData(): array
{ {
$types = $this->string('types'); $types = $this->convertString('types');
$array = []; $array = [];
if ('' !== $types) { if ('' !== $types) {
$array = explode(',', $types); $array = explode(',', $types);
@@ -53,7 +53,7 @@ class AutocompleteRequest extends FormRequest
return [ return [
'types' => $array, 'types' => $array,
'query' => $this->string('query'), 'query' => $this->convertString('query'),
'date' => $this->getCarbonDate('date'), 'date' => $this->getCarbonDate('date'),
'limit' => $limit, 'limit' => $limit,
]; ];

View File

@@ -43,9 +43,9 @@ class ExportRequest extends FormRequest
$result = [ $result = [
'start' => $this->getCarbonDate('start') ?? Carbon::now()->subYear(), 'start' => $this->getCarbonDate('start') ?? Carbon::now()->subYear(),
'end' => $this->getCarbonDate('end') ?? Carbon::now(), 'end' => $this->getCarbonDate('end') ?? Carbon::now(),
'type' => $this->string('type'), 'type' => $this->convertString('type'),
]; ];
$parts = explode(',', $this->string('accounts')); $parts = explode(',', $this->convertString('accounts'));
$repository = app(AccountRepositoryInterface::class); $repository = app(AccountRepositoryInterface::class);
$repository->setUser(auth()->user()); $repository->setUser(auth()->user());

View File

@@ -56,35 +56,35 @@ class StoreRequest extends FormRequest
$includeNetWorth = $this->boolean('include_net_worth'); $includeNetWorth = $this->boolean('include_net_worth');
} }
$data = [ $data = [
'name' => $this->string('name'), 'name' => $this->convertString('name'),
'active' => $active, 'active' => $active,
'include_net_worth' => $includeNetWorth, 'include_net_worth' => $includeNetWorth,
'account_type_name' => $this->string('type'), 'account_type_name' => $this->convertString('type'),
'account_type_id' => null, 'account_type_id' => null,
'currency_id' => $this->integer('currency_id'), 'currency_id' => $this->integer('currency_id'),
'order' => $this->integer('order'), 'order' => $this->integer('order'),
'currency_code' => $this->string('currency_code'), 'currency_code' => $this->convertString('currency_code'),
'virtual_balance' => $this->string('virtual_balance'), 'virtual_balance' => $this->convertString('virtual_balance'),
'iban' => $this->string('iban'), 'iban' => $this->convertString('iban'),
'BIC' => $this->string('bic'), 'BIC' => $this->convertString('bic'),
'account_number' => $this->string('account_number'), 'account_number' => $this->convertString('account_number'),
'account_role' => $this->string('account_role'), 'account_role' => $this->convertString('account_role'),
'opening_balance' => $this->string('opening_balance'), 'opening_balance' => $this->convertString('opening_balance'),
'opening_balance_date' => $this->getCarbonDate('opening_balance_date'), 'opening_balance_date' => $this->getCarbonDate('opening_balance_date'),
'cc_type' => $this->string('credit_card_type'), 'cc_type' => $this->convertString('credit_card_type'),
'cc_monthly_payment_date' => $this->string('monthly_payment_date'), 'cc_monthly_payment_date' => $this->convertString('monthly_payment_date'),
'notes' => $this->stringWithNewlines('notes'), 'notes' => $this->stringWithNewlines('notes'),
'interest' => $this->string('interest'), 'interest' => $this->convertString('interest'),
'interest_period' => $this->string('interest_period'), 'interest_period' => $this->convertString('interest_period'),
]; ];
// append location information. // append location information.
$data = $this->appendLocationData($data, null); $data = $this->appendLocationData($data, null);
if ('liability' === $data['account_type_name'] || 'liabilities' === $data['account_type_name']) { if ('liability' === $data['account_type_name'] || 'liabilities' === $data['account_type_name']) {
$data['opening_balance'] = app('steam')->negative($this->string('liability_amount')); $data['opening_balance'] = app('steam')->negative($this->convertString('liability_amount'));
$data['opening_balance_date'] = $this->getCarbonDate('liability_start_date'); $data['opening_balance_date'] = $this->getCarbonDate('liability_start_date');
$data['account_type_name'] = $this->string('liability_type'); $data['account_type_name'] = $this->convertString('liability_type');
$data['liability_direction'] = $this->string('liability_direction'); $data['liability_direction'] = $this->convertString('liability_direction');
$data['account_type_id'] = null; $data['account_type_id'] = null;
} }
@@ -101,7 +101,7 @@ class StoreRequest extends FormRequest
$accountRoles = implode(',', config('firefly.accountRoles')); $accountRoles = implode(',', config('firefly.accountRoles'));
$types = implode(',', array_keys(config('firefly.subTitlesByIdentifier'))); $types = implode(',', array_keys(config('firefly.subTitlesByIdentifier')));
$ccPaymentTypes = implode(',', array_keys(config('firefly.ccTypes'))); $ccPaymentTypes = implode(',', array_keys(config('firefly.ccTypes')));
$type = $this->string('type'); $type = $this->convertString('type');
$rules = [ $rules = [
'name' => 'required|min:1|uniqueAccountForUser', 'name' => 'required|min:1|uniqueAccountForUser',
'type' => 'required|' . sprintf('in:%s', $types), 'type' => 'required|' . sprintf('in:%s', $types),

View File

@@ -107,9 +107,9 @@ class UpdateRequest extends FormRequest
$rules = [ $rules = [
'name' => sprintf('min:1|uniqueAccountForUser:%d', $account->id), 'name' => sprintf('min:1|uniqueAccountForUser:%d', $account->id),
'type' => sprintf('in:%s', $types), 'type' => sprintf('in:%s', $types),
'iban' => ['iban', 'nullable', new UniqueIban($account, $this->string('type'))], 'iban' => ['iban', 'nullable', new UniqueIban($account, $this->convertString('type'))],
'bic' => 'bic|nullable', 'bic' => 'bic|nullable',
'account_number' => ['between:1,255', 'nullable', new UniqueAccountNumber($account, $this->string('type'))], 'account_number' => ['between:1,255', 'nullable', new UniqueAccountNumber($account, $this->convertString('type'))],
'opening_balance' => 'numeric|required_with:opening_balance_date|nullable', 'opening_balance' => 'numeric|required_with:opening_balance_date|nullable',
'opening_balance_date' => 'date|required_with:opening_balance|nullable', 'opening_balance_date' => 'date|required_with:opening_balance|nullable',
'virtual_balance' => 'numeric|nullable', 'virtual_balance' => 'numeric|nullable',

View File

@@ -45,10 +45,10 @@ class StoreRequest extends FormRequest
public function getAll(): array public function getAll(): array
{ {
return [ return [
'filename' => $this->string('filename'), 'filename' => $this->convertString('filename'),
'title' => $this->string('title'), 'title' => $this->convertString('title'),
'notes' => $this->stringWithNewlines('notes'), 'notes' => $this->stringWithNewlines('notes'),
'attachable_type' => $this->string('attachable_type'), 'attachable_type' => $this->convertString('attachable_type'),
'attachable_id' => $this->integer('attachable_id'), 'attachable_id' => $this->integer('attachable_id'),
]; ];
} }
@@ -68,7 +68,7 @@ class StoreRequest extends FormRequest
}, $models }, $models
); );
$models = implode(',', $models); $models = implode(',', $models);
$model = $this->string('attachable_type'); $model = $this->convertString('attachable_type');
return [ return [
'filename' => 'required|between:1,255', 'filename' => 'required|between:1,255',

View File

@@ -70,7 +70,7 @@ class UpdateRequest extends FormRequest
}, $models }, $models
); );
$models = implode(',', $models); $models = implode(',', $models);
$model = $this->string('attachable_type'); $model = $this->convertString('attachable_type');
return [ return [
'filename' => 'between:1,255', 'filename' => 'between:1,255',

View File

@@ -46,9 +46,9 @@ class StoreRequest extends FormRequest
return [ return [
'start' => $this->getCarbonDate('start'), 'start' => $this->getCarbonDate('start'),
'end' => $this->getCarbonDate('end'), 'end' => $this->getCarbonDate('end'),
'amount' => $this->string('amount'), 'amount' => $this->convertString('amount'),
'currency_id' => $this->integer('currency_id'), 'currency_id' => $this->integer('currency_id'),
'currency_code' => $this->string('currency_code'), 'currency_code' => $this->convertString('currency_code'),
]; ];
} }

View File

@@ -45,7 +45,7 @@ class StoreRequest extends FormRequest
public function getAll(): array public function getAll(): array
{ {
return [ return [
'name' => $this->string('name'), 'name' => $this->convertString('name'),
'notes' => $this->stringWithNewlines('notes'), 'notes' => $this->stringWithNewlines('notes'),
]; ];
} }

View File

@@ -47,15 +47,15 @@ class StoreRequest extends FormRequest
'order' => ['order', 'integer'], 'order' => ['order', 'integer'],
]; ];
$data = $this->getAllData($fields); $data = $this->getAllData($fields);
$data['name'] = $this->string('name'); $data['name'] = $this->convertString('name');
$data['account_id'] = $this->integer('account_id'); $data['account_id'] = $this->integer('account_id');
$data['targetamount'] = $this->string('target_amount'); $data['targetamount'] = $this->convertString('target_amount');
$data['current_amount'] = $this->string('current_amount'); $data['current_amount'] = $this->convertString('current_amount');
$data['startdate'] = $this->getCarbonDate('start_date'); $data['startdate'] = $this->getCarbonDate('start_date');
$data['targetdate'] = $this->getCarbonDate('target_date'); $data['targetdate'] = $this->getCarbonDate('target_date');
$data['notes'] = $this->stringWithNewlines('notes'); $data['notes'] = $this->stringWithNewlines('notes');
$data['object_group_id'] = $this->integer('object_group_id'); $data['object_group_id'] = $this->integer('object_group_id');
$data['object_group_title'] = $this->string('object_group_title'); $data['object_group_title'] = $this->convertString('object_group_title');
return $data; return $data;

View File

@@ -53,8 +53,8 @@ class StoreRequest extends FormRequest
} }
return [ return [
'title' => $this->string('title'), 'title' => $this->convertString('title'),
'description' => $this->string('description'), 'description' => $this->convertString('description'),
'active' => $active, 'active' => $active,
'order' => $order, 'order' => $order,
]; ];

View File

@@ -46,9 +46,9 @@ class StoreRequest extends FormRequest
public function getAll(): array public function getAll(): array
{ {
$data = [ $data = [
'tag' => $this->string('tag'), 'tag' => $this->convertString('tag'),
'date' => $this->getCarbonDate('date'), 'date' => $this->getCarbonDate('date'),
'description' => $this->string('description'), 'description' => $this->convertString('description'),
'has_location' => true, 'has_location' => true,
]; ];

View File

@@ -55,7 +55,7 @@ class StoreRequest extends FormRequest
Log::debug('get all data in TransactionStoreRequest'); Log::debug('get all data in TransactionStoreRequest');
return [ return [
'group_title' => $this->string('group_title'), 'group_title' => $this->convertString('group_title'),
'error_if_duplicate_hash' => $this->boolean('error_if_duplicate_hash'), 'error_if_duplicate_hash' => $this->boolean('error_if_duplicate_hash'),
'apply_rules' => $this->boolean('apply_rules', true), 'apply_rules' => $this->boolean('apply_rules', true),
'fire_webhooks' => $this->boolean('fire_webhooks', true), 'fire_webhooks' => $this->boolean('fire_webhooks', true),

View File

@@ -84,7 +84,7 @@ class UpdateRequest extends FormRequest
'notes', 'notes',
]; ];
$this->stringFields = [ $this->convertStringFields = [
'type', 'type',
'currency_code', 'currency_code',
'foreign_currency_code', 'foreign_currency_code',
@@ -133,7 +133,7 @@ class UpdateRequest extends FormRequest
$data['fire_webhooks'] = $this->boolean('fire_webhooks', true); $data['fire_webhooks'] = $this->boolean('fire_webhooks', true);
} }
if ($this->has('group_title')) { if ($this->has('group_title')) {
$data['group_title'] = $this->string('group_title'); $data['group_title'] = $this->convertString('group_title');
} }
return $data; return $data;
@@ -196,7 +196,7 @@ class UpdateRequest extends FormRequest
*/ */
private function getStringData(array $current, array $transaction): array private function getStringData(array $current, array $transaction): array
{ {
foreach ($this->stringFields as $fieldName) { foreach ($this->convertStringFields as $fieldName) {
if (array_key_exists($fieldName, $transaction)) { if (array_key_exists($fieldName, $transaction)) {
$current[$fieldName] = $this->clearString((string) $transaction[$fieldName], false); $current[$fieldName] = $this->clearString((string) $transaction[$fieldName], false);
} }

View File

@@ -54,9 +54,9 @@ class StoreRequest extends FormRequest
} }
return [ return [
'name' => $this->string('name'), 'name' => $this->convertString('name'),
'code' => $this->string('code'), 'code' => $this->convertString('code'),
'symbol' => $this->string('symbol'), 'symbol' => $this->convertString('symbol'),
'decimal_places' => $this->integer('decimal_places'), 'decimal_places' => $this->integer('decimal_places'),
'default' => $default, 'default' => $default,
'enabled' => $enabled, 'enabled' => $enabled,

View File

@@ -47,7 +47,7 @@ class StoreRequest extends FormRequest
{ {
return [ return [
'link_type_id' => $this->integer('link_type_id'), 'link_type_id' => $this->integer('link_type_id'),
'link_type_name' => $this->string('link_type_name'), 'link_type_name' => $this->convertString('link_type_name'),
'inward_id' => $this->integer('inward_id'), 'inward_id' => $this->integer('inward_id'),
'outward_id' => $this->integer('outward_id'), 'outward_id' => $this->integer('outward_id'),
'notes' => $this->stringWithNewlines('notes'), 'notes' => $this->stringWithNewlines('notes'),

View File

@@ -47,7 +47,7 @@ class UpdateRequest extends FormRequest
{ {
return [ return [
'link_type_id' => $this->integer('link_type_id'), 'link_type_id' => $this->integer('link_type_id'),
'link_type_name' => $this->string('link_type_name'), 'link_type_name' => $this->convertString('link_type_name'),
'inward_id' => $this->integer('inward_id'), 'inward_id' => $this->integer('inward_id'),
'outward_id' => $this->integer('outward_id'), 'outward_id' => $this->integer('outward_id'),
'notes' => $this->stringWithNewlines('notes'), 'notes' => $this->stringWithNewlines('notes'),

View File

@@ -44,9 +44,9 @@ class StoreRequest extends FormRequest
public function getAll(): array public function getAll(): array
{ {
return [ return [
'name' => $this->string('name'), 'name' => $this->convertString('name'),
'outward' => $this->string('outward'), 'outward' => $this->convertString('outward'),
'inward' => $this->string('inward'), 'inward' => $this->convertString('inward'),
]; ];
} }

View File

@@ -45,9 +45,9 @@ class UpdateRequest extends FormRequest
public function getAll(): array public function getAll(): array
{ {
return [ return [
'name' => $this->string('name'), 'name' => $this->convertString('name'),
'outward' => $this->string('outward'), 'outward' => $this->convertString('outward'),
'inward' => $this->string('inward'), 'inward' => $this->convertString('inward'),
]; ];
} }

View File

@@ -66,7 +66,7 @@ class UpdateRequest extends FormRequest
} }
$return['secret'] = null !== $this->get('secret'); $return['secret'] = null !== $this->get('secret');
if (null !== $this->get('title')) { if (null !== $this->get('title')) {
$return['title'] = $this->string('title'); $return['title'] = $this->convertString('title');
} }
return $return; return $return;

View File

@@ -57,7 +57,7 @@ class UpdateRequest extends FormRequest
return ['value' => $this->integer('value')]; return ['value' => $this->integer('value')];
} }
return ['value' => $this->string('value')]; return ['value' => $this->convertString('value')];
} }
/** /**

View File

@@ -59,10 +59,10 @@ class UserStoreRequest extends FormRequest
} }
return [ return [
'email' => $this->string('email'), 'email' => $this->convertString('email'),
'blocked' => $blocked, 'blocked' => $blocked,
'blocked_code' => $this->string('blocked_code'), 'blocked_code' => $this->convertString('blocked_code'),
'role' => $this->string('role'), 'role' => $this->convertString('role'),
]; ];
} }

View File

@@ -60,10 +60,10 @@ class UserUpdateRequest extends FormRequest
} }
return [ return [
'email' => $this->string('email'), 'email' => $this->convertString('email'),
'blocked' => $blocked, 'blocked' => $blocked,
'blocked_code' => $this->string('blocked_code'), 'blocked_code' => $this->convertString('blocked_code'),
'role' => $this->string('role'), 'role' => $this->convertString('role'),
]; ];
} }

View File

@@ -37,7 +37,7 @@ class PreferenceStoreRequest extends FormRequest
public function getAll(): array public function getAll(): array
{ {
$array = [ $array = [
'name' => $this->string('name'), 'name' => $this->convertString('name'),
'data' => $this->get('data'), 'data' => $this->get('data'),
]; ];
if ('true' === $array['data']) { if ('true' === $array['data']) {

View File

@@ -38,7 +38,7 @@ class PreferenceUpdateRequest extends FormRequest
public function getAll(): array public function getAll(): array
{ {
$array = [ $array = [
'name' => $this->string('name'), 'name' => $this->convertString('name'),
'data' => $this->get('data'), 'data' => $this->get('data'),
]; ];
if ('true' === $array['data']) { if ('true' === $array['data']) {

View File

@@ -217,9 +217,9 @@ class LinkController extends Controller
public function store(LinkTypeFormRequest $request) public function store(LinkTypeFormRequest $request)
{ {
$data = [ $data = [
'name' => $request->string('name'), 'name' => $request->convertString('name'),
'inward' => $request->string('inward'), 'inward' => $request->convertString('inward'),
'outward' => $request->string('outward'), 'outward' => $request->convertString('outward'),
]; ];
$linkType = $this->repository->store($data); $linkType = $this->repository->store($data);
@@ -255,9 +255,9 @@ class LinkController extends Controller
} }
$data = [ $data = [
'name' => $request->string('name'), 'name' => $request->convertString('name'),
'inward' => $request->string('inward'), 'inward' => $request->convertString('inward'),
'outward' => $request->string('outward'), 'outward' => $request->convertString('outward'),
]; ];
$this->repository->update($linkType, $data); $this->repository->update($linkType, $data);

View File

@@ -92,7 +92,7 @@ class NewUserController extends Controller
*/ */
public function submit(NewUserFormRequest $request, CurrencyRepositoryInterface $currencyRepository) public function submit(NewUserFormRequest $request, CurrencyRepositoryInterface $currencyRepository)
{ {
$language = $request->string('language'); $language = $request->convertString('language');
if (!array_key_exists($language, config('firefly.languages'))) { if (!array_key_exists($language, config('firefly.languages'))) {
$language = 'en_US'; $language = 'en_US';

View File

@@ -410,7 +410,7 @@ class ProfileController extends Controller
/** @var User $user */ /** @var User $user */
$user = auth()->user(); $user = auth()->user();
$newEmail = $request->string('email'); $newEmail = $request->convertString('email');
$oldEmail = $user->email; $oldEmail = $user->email;
if ($newEmail === $user->email) { if ($newEmail === $user->email) {
session()->flash('error', (string) trans('firefly.email_not_changed')); session()->flash('error', (string) trans('firefly.email_not_changed'));

View File

@@ -131,7 +131,7 @@ class EditController extends Controller
public function update(RuleGroupFormRequest $request, RuleGroup $ruleGroup) public function update(RuleGroupFormRequest $request, RuleGroup $ruleGroup)
{ {
$data = [ $data = [
'title' => $request->string('title'), 'title' => $request->convertString('title'),
'description' => $request->stringWithNewlines('description'), 'description' => $request->stringWithNewlines('description'),
'active' => 1 === (int) $request->input('active'), 'active' => 1 === (int) $request->input('active'),
]; ];

View File

@@ -110,8 +110,8 @@ class BulkController extends Controller
$journal = $this->repository->find($journalId); $journal = $this->repository->find($journalId);
if (null !== $journal) { if (null !== $journal) {
$resultA = $this->updateJournalBudget($journal, $ignoreBudget, $request->integer('budget_id')); $resultA = $this->updateJournalBudget($journal, $ignoreBudget, $request->integer('budget_id'));
$resultB = $this->updateJournalTags($journal, $tagsAction, explode(',', $request->string('tags'))); $resultB = $this->updateJournalTags($journal, $tagsAction, explode(',', $request->convertString('tags')));
$resultC = $this->updateJournalCategory($journal, $ignoreCategory, $request->string('category')); $resultC = $this->updateJournalCategory($journal, $ignoreCategory, $request->convertString('category'));
if ($resultA || $resultB || $resultC) { if ($resultA || $resultB || $resultC) {
$count++; $count++;
} }

View File

@@ -45,24 +45,24 @@ class AccountFormRequest extends FormRequest
public function getAccountData(): array public function getAccountData(): array
{ {
$data = [ $data = [
'name' => $this->string('name'), 'name' => $this->convertString('name'),
'active' => $this->boolean('active'), 'active' => $this->boolean('active'),
'account_type_name' => $this->string('objectType'), 'account_type_name' => $this->convertString('objectType'),
'currency_id' => $this->integer('currency_id'), 'currency_id' => $this->integer('currency_id'),
'virtual_balance' => $this->string('virtual_balance'), 'virtual_balance' => $this->convertString('virtual_balance'),
'iban' => $this->string('iban'), 'iban' => $this->convertString('iban'),
'BIC' => $this->string('BIC'), 'BIC' => $this->convertString('BIC'),
'account_number' => $this->string('account_number'), 'account_number' => $this->convertString('account_number'),
'account_role' => $this->string('account_role'), 'account_role' => $this->convertString('account_role'),
'opening_balance' => $this->string('opening_balance'), 'opening_balance' => $this->convertString('opening_balance'),
'opening_balance_date' => $this->getCarbonDate('opening_balance_date'), 'opening_balance_date' => $this->getCarbonDate('opening_balance_date'),
'cc_type' => $this->string('cc_type'), 'cc_type' => $this->convertString('cc_type'),
'cc_monthly_payment_date' => $this->string('cc_monthly_payment_date'), 'cc_monthly_payment_date' => $this->convertString('cc_monthly_payment_date'),
'notes' => $this->stringWithNewlines('notes'), 'notes' => $this->stringWithNewlines('notes'),
'interest' => $this->string('interest'), 'interest' => $this->convertString('interest'),
'interest_period' => $this->string('interest_period'), 'interest_period' => $this->convertString('interest_period'),
'include_net_worth' => '1', 'include_net_worth' => '1',
'liability_direction' => $this->string('liability_direction'), 'liability_direction' => $this->convertString('liability_direction'),
]; ];
$data = $this->appendLocationData($data, 'location'); $data = $this->appendLocationData($data, 'location');
@@ -100,7 +100,7 @@ class AccountFormRequest extends FormRequest
'name' => 'required|min:1|uniqueAccountForUser', 'name' => 'required|min:1|uniqueAccountForUser',
'opening_balance' => 'numeric|nullable|max:1000000000', 'opening_balance' => 'numeric|nullable|max:1000000000',
'opening_balance_date' => 'date|required_with:opening_balance|nullable', 'opening_balance_date' => 'date|required_with:opening_balance|nullable',
'iban' => ['iban', 'nullable', new UniqueIban(null, $this->string('objectType'))], 'iban' => ['iban', 'nullable', new UniqueIban(null, $this->convertString('objectType'))],
'BIC' => 'bic|nullable', 'BIC' => 'bic|nullable',
'virtual_balance' => 'numeric|nullable|max:1000000000', 'virtual_balance' => 'numeric|nullable|max:1000000000',
'currency_id' => 'exists:transaction_currencies,id', 'currency_id' => 'exists:transaction_currencies,id',

View File

@@ -43,8 +43,8 @@ class AttachmentFormRequest extends FormRequest
public function getAttachmentData(): array public function getAttachmentData(): array
{ {
return [ return [
'title' => $this->string('title'), 'title' => $this->convertString('title'),
'notes' => $this->string('notes'), 'notes' => $this->convertString('notes'),
]; ];
} }

View File

@@ -41,19 +41,19 @@ class BillStoreRequest extends FormRequest
public function getBillData(): array public function getBillData(): array
{ {
return [ return [
'name' => $this->string('name'), 'name' => $this->convertString('name'),
'amount_min' => $this->string('amount_min'), 'amount_min' => $this->convertString('amount_min'),
'currency_id' => $this->integer('transaction_currency_id'), 'currency_id' => $this->integer('transaction_currency_id'),
'currency_code' => '', 'currency_code' => '',
'amount_max' => $this->string('amount_max'), 'amount_max' => $this->convertString('amount_max'),
'date' => $this->getCarbonDate('date'), 'date' => $this->getCarbonDate('date'),
'end_date' => $this->getCarbonDate('bill_end_date'), 'end_date' => $this->getCarbonDate('bill_end_date'),
'extension_date' => $this->getCarbonDate('extension_date'), 'extension_date' => $this->getCarbonDate('extension_date'),
'repeat_freq' => $this->string('repeat_freq'), 'repeat_freq' => $this->convertString('repeat_freq'),
'skip' => $this->integer('skip'), 'skip' => $this->integer('skip'),
'notes' => $this->stringWithNewlines('notes'), 'notes' => $this->stringWithNewlines('notes'),
'active' => $this->boolean('active'), 'active' => $this->boolean('active'),
'object_group_title' => $this->string('object_group'), 'object_group_title' => $this->convertString('object_group'),
]; ];
} }

View File

@@ -42,19 +42,19 @@ class BillUpdateRequest extends FormRequest
public function getBillData(): array public function getBillData(): array
{ {
return [ return [
'name' => $this->string('name'), 'name' => $this->convertString('name'),
'amount_min' => $this->string('amount_min'), 'amount_min' => $this->convertString('amount_min'),
'currency_id' => $this->integer('transaction_currency_id'), 'currency_id' => $this->integer('transaction_currency_id'),
'currency_code' => '', 'currency_code' => '',
'amount_max' => $this->string('amount_max'), 'amount_max' => $this->convertString('amount_max'),
'date' => $this->getCarbonDate('date'), 'date' => $this->getCarbonDate('date'),
'end_date' => $this->getCarbonDate('bill_end_date'), 'end_date' => $this->getCarbonDate('bill_end_date'),
'extension_date' => $this->getCarbonDate('extension_date'), 'extension_date' => $this->getCarbonDate('extension_date'),
'repeat_freq' => $this->string('repeat_freq'), 'repeat_freq' => $this->convertString('repeat_freq'),
'skip' => $this->integer('skip'), 'skip' => $this->integer('skip'),
'notes' => $this->stringWithNewlines('notes'), 'notes' => $this->stringWithNewlines('notes'),
'active' => $this->boolean('active'), 'active' => $this->boolean('active'),
'object_group_title' => $this->string('object_group'), 'object_group_title' => $this->convertString('object_group'),
]; ];
} }

View File

@@ -44,12 +44,12 @@ class BudgetFormStoreRequest extends FormRequest
public function getBudgetData(): array public function getBudgetData(): array
{ {
return [ return [
'name' => $this->string('name'), 'name' => $this->convertString('name'),
'active' => $this->boolean('active'), 'active' => $this->boolean('active'),
'auto_budget_type' => $this->integer('auto_budget_type'), 'auto_budget_type' => $this->integer('auto_budget_type'),
'currency_id' => $this->integer('auto_budget_currency_id'), 'currency_id' => $this->integer('auto_budget_currency_id'),
'auto_budget_amount' => $this->string('auto_budget_amount'), 'auto_budget_amount' => $this->convertString('auto_budget_amount'),
'auto_budget_period' => $this->string('auto_budget_period'), 'auto_budget_period' => $this->convertString('auto_budget_period'),
]; ];
} }

View File

@@ -45,12 +45,12 @@ class BudgetFormUpdateRequest extends FormRequest
public function getBudgetData(): array public function getBudgetData(): array
{ {
return [ return [
'name' => $this->string('name'), 'name' => $this->convertString('name'),
'active' => $this->boolean('active'), 'active' => $this->boolean('active'),
'auto_budget_type' => $this->integer('auto_budget_type'), 'auto_budget_type' => $this->integer('auto_budget_type'),
'currency_id' => $this->integer('auto_budget_currency_id'), 'currency_id' => $this->integer('auto_budget_currency_id'),
'auto_budget_amount' => $this->string('auto_budget_amount'), 'auto_budget_amount' => $this->convertString('auto_budget_amount'),
'auto_budget_period' => $this->string('auto_budget_period'), 'auto_budget_period' => $this->convertString('auto_budget_period'),
]; ];
} }

View File

@@ -42,7 +42,7 @@ class CategoryFormRequest extends FormRequest
public function getCategoryData(): array public function getCategoryData(): array
{ {
return [ return [
'name' => $this->string('name'), 'name' => $this->convertString('name'),
'notes' => $this->stringWithNewlines('notes'), 'notes' => $this->stringWithNewlines('notes'),
]; ];
} }

View File

@@ -42,9 +42,9 @@ class CurrencyFormRequest extends FormRequest
public function getCurrencyData(): array public function getCurrencyData(): array
{ {
return [ return [
'name' => $this->string('name'), 'name' => $this->convertString('name'),
'code' => $this->string('code'), 'code' => $this->convertString('code'),
'symbol' => $this->string('symbol'), 'symbol' => $this->convertString('symbol'),
'decimal_places' => $this->integer('decimal_places'), 'decimal_places' => $this->integer('decimal_places'),
'enabled' => $this->boolean('enabled'), 'enabled' => $this->boolean('enabled'),
]; ];

View File

@@ -46,7 +46,7 @@ class JournalLinkRequest extends FormRequest
$parts = explode('_', $linkType); $parts = explode('_', $linkType);
$return['link_type_id'] = (int) $parts[0]; $return['link_type_id'] = (int) $parts[0];
$return['transaction_journal_id'] = $this->integer('opposing'); $return['transaction_journal_id'] = $this->integer('opposing');
$return['notes'] = $this->string('notes'); $return['notes'] = $this->convertString('notes');
$return['direction'] = $parts[1]; $return['direction'] = $parts[1];
return $return; return $return;

View File

@@ -42,7 +42,7 @@ class ObjectGroupFormRequest extends FormRequest
public function getObjectGroupData(): array public function getObjectGroupData(): array
{ {
return [ return [
'title' => $this->string('title'), 'title' => $this->convertString('title'),
]; ];
} }

View File

@@ -41,13 +41,13 @@ class PiggyBankStoreRequest extends FormRequest
public function getPiggyBankData(): array public function getPiggyBankData(): array
{ {
return [ return [
'name' => $this->string('name'), 'name' => $this->convertString('name'),
'startdate' => $this->getCarbonDate('startdate'), 'startdate' => $this->getCarbonDate('startdate'),
'account_id' => $this->integer('account_id'), 'account_id' => $this->integer('account_id'),
'targetamount' => $this->string('targetamount'), 'targetamount' => $this->convertString('targetamount'),
'targetdate' => $this->getCarbonDate('targetdate'), 'targetdate' => $this->getCarbonDate('targetdate'),
'notes' => $this->stringWithNewlines('notes'), 'notes' => $this->stringWithNewlines('notes'),
'object_group_title' => $this->string('object_group'), 'object_group_title' => $this->convertString('object_group'),
]; ];
} }

View File

@@ -42,13 +42,13 @@ class PiggyBankUpdateRequest extends FormRequest
public function getPiggyBankData(): array public function getPiggyBankData(): array
{ {
return [ return [
'name' => $this->string('name'), 'name' => $this->convertString('name'),
'startdate' => $this->getCarbonDate('startdate'), 'startdate' => $this->getCarbonDate('startdate'),
'account_id' => $this->integer('account_id'), 'account_id' => $this->integer('account_id'),
'targetamount' => $this->string('targetamount'), 'targetamount' => $this->convertString('targetamount'),
'targetdate' => $this->getCarbonDate('targetdate'), 'targetdate' => $this->getCarbonDate('targetdate'),
'notes' => $this->stringWithNewlines('notes'), 'notes' => $this->stringWithNewlines('notes'),
'object_group_title' => $this->string('object_group'), 'object_group_title' => $this->convertString('object_group'),
]; ];
} }

View File

@@ -50,11 +50,11 @@ class ReconciliationStoreRequest extends FormRequest
$data = [ $data = [
'start' => $this->getCarbonDate('start'), 'start' => $this->getCarbonDate('start'),
'end' => $this->getCarbonDate('end'), 'end' => $this->getCarbonDate('end'),
'start_balance' => $this->string('startBalance'), 'start_balance' => $this->convertString('startBalance'),
'end_balance' => $this->string('endBalance'), 'end_balance' => $this->convertString('endBalance'),
'difference' => $this->string('difference'), 'difference' => $this->convertString('difference'),
'journals' => $transactions, 'journals' => $transactions,
'reconcile' => $this->string('reconcile'), 'reconcile' => $this->convertString('reconcile'),
]; ];
Log::debug('In ReconciliationStoreRequest::getAll(). Will now return data.'); Log::debug('In ReconciliationStoreRequest::getAll(). Will now return data.');

View File

@@ -56,23 +56,23 @@ class RecurrenceFormRequest extends FormRequest
$repetitionData = $this->parseRepetitionData(); $repetitionData = $this->parseRepetitionData();
$return = [ $return = [
'recurrence' => [ 'recurrence' => [
'type' => $this->string('transaction_type'), 'type' => $this->convertString('transaction_type'),
'title' => $this->string('title'), 'title' => $this->convertString('title'),
'description' => $this->string('recurring_description'), 'description' => $this->convertString('recurring_description'),
'first_date' => $this->getCarbonDate('first_date'), 'first_date' => $this->getCarbonDate('first_date'),
'repeat_until' => $this->getCarbonDate('repeat_until'), 'repeat_until' => $this->getCarbonDate('repeat_until'),
'nr_of_repetitions' => $this->integer('repetitions'), 'nr_of_repetitions' => $this->integer('repetitions'),
'apply_rules' => $this->boolean('apply_rules'), 'apply_rules' => $this->boolean('apply_rules'),
'active' => $this->boolean('active'), 'active' => $this->boolean('active'),
'repetition_end' => $this->string('repetition_end'), 'repetition_end' => $this->convertString('repetition_end'),
], ],
'transactions' => [ 'transactions' => [
[ [
'currency_id' => $this->integer('transaction_currency_id'), 'currency_id' => $this->integer('transaction_currency_id'),
'currency_code' => null, 'currency_code' => null,
'type' => $this->string('transaction_type'), 'type' => $this->convertString('transaction_type'),
'description' => $this->string('transaction_description'), 'description' => $this->convertString('transaction_description'),
'amount' => $this->string('amount'), 'amount' => $this->convertString('amount'),
'foreign_amount' => null, 'foreign_amount' => null,
'foreign_currency_id' => null, 'foreign_currency_id' => null,
'foreign_currency_code' => null, 'foreign_currency_code' => null,
@@ -81,8 +81,8 @@ class RecurrenceFormRequest extends FormRequest
'bill_id' => $this->integer('bill_id'), 'bill_id' => $this->integer('bill_id'),
'bill_name' => null, 'bill_name' => null,
'category_id' => null, 'category_id' => null,
'category_name' => $this->string('category'), 'category_name' => $this->convertString('category'),
'tags' => '' !== $this->string('tags') ? explode(',', $this->string('tags')) : [], 'tags' => '' !== $this->convertString('tags') ? explode(',', $this->convertString('tags')) : [],
'piggy_bank_id' => $this->integer('piggy_bank_id'), 'piggy_bank_id' => $this->integer('piggy_bank_id'),
'piggy_bank_name' => null, 'piggy_bank_name' => null,
], ],
@@ -100,7 +100,7 @@ class RecurrenceFormRequest extends FormRequest
// fill in foreign currency data // fill in foreign currency data
if (null !== $this->float('foreign_amount')) { if (null !== $this->float('foreign_amount')) {
$return['transactions'][0]['foreign_amount'] = $this->string('foreign_amount'); $return['transactions'][0]['foreign_amount'] = $this->convertString('foreign_amount');
$return['transactions'][0]['foreign_currency_id'] = $this->integer('foreign_currency_id'); $return['transactions'][0]['foreign_currency_id'] = $this->integer('foreign_currency_id');
} }
// default values: // default values:
@@ -109,9 +109,9 @@ class RecurrenceFormRequest extends FormRequest
$return['transactions'][0]['destination_id'] = null; $return['transactions'][0]['destination_id'] = null;
$return['transactions'][0]['destination_name'] = null; $return['transactions'][0]['destination_name'] = null;
// fill in source and destination account data // fill in source and destination account data
switch ($this->string('transaction_type')) { switch ($this->convertString('transaction_type')) {
default: default:
throw new FireflyException(sprintf('Cannot handle transaction type "%s"', $this->string('transaction_type'))); throw new FireflyException(sprintf('Cannot handle transaction type "%s"', $this->convertString('transaction_type')));
case 'withdrawal': case 'withdrawal':
$return['transactions'][0]['source_id'] = $this->integer('source_id'); $return['transactions'][0]['source_id'] = $this->integer('source_id');
$return['transactions'][0]['destination_id'] = $this->integer('withdrawal_destination_id'); $return['transactions'][0]['destination_id'] = $this->integer('withdrawal_destination_id');
@@ -149,7 +149,7 @@ class RecurrenceFormRequest extends FormRequest
*/ */
private function parseRepetitionData(): array private function parseRepetitionData(): array
{ {
$value = $this->string('repetition_type'); $value = $this->convertString('repetition_type');
$return = [ $return = [
'type' => '', 'type' => '',
'moment' => '', 'moment' => '',
@@ -224,7 +224,7 @@ class RecurrenceFormRequest extends FormRequest
} }
// if ends after X repetitions, set another rule // if ends after X repetitions, set another rule
if ('times' === $this->string('repetition_end')) { if ('times' === $this->convertString('repetition_end')) {
$rules['repetitions'] = 'required|numeric|between:0,254'; $rules['repetitions'] = 'required|numeric|between:0,254';
} }
// if foreign amount, currency must be different. // if foreign amount, currency must be different.
@@ -233,12 +233,12 @@ class RecurrenceFormRequest extends FormRequest
} }
// if ends at date X, set another rule. // if ends at date X, set another rule.
if ('until_date' === $this->string('repetition_end')) { if ('until_date' === $this->convertString('repetition_end')) {
$rules['repeat_until'] = 'required|date|after:' . $tomorrow->format('Y-m-d'); $rules['repeat_until'] = 'required|date|after:' . $tomorrow->format('Y-m-d');
} }
// switchc on type to expand rules for source and destination accounts: // switchc on type to expand rules for source and destination accounts:
switch ($this->string('transaction_type')) { switch ($this->convertString('transaction_type')) {
case strtolower(TransactionType::WITHDRAWAL): case strtolower(TransactionType::WITHDRAWAL):
$rules['source_id'] = 'required|exists:accounts,id|belongsToUser:accounts'; $rules['source_id'] = 'required|exists:accounts,id|belongsToUser:accounts';
$rules['destination_name'] = 'between:1,255|nullable'; $rules['destination_name'] = 'between:1,255|nullable';
@@ -254,7 +254,7 @@ class RecurrenceFormRequest extends FormRequest
break; break;
default: default:
throw new FireflyException(sprintf('Cannot handle transaction type of type "%s"', $this->string('transaction_type'))); throw new FireflyException(sprintf('Cannot handle transaction type of type "%s"', $this->convertString('transaction_type')));
} }
// update some rules in case the user is editing a post: // update some rules in case the user is editing a post:
@@ -309,9 +309,9 @@ class RecurrenceFormRequest extends FormRequest
// See reference nr. 45 // See reference nr. 45
switch ($this->string('transaction_type')) { switch ($this->convertString('transaction_type')) {
default: default:
throw new FireflyException(sprintf('Cannot handle transaction type "%s"', $this->string('transaction_type'))); throw new FireflyException(sprintf('Cannot handle transaction type "%s"', $this->convertString('transaction_type')));
case 'withdrawal': case 'withdrawal':
$sourceId = (int) $data['source_id']; $sourceId = (int) $data['source_id'];
$destinationId = (int) $data['withdrawal_destination_id']; $destinationId = (int) $data['withdrawal_destination_id'];

View File

@@ -44,10 +44,10 @@ class RuleFormRequest extends FormRequest
public function getRuleData(): array public function getRuleData(): array
{ {
return [ return [
'title' => $this->string('title'), 'title' => $this->convertString('title'),
'rule_group_id' => $this->integer('rule_group_id'), 'rule_group_id' => $this->integer('rule_group_id'),
'active' => $this->boolean('active'), 'active' => $this->boolean('active'),
'trigger' => $this->string('trigger'), 'trigger' => $this->convertString('trigger'),
'description' => $this->stringWithNewlines('description'), 'description' => $this->stringWithNewlines('description'),
'stop_processing' => $this->boolean('stop_processing'), 'stop_processing' => $this->boolean('stop_processing'),
'strict' => $this->boolean('strict'), 'strict' => $this->boolean('strict'),

View File

@@ -48,7 +48,7 @@ class RuleGroupFormRequest extends FormRequest
} }
return [ return [
'title' => $this->string('title'), 'title' => $this->convertString('title'),
'description' => $this->stringWithNewlines('description'), 'description' => $this->stringWithNewlines('description'),
'active' => $active, 'active' => $active,
]; ];

View File

@@ -44,9 +44,9 @@ class TagFormRequest extends FormRequest
public function collectTagData(): array public function collectTagData(): array
{ {
$data = [ $data = [
'tag' => $this->string('tag'), 'tag' => $this->convertString('tag'),
'date' => $this->getCarbonDate('date'), 'date' => $this->getCarbonDate('date'),
'description' => $this->string('description'), 'description' => $this->convertString('description'),
]; ];
return $this->appendLocationData($data, 'location'); return $this->appendLocationData($data, 'location');

View File

@@ -43,10 +43,10 @@ class UserFormRequest extends FormRequest
public function getUserData(): array public function getUserData(): array
{ {
return [ return [
'email' => $this->string('email'), 'email' => $this->convertString('email'),
'blocked' => 1 === $this->integer('blocked'), 'blocked' => 1 === $this->integer('blocked'),
'blocked_code' => $this->string('blocked_code'), 'blocked_code' => $this->convertString('blocked_code'),
'password' => $this->string('password'), 'password' => $this->convertString('password'),
'is_owner' => 1 === $this->integer('is_owner'), 'is_owner' => 1 === $this->integer('is_owner'),
]; ];
} }

View File

@@ -69,18 +69,18 @@ trait AppendsLocationData
if ($isValidPOST) { if ($isValidPOST) {
Log::debug('Method is POST and all fields present and not NULL.'); Log::debug('Method is POST and all fields present and not NULL.');
$data['store_location'] = true; $data['store_location'] = true;
$data['longitude'] = $this->string($longitudeKey); $data['longitude'] = $this->convertString($longitudeKey);
$data['latitude'] = $this->string($latitudeKey); $data['latitude'] = $this->convertString($latitudeKey);
$data['zoom_level'] = $this->string($zoomLevelKey); $data['zoom_level'] = $this->convertString($zoomLevelKey);
} }
// for a PUT (api update) or POST update (UI) // for a PUT (api update) or POST update (UI)
if ($isValidPUT) { if ($isValidPUT) {
Log::debug('Method is PUT and all fields present and not NULL.'); Log::debug('Method is PUT and all fields present and not NULL.');
$data['update_location'] = true; $data['update_location'] = true;
$data['longitude'] = $this->string($longitudeKey); $data['longitude'] = $this->convertString($longitudeKey);
$data['latitude'] = $this->string($latitudeKey); $data['latitude'] = $this->convertString($latitudeKey);
$data['zoom_level'] = $this->string($zoomLevelKey); $data['zoom_level'] = $this->convertString($zoomLevelKey);
} }
if ($isValidEmptyPUT) { if ($isValidEmptyPUT) {
Log::debug('Method is PUT and all fields present and NULL.'); Log::debug('Method is PUT and all fields present and NULL.');

View File

@@ -51,7 +51,7 @@ trait ConvertsDataTypes
* *
* @return string * @return string
*/ */
public function string(string $field): string public function convertString(string $field): string
{ {
return $this->clearString((string) ($this->get($field) ?? ''), false); return $this->clearString((string) ($this->get($field) ?? ''), false);
} }