This commit is contained in:
James Cole
2019-09-20 06:14:08 +02:00
parent 845e67e9be
commit c14d3f40a9
9 changed files with 120 additions and 8 deletions

View File

@@ -56,7 +56,7 @@ class BillFormRequest extends Request
'date' => $this->date('date'),
'repeat_freq' => $this->string('repeat_freq'),
'skip' => $this->integer('skip'),
'notes' => $this->string('notes'),
'notes' => $this->nlString('notes'),
'active' => $this->boolean('active'),
];
}

View File

@@ -224,6 +224,19 @@ class Request extends FormRequest
return app('steam')->cleanString((string)($this->get($field) ?? ''));
}
/**
* Return string value, but keep newlines.
*
* @param string $field
*
* @return string
*/
public function nlString(string $field): string
{
return app('steam')->nlCleanString((string)($this->get($field) ?? ''));
}
/**
* Parse and clean a string.
*
@@ -242,6 +255,24 @@ class Request extends FormRequest
}
/**
* Parse and clean a string, but keep the newlines.
*
* @param string|null $string
*
* @return string|null
*/
public function nlStringFromValue(?string $string): ?string
{
if (null === $string) {
return null;
}
$result = app('steam')->nlCleanString($string);
return '' === $result ? null : $result;
}
/**
* Return date or NULL.
*

View File

@@ -53,7 +53,7 @@ class RuleFormRequest extends Request
'rule_group_id' => $this->integer('rule_group_id'),
'active' => $this->boolean('active'),
'trigger' => $this->string('trigger'),
'description' => $this->string('description'),
'description' => $this->nlString('description'),
'stop_processing' => $this->boolean('stop_processing'),
'strict' => $this->boolean('strict'),
'triggers' => $this->getRuleTriggerData(),

View File

@@ -55,7 +55,7 @@ class RuleGroupFormRequest extends Request
return [
'title' => $this->string('title'),
'description' => $this->string('description'),
'description' => $this->nlString('description'),
'active' => $active,
];
}