check(); } /** * Prepare the data for validation. * * @return void */ protected function prepareForValidation() { $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() { $rules = [ 'title' => 'required|min:3|max:255', 'content' => 'required|string|min:15', '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', true, 950, 700, 950, 700), $this->pictureRules('picture_thumbnail', true, 167, 70, 167, 70) ); } /** * 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') ]; } }