2023-11-17 16:07:28 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Requests\Bo\Sections;
|
|
|
|
|
|
|
|
|
|
use App\Http\Requests\Bo\UpdateMiniCrudRequest;
|
|
|
|
|
|
|
|
|
|
class UpdateSectionRequest extends UpdateMiniCrudRequest
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* The model parameter name
|
|
|
|
|
*
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
protected $modelName = 'section';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine if the user is authorized to make this request.
|
|
|
|
|
*
|
|
|
|
|
* @return boolean
|
|
|
|
|
*/
|
|
|
|
|
public function authorize(): bool
|
|
|
|
|
{
|
|
|
|
|
return auth('backend')->check();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the validation rules that apply to the request.
|
|
|
|
|
*
|
|
|
|
|
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
|
|
|
|
*/
|
|
|
|
|
public function rules(): array
|
|
|
|
|
{
|
|
|
|
|
$rules = [
|
|
|
|
|
'h2_title' => 'required|between:3,255',
|
|
|
|
|
];
|
2024-02-12 15:51:31 +01:00
|
|
|
/** @var \App\Models\Section|null $section */
|
|
|
|
|
$section = $this->route('section');
|
|
|
|
|
if ($section) {
|
2024-07-24 17:49:30 +02:00
|
|
|
if (
|
|
|
|
|
$section->section !== \App\Enums\Sections\PageSectionEnum::hire_grow
|
|
|
|
|
) {
|
2024-02-12 15:51:31 +01:00
|
|
|
$rules = \array_merge($rules, [
|
|
|
|
|
'text' => 'present',
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
if ($section->section->containsData()) {
|
|
|
|
|
$rules = \array_merge($rules, [
|
|
|
|
|
'data' => 'present|array',
|
|
|
|
|
'data.*' => 'required|array',
|
|
|
|
|
]);
|
|
|
|
|
}
|
2023-11-17 16:07:28 +01:00
|
|
|
}
|
2024-03-20 17:39:24 +01:00
|
|
|
return \array_merge(parent::rules(), $rules);
|
2023-11-17 16:07:28 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get custom attributes for validator errors.
|
|
|
|
|
*
|
2026-04-24 15:04:18 +02:00
|
|
|
* @return array<string, string>
|
2023-11-17 16:07:28 +01:00
|
|
|
*/
|
2024-03-20 17:39:24 +01:00
|
|
|
public function attributes(): array
|
2023-11-17 16:07:28 +01:00
|
|
|
{
|
|
|
|
|
return [
|
2024-03-20 17:39:24 +01:00
|
|
|
'h2_title' => trans('validation.custom.h2_title'),
|
|
|
|
|
'text' => trans('validation.attributes.content'),
|
|
|
|
|
'data' => trans('Valeurs du contenu spécifique'),
|
2023-11-17 16:07:28 +01:00
|
|
|
'data.*.value' => trans('Valeur du contenu spécifique'),
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|