check(); } /** * Prepare the data for validation. * * @return void */ protected function prepareForValidation() { $this->merge([ 'link_new_tab' => $this->link_new_tab ? true : false, 'status' => $this->status ? true : false, 'publish_at' => $this->publish_at ? \str_replace('T', ' ', $this->publish_at) : null, 'unpublish_at' => $this->unpublish_at ? \str_replace('T', ' ', $this->unpublish_at) : null, ]); $this->mergePicture(); } /** * Get the validation rules that apply to the request. * * @return array */ public function rules() { $rules = [ 'title' => 'required|min:3|max:255', 'title_color' => 'nullable|color_rgba', 'title_color_bg' => 'nullable|color_rgba', 'subtitle' => 'required|min:3|max:255', 'subtitle_color' => 'nullable|color_rgba', 'subtitle_color_bg' => 'nullable|color_rgba', 'text_position_desktop' => ['required', new EnumIsValidRule(SliderElementPosition::class)], 'picture_position_mobile' => ['required', new EnumIsValidRule(SliderElementPosition::class)], 'link' => 'required|url', 'link_title' => 'required|min:3|max:255', 'link_color' => 'nullable|color_rgba', 'link_color_hover' => 'nullable|color_rgba', 'link_color_bg' => 'nullable|color_rgba', 'link_color_bg_hover' => 'nullable|color_rgba', 'link_new_tab' => 'required|boolean', 'status' => 'required|boolean', 'publish_at' => 'nullable|date_format:Y-m-d H:i', 'unpublish_at' => 'nullable|date_format:Y-m-d H:i', ]; if (!$this->slider) { $rules['type'] = ['required', new EnumIsValidRule(SliderType::class)]; } return \array_merge($rules, $this->pictureRules(1400, 630, 1400, 630)); } /** * Get custom attributes for validator errors. * * @return array */ public function attributes(): array { return [ 'title' => trans('title'), 'title_color' => trans('couleur de titre'), 'title_color_bg' => trans('couleur de fond du titre'), 'picture_position_mobile' => trans('position de centrage de l\'image en mobile'), 'text_position_desktop' => trans('position de centrage du texte en desktop'), 'link' => trans('lien'), 'link_title' => trans('titre du lien'), 'link_color' => trans('couleur du lien'), 'link_color_bg' => trans('couleur de fond du lien'), 'link_new_tab' => trans('nouvel onglet'), 'status' => trans('publication'), 'picture' => trans('image'), ]; } }