mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-20 11:19:16 +00:00
chore: reformat code.
This commit is contained in:
@@ -133,7 +133,7 @@ class RecurrenceFormRequest extends FormRequest
|
||||
$factory = app(CategoryFactory::class);
|
||||
$factory->setUser(auth()->user());
|
||||
/**
|
||||
* @var int $index
|
||||
* @var int $index
|
||||
* @var array $transaction
|
||||
*/
|
||||
foreach ($return['transactions'] as $index => $transaction) {
|
||||
@@ -149,6 +149,40 @@ class RecurrenceFormRequest extends FormRequest
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses repetition data.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function parseRepetitionData(): array
|
||||
{
|
||||
$value = $this->convertString('repetition_type');
|
||||
$return = [
|
||||
'type' => '',
|
||||
'moment' => '',
|
||||
];
|
||||
|
||||
if ('daily' === $value) {
|
||||
$return['type'] = $value;
|
||||
}
|
||||
//monthly,17
|
||||
//ndom,3,7
|
||||
if (in_array(substr($value, 0, 6), ['yearly', 'weekly'], true)) {
|
||||
$return['type'] = substr($value, 0, 6);
|
||||
$return['moment'] = substr($value, 7);
|
||||
}
|
||||
if (str_starts_with($value, 'monthly')) {
|
||||
$return['type'] = substr($value, 0, 7);
|
||||
$return['moment'] = substr($value, 8);
|
||||
}
|
||||
if (str_starts_with($value, 'ndom')) {
|
||||
$return['type'] = substr($value, 0, 4);
|
||||
$return['moment'] = substr($value, 5);
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* The rules for this request.
|
||||
*
|
||||
@@ -162,7 +196,7 @@ class RecurrenceFormRequest extends FormRequest
|
||||
$rules = [
|
||||
// mandatory info for recurrence.
|
||||
'title' => 'required|between:1,255|uniqueObjectForUser:recurrences,title',
|
||||
'first_date' => 'required|date|after:'.$today->format('Y-m-d'),
|
||||
'first_date' => 'required|date|after:' . $today->format('Y-m-d'),
|
||||
'repetition_type' => ['required', new ValidRecurrenceRepetitionValue(), new ValidRecurrenceRepetitionType(), 'between:1,20'],
|
||||
'skip' => 'required|numeric|integer|gte:0|lte:31',
|
||||
|
||||
@@ -206,7 +240,7 @@ class RecurrenceFormRequest extends FormRequest
|
||||
|
||||
// if ends at date X, set another rule.
|
||||
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');
|
||||
}
|
||||
|
||||
// switch on type to expand rules for source and destination accounts:
|
||||
@@ -230,17 +264,34 @@ class RecurrenceFormRequest extends FormRequest
|
||||
$recurrence = $this->route()->parameter('recurrence');
|
||||
if ($recurrence instanceof Recurrence) {
|
||||
$rules['id'] = 'required|numeric|exists:recurrences,id';
|
||||
$rules['title'] = 'required|between:1,255|uniqueObjectForUser:recurrences,title,'.$recurrence->id;
|
||||
$rules['title'] = 'required|between:1,255|uniqueObjectForUser:recurrences,title,' . $recurrence->id;
|
||||
$rules['first_date'] = 'required|date';
|
||||
}
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the validator instance with special rules for after the basic validation rules.
|
||||
*
|
||||
* @param Validator $validator
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function withValidator(Validator $validator): void
|
||||
{
|
||||
$validator->after(
|
||||
function (Validator $validator) {
|
||||
// validate all account info
|
||||
$this->validateAccountInformation($validator);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the given account information. Switches on given transaction type.
|
||||
*
|
||||
* @param Validator $validator
|
||||
* @param Validator $validator
|
||||
*
|
||||
* @throws FireflyException
|
||||
*/
|
||||
@@ -302,55 +353,4 @@ class RecurrenceFormRequest extends FormRequest
|
||||
$validator->errors()->add('withdrawal_destination_id', $message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure the validator instance with special rules for after the basic validation rules.
|
||||
*
|
||||
* @param Validator $validator
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function withValidator(Validator $validator): void
|
||||
{
|
||||
$validator->after(
|
||||
function (Validator $validator) {
|
||||
// validate all account info
|
||||
$this->validateAccountInformation($validator);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses repetition data.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function parseRepetitionData(): array
|
||||
{
|
||||
$value = $this->convertString('repetition_type');
|
||||
$return = [
|
||||
'type' => '',
|
||||
'moment' => '',
|
||||
];
|
||||
|
||||
if ('daily' === $value) {
|
||||
$return['type'] = $value;
|
||||
}
|
||||
//monthly,17
|
||||
//ndom,3,7
|
||||
if (in_array(substr($value, 0, 6), ['yearly', 'weekly'], true)) {
|
||||
$return['type'] = substr($value, 0, 6);
|
||||
$return['moment'] = substr($value, 7);
|
||||
}
|
||||
if (str_starts_with($value, 'monthly')) {
|
||||
$return['type'] = substr($value, 0, 7);
|
||||
$return['moment'] = substr($value, 8);
|
||||
}
|
||||
if (str_starts_with($value, 'ndom')) {
|
||||
$return['type'] = substr($value, 0, 4);
|
||||
$return['moment'] = substr($value, 5);
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user