2023-12-19 15:09:12 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Requests\Bo\StaticPages;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
|
use Illuminate\Support\Str;
|
|
|
|
|
|
|
|
|
|
class UpdateStaticPageRequest extends FormRequest
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Determine if the user is authorized to make this request.
|
|
|
|
|
*
|
|
|
|
|
* @return boolean
|
|
|
|
|
*/
|
|
|
|
|
public function authorize(): bool
|
|
|
|
|
{
|
|
|
|
|
return auth('backend')->check();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Prepare the data for validation.
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
|
|
|
|
public function prepareForValidation(): void
|
|
|
|
|
{
|
2024-01-26 16:08:12 +01:00
|
|
|
/** @var \App\Models\StaticPage $staticPageModel */
|
|
|
|
|
$staticPageModel = $this->route('static_page');
|
2023-12-19 15:09:12 +00:00
|
|
|
if (
|
2024-01-26 16:08:12 +01:00
|
|
|
\in_array($staticPageModel->type, [
|
2023-12-19 15:09:12 +00:00
|
|
|
\App\Enums\StaticPageType::confidentiality,
|
|
|
|
|
\App\Enums\StaticPageType::legals
|
|
|
|
|
])
|
|
|
|
|
) {
|
|
|
|
|
$this->merge([
|
|
|
|
|
'content' => (string)Str::of($this->post('content'))
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
$this->merge([
|
|
|
|
|
'content' => ''
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the validation rules that apply to the request.
|
|
|
|
|
*
|
|
|
|
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
|
|
|
|
*/
|
|
|
|
|
public function rules(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'seo_title' => 'required|min:45|max:70',
|
|
|
|
|
'seo_description' => 'required|min:50|max:160',
|
|
|
|
|
'title' => 'required|min:3|max:255',
|
|
|
|
|
'content' => 'present',
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get custom attributes for validator errors.
|
|
|
|
|
*
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function attributes(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'seo_title' => trans('validation.custom.seo_title'),
|
|
|
|
|
'seo_description' => trans('validation.custom.seo_description'),
|
|
|
|
|
'title' => trans('validation.attributes.title'),
|
|
|
|
|
'content' => trans('validation.attributes.content'),
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|