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, 'locales' => \collect($this->locales)->filter()->unique()->all() ]); $this->mergePicture('picture'); } /** * Get the validation rules that apply to the request. * * @return array */ public function rules() { $rules = [ 'type' => [new Enum(TypeEnum::class)], 'title' => 'required|min:3|max:70', 'subtitle' => 'required|min:3|max:70', 'description' => 'required|string|min:15', 'link' => 'required|url', 'link_title' => 'required|min:3|max:255', 'link_new_tab' => 'required|boolean', 'picture_alt' => 'required|min:3|max:255', 'picture_title' => 'required|min:3|max:255', 'status' => 'required|boolean', 'locales' => 'required|array', 'locales.*' => ['required', \sprintf('in:%s', \implode(',', \config('app.locales')))], 'publish_at' => 'sometimes|nullable|date', 'unpublish_at' => 'sometimes|nullable|date' ]; return \array_merge( $rules, $this->pictureRules('picture', 1270, 930, 1270, 930, false), ); } /** * Get custom attributes for validator errors. * * @return array */ public function attributes() { return [ 'type' => trans('type of slider'), 'title' => trans('title of the slide'), 'subtitle' => trans('subtitle of the slide'), 'description' => trans('description of the slide'), 'link' => trans('link of the slide'), 'link_title' => trans('title of link'), 'link_new_tab' => trans('open the link in the new tab'), 'picture' => trans('illustration'), 'picture_alt' => trans('alt attribute of the image'), 'picture_title' => trans('title attribute of the image'), 'status' => trans('status of the slide'), ]; } }