check(); } /** * Prepare the data for validation. * * @return void */ protected function prepareForValidation() { $this->merge([ 'slug' => Str::slug($this->title), ]); $this->mergePicture('picture'); } /** * Get the validation rules that apply to the request. * * @return array */ public function rules() { return \array_merge([ 'title' => 'required|min:6|max:255', 'slug' => 'required|max:255', 'seo_title' => 'required|min:45|max:70', 'seo_description' => 'required|min:50|max:160', 'content' => 'required|string|min:15', 'picture_alt' => 'required_with:picture|nullable|string|min:6|max:255', 'picture_title' => 'required_with:picture|nullable|string|min:6|max:255', 'published' => ['required', new EnumIsValidRule(PublishedStatus::class)], 'tags' => 'sometimes|array', 'tags.*' => 'required|array', 'tags.*.id' => 'required|numeric|exists:tags,id|distinct', 'tags.*.name' => 'required|string', ], $this->pictureRules('picture', 300, 300, 300, 300)); } /** * Get custom attributes for validator errors. * * @return array */ public function attributes(): array { return [ 'title' => trans('title'), 'slug' => trans('title'), 'seo_title' => trans('title') . ' seo', 'seo_description' => trans('description') . ' seo', 'content' => trans('content'), 'picture' => trans('vignette'), 'picture_alt' => trans('Texte alternatif de la vignette'), 'picture_title' => trans('Titre de la vignette'), 'published' => trans('published'), ]; } }