check(); } /** * Prepare the data for validation. * * @return void */ protected function prepareForValidation(): void { $this->merge([ 'button_display' => $this->button_display ? true : false, '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 */ public function rules(): array { $rules = [ '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', 'picture_thumbnail_title' => 'required|min:3|max:255' ]; return \array_merge( $rules, $this->pictureRules('picture', 950, 700, 950, 700, true), $this->pictureRules('picture_thumbnail', 167, 70, 167, 70, true) ); } /** * Get custom attributes for validator errors. * * @return array */ public function attributes(): array { return [ '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'), 'picture_thumbnail_title' => trans('titre de la vignette') ]; } }