check(); } /** * Prepare the data for validation. * * @return void */ protected function prepareForValidation(): void { $this->merge([ 'published' => $this->boolean('published'), 'button_display' => $this->boolean('button_display'), 'button_newtab' => $this->boolean('button_newtab'), ]); $this->mergePicture('picture'); } /** * Get the validation rules that apply to the request. * * @return array */ public function rules(): array { $rules = [ 'title' => 'required|string|min:3|max:500', 'content' => [ 'required', 'string', new WysiwygLength(15, 1500) ], 'picture_alt' => 'required|string|min:3|max:255', 'picture_title' => 'required|string|min:3|max:255', 'button_display' => 'required|boolean', 'button_text' => 'required_if_accepted:button_display|nullable|string|min:3|max:255', 'button_url' => 'required_if_accepted:button_display|nullable|url:https|min:3|max:255', 'button_newtab' => 'required|boolean', 'published' => 'required|boolean', ]; return \array_merge( $rules, $this->pictureRules('picture', 800, 535, 800, 535, false), ); } /** * Get custom attributes for validator errors. * * @return array */ public function attributes(): array { return [ 'title' => trans('Titre'), 'picture' => trans('Image'), 'picture_alt' => trans('Attribut alt de l\'image'), 'picture_title' => trans('Titre de l\'image'), 'content' => trans('Contenu'), 'button_text' => trans('Texte du CTA'), 'button_url' => trans('URL du CTA'), 'published' => trans('Statut'), ]; } }