mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Various code cleanup and fixed alignments.
This commit is contained in:
@@ -120,7 +120,7 @@ class AccountFormRequest extends FormRequest
|
||||
$rules = Location::requestRules($rules);
|
||||
|
||||
/** @var null|Account $account */
|
||||
$account = $this->route()->parameter('account');
|
||||
$account = $this->route()->parameter('account');
|
||||
if (null !== $account) {
|
||||
// add rules:
|
||||
$rules['id'] = 'belongsToUser:accounts';
|
||||
|
@@ -62,7 +62,7 @@ class BudgetFormUpdateRequest extends FormRequest
|
||||
$nameRule = 'required|between:1,100|uniqueObjectForUser:budgets,name';
|
||||
|
||||
/** @var null|Budget $budget */
|
||||
$budget = $this->route()->parameter('budget');
|
||||
$budget = $this->route()->parameter('budget');
|
||||
|
||||
if (null !== $budget) {
|
||||
$nameRule = 'required|between:1,100|uniqueObjectForUser:budgets,name,'.$budget->id;
|
||||
|
@@ -56,7 +56,7 @@ class CurrencyFormRequest extends FormRequest
|
||||
public function rules(): array
|
||||
{
|
||||
// fixed
|
||||
$rules = [
|
||||
$rules = [
|
||||
'name' => 'required|max:48|min:1|uniqueCurrencyName',
|
||||
'code' => 'required|min:3|max:51|uniqueCurrencyCode',
|
||||
'symbol' => 'required|min:1|max:51|uniqueCurrencySymbol',
|
||||
|
@@ -66,7 +66,7 @@ class JournalLinkRequest extends FormRequest
|
||||
$combinations[] = sprintf('%d_inward', $type->id);
|
||||
$combinations[] = sprintf('%d_outward', $type->id);
|
||||
}
|
||||
$string = implode(',', $combinations);
|
||||
$string = implode(',', $combinations);
|
||||
|
||||
// fixed
|
||||
return [
|
||||
|
@@ -45,7 +45,7 @@ class LinkTypeFormRequest extends FormRequest
|
||||
$idRule = '';
|
||||
|
||||
// get parameter link:
|
||||
$link = $this->route()->parameter('linkType');
|
||||
$link = $this->route()->parameter('linkType');
|
||||
|
||||
if (null !== $link) {
|
||||
$idRule = 'exists:link_types,id';
|
||||
|
@@ -45,7 +45,7 @@ class ReconciliationStoreRequest extends FormRequest
|
||||
if (!is_array($transactions)) {
|
||||
$transactions = [];
|
||||
}
|
||||
$data = [
|
||||
$data = [
|
||||
'start' => $this->getCarbonDate('start'),
|
||||
'end' => $this->getCarbonDate('end'),
|
||||
'start_balance' => $this->convertString('startBalance'),
|
||||
|
@@ -52,8 +52,8 @@ class RecurrenceFormRequest extends FormRequest
|
||||
*/
|
||||
public function getAll(): array
|
||||
{
|
||||
$repetitionData = $this->parseRepetitionData();
|
||||
$return = [
|
||||
$repetitionData = $this->parseRepetitionData();
|
||||
$return = [
|
||||
'recurrence' => [
|
||||
'type' => $this->convertString('transaction_type'),
|
||||
'title' => $this->convertString('title'),
|
||||
@@ -128,7 +128,7 @@ class RecurrenceFormRequest extends FormRequest
|
||||
}
|
||||
|
||||
// replace category name with a new category:
|
||||
$factory = app(CategoryFactory::class);
|
||||
$factory = app(CategoryFactory::class);
|
||||
$factory->setUser(auth()->user());
|
||||
|
||||
/**
|
||||
@@ -153,9 +153,9 @@ class RecurrenceFormRequest extends FormRequest
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$today = today(config('app.timezone'));
|
||||
$tomorrow = today(config('app.timezone'))->addDay();
|
||||
$rules = [
|
||||
$today = today(config('app.timezone'));
|
||||
$tomorrow = today(config('app.timezone'))->addDay();
|
||||
$rules = [
|
||||
// mandatory info for recurrence.
|
||||
'title' => 'required|between:1,255|uniqueObjectForUser:recurrences,title',
|
||||
'first_date' => 'required|date|after:'.$today->format('Y-m-d'),
|
||||
@@ -206,7 +206,7 @@ class RecurrenceFormRequest extends FormRequest
|
||||
}
|
||||
|
||||
// switch on type to expand rules for source and destination accounts:
|
||||
$type = strtolower($this->convertString('transaction_type'));
|
||||
$type = strtolower($this->convertString('transaction_type'));
|
||||
if (strtolower(TransactionType::WITHDRAWAL) === $type) {
|
||||
$rules['source_id'] = 'required|exists:accounts,id|belongsToUser:accounts';
|
||||
$rules['destination_name'] = 'between:1,255|nullable';
|
||||
@@ -263,13 +263,13 @@ class RecurrenceFormRequest extends FormRequest
|
||||
$accountValidator->setTransactionType($transactionType);
|
||||
|
||||
// default values:
|
||||
$sourceId = null;
|
||||
$destinationId = null;
|
||||
$sourceId = null;
|
||||
$destinationId = null;
|
||||
|
||||
// TODO typeOverrule: the account validator may have another opinion the transaction type.
|
||||
// TODO either use 'withdrawal' or the strtolower() variant, not both.
|
||||
$type = $this->convertString('transaction_type');
|
||||
$throwError = true;
|
||||
$type = $this->convertString('transaction_type');
|
||||
$throwError = true;
|
||||
if ('withdrawal' === $type) {
|
||||
$throwError = false;
|
||||
$sourceId = (int) $data['source_id'];
|
||||
@@ -290,7 +290,7 @@ class RecurrenceFormRequest extends FormRequest
|
||||
}
|
||||
|
||||
// validate source account.
|
||||
$validSource = $accountValidator->validateSource(['id' => $sourceId]);
|
||||
$validSource = $accountValidator->validateSource(['id' => $sourceId]);
|
||||
|
||||
// do something with result:
|
||||
if (false === $validSource) {
|
||||
|
@@ -137,7 +137,7 @@ class ReportFormRequest extends FormRequest
|
||||
$range = $this->get('daterange');
|
||||
$parts = explode(' - ', (string) $range);
|
||||
if (2 === count($parts)) {
|
||||
$string = $parts[1];
|
||||
$string = $parts[1];
|
||||
// validate as date
|
||||
// if regex for YYYY-MM-DD:
|
||||
$pattern = '/^(19|20)\d\d-(0[1-9]|1[012])-(0[1-9]|[12][\d]|3[01])$/';
|
||||
@@ -155,7 +155,7 @@ class ReportFormRequest extends FormRequest
|
||||
|
||||
return $date;
|
||||
}
|
||||
$error = sprintf('"%s" is not a valid date range: %s', $range, 'invalid format :(');
|
||||
$error = sprintf('"%s" is not a valid date range: %s', $range, 'invalid format :(');
|
||||
app('log')->error($error);
|
||||
|
||||
throw new FireflyException($error, 0);
|
||||
@@ -175,7 +175,7 @@ class ReportFormRequest extends FormRequest
|
||||
$range = $this->get('daterange');
|
||||
$parts = explode(' - ', (string) $range);
|
||||
if (2 === count($parts)) {
|
||||
$string = $parts[0];
|
||||
$string = $parts[0];
|
||||
// validate as date
|
||||
// if regex for YYYY-MM-DD:
|
||||
$pattern = '/^(19|20)\d\d-(0[1-9]|1[012])-(0[1-9]|[12][\d]|3[01])$/';
|
||||
@@ -193,7 +193,7 @@ class ReportFormRequest extends FormRequest
|
||||
|
||||
return $date;
|
||||
}
|
||||
$error = sprintf('"%s" is not a valid date range: %s', $range, 'invalid format :(');
|
||||
$error = sprintf('"%s" is not a valid date range: %s', $range, 'invalid format :(');
|
||||
app('log')->error($error);
|
||||
|
||||
throw new FireflyException($error, 0);
|
||||
|
@@ -86,17 +86,17 @@ class RuleFormRequest extends FormRequest
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$validTriggers = $this->getTriggers();
|
||||
$validActions = array_keys(config('firefly.rule-actions'));
|
||||
$validTriggers = $this->getTriggers();
|
||||
$validActions = array_keys(config('firefly.rule-actions'));
|
||||
|
||||
// some actions require text (aka context):
|
||||
$contextActions = implode(',', config('firefly.context-rule-actions'));
|
||||
$contextActions = implode(',', config('firefly.context-rule-actions'));
|
||||
|
||||
// some triggers require text (aka context):
|
||||
$contextTriggers = implode(',', $this->getTriggersWithContext());
|
||||
|
||||
// initial set of rules:
|
||||
$rules = [
|
||||
$rules = [
|
||||
'title' => 'required|between:1,100|uniqueObjectForUser:rules,title',
|
||||
'description' => 'between:1,5000|nullable',
|
||||
'stop_processing' => 'boolean',
|
||||
@@ -110,7 +110,7 @@ class RuleFormRequest extends FormRequest
|
||||
];
|
||||
|
||||
/** @var null|Rule $rule */
|
||||
$rule = $this->route()->parameter('rule');
|
||||
$rule = $this->route()->parameter('rule');
|
||||
|
||||
if (null !== $rule) {
|
||||
$rules['title'] = 'required|between:1,100|uniqueObjectForUser:rules,title,'.$rule->id;
|
||||
|
@@ -58,7 +58,7 @@ class TagFormRequest extends FormRequest
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
$idRule = '';
|
||||
$idRule = '';
|
||||
|
||||
/** @var null|Tag $tag */
|
||||
$tag = $this->route()->parameter('tag');
|
||||
@@ -68,7 +68,7 @@ class TagFormRequest extends FormRequest
|
||||
$tagRule = 'required|max:1024|min:1|uniqueObjectForUser:tags,tag,'.$tag->id;
|
||||
}
|
||||
|
||||
$rules = [
|
||||
$rules = [
|
||||
'tag' => $tagRule,
|
||||
'id' => $idRule,
|
||||
'description' => 'max:65536|min:1|nullable',
|
||||
|
Reference in New Issue
Block a user