2022-12-08 13:10:13 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Requests\Bo\Slides;
|
|
|
|
|
|
|
|
|
|
use App\Traits\Requests\HasPicture;
|
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
|
|
|
|
|
|
class StoreSlideRequest extends FormRequest
|
|
|
|
|
{
|
|
|
|
|
use HasPicture;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Determine if the user is authorized to make this request.
|
|
|
|
|
*
|
|
|
|
|
* @return boolean
|
|
|
|
|
*/
|
2023-09-27 10:25:30 +02:00
|
|
|
public function authorize(): bool
|
2022-12-08 13:10:13 +01:00
|
|
|
{
|
|
|
|
|
return auth('backend')->check();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Prepare the data for validation.
|
|
|
|
|
*
|
|
|
|
|
* @return void
|
|
|
|
|
*/
|
2023-09-27 10:25:30 +02:00
|
|
|
protected function prepareForValidation(): void
|
2022-12-08 13:10:13 +01:00
|
|
|
{
|
|
|
|
|
$this->merge([
|
2023-09-27 10:25:30 +02:00
|
|
|
'button_display' => $this->button_display ? true : false,
|
2022-12-08 13:10:13 +01:00
|
|
|
'button_targetblank' => $this->button_targetblank ? true : false,
|
|
|
|
|
]);
|
|
|
|
|
$this->mergePicture('picture');
|
|
|
|
|
$this->mergePicture('picture_thumbnail');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the validation rules that apply to the request.
|
|
|
|
|
*
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
2023-09-27 10:25:30 +02:00
|
|
|
public function rules(): array
|
2022-12-08 13:10:13 +01:00
|
|
|
{
|
|
|
|
|
$rules = [
|
2023-09-27 10:25:30 +02:00
|
|
|
'title' => 'required|min:3|max:255',
|
|
|
|
|
'content' => 'required|string|min:15|max:540',
|
|
|
|
|
'button_display' => 'required|boolean',
|
|
|
|
|
'button_text' => 'nullable|min:3|max:45',
|
|
|
|
|
'button_url' => 'nullable|min:3|max:255|url',
|
|
|
|
|
'button_targetblank' => 'required|boolean',
|
|
|
|
|
'picture_alt' => 'required|min:3|max:255',
|
|
|
|
|
'picture_title' => 'required|min:3|max:255',
|
|
|
|
|
'picture_thumbnail_alt' => 'required|min:3|max:255',
|
2022-12-08 13:10:13 +01:00
|
|
|
'picture_thumbnail_title' => 'required|min:3|max:255'
|
|
|
|
|
];
|
|
|
|
|
return \array_merge(
|
|
|
|
|
$rules,
|
2024-02-05 09:33:08 +01:00
|
|
|
$this->pictureRules('picture', 950, 700, 950, 700, true),
|
|
|
|
|
$this->pictureRules('picture_thumbnail', 167, 70, 167, 70, true)
|
2022-12-08 13:10:13 +01:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get custom attributes for validator errors.
|
|
|
|
|
*
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
|
|
|
|
public function attributes(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
2023-09-27 10:25:30 +02:00
|
|
|
'title' => trans('title'),
|
|
|
|
|
'content' => trans('contenu de la slide'),
|
|
|
|
|
'button_display' => trans('afficher le bouton'),
|
|
|
|
|
'button_text' => trans('texte du bouton'),
|
|
|
|
|
'button_url' => trans('url du bouton'),
|
|
|
|
|
'button_targetblank' => trans('ouvrir dans un nouvel onglet'),
|
|
|
|
|
'picture' => trans('Illustration'),
|
|
|
|
|
'picture_alt' => trans('attribut alt de l\'image'),
|
|
|
|
|
'picture_title' => trans('titre de l\'image'),
|
|
|
|
|
'picture_thumbnail' => trans('vignette'),
|
|
|
|
|
'picture_thumbnail_alt' => trans('attribut alt de la vignette'),
|
2022-12-08 13:10:13 +01:00
|
|
|
'picture_thumbnail_title' => trans('titre de la vignette')
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|