check(); } /** * Prepare the data for validation. * * @return void */ protected function prepareForValidation(): void { $this->merge([ 'slug' => Str::slug(strip_tags($this->input('name'))), 'status' => $this->boolean('status'), 'publish_at' => $this->date('publish_at'), 'unpublish_at' => $this->date('unpublish_at'), 'locales' => \collect($this->input('locales'))->filter()->unique()->all() ]); } /** * Get the validation rules that apply to the request. * * @return array */ public function rules(): array { $rules = [ 'seo_title' => 'required|min:3|max:70', 'seo_description' => 'required|min:50|max:160', 'slug' => 'unique_translation:news', 'title' => 'required|min:3|max:70', 'subtitle' => 'required|min:3|max:70', 'content' => 'required|string|min:15', 'locales' => 'required|array', 'locales.*' => [ 'required', \sprintf('in:%s', \implode(',', \config('app.locales'))) ], 'data' => 'present|array', 'data.*' => 'required|array', 'data.bloc_1_display_picture.value' => 'required|accepted', 'status' => 'required|boolean', 'publish_at' => 'required|date', 'unpublish_at' => 'sometimes|nullable|date' ]; return \array_merge( parent::rules(), $rules ); } /** * Get custom attributes for validator errors. * * @return array */ public function attributes(): array { return [ 'seo_title' => trans('titre') . ' seo', 'seo_description' => trans('description') . ' seo', 'slug' => trans('slug of the news'), 'title' => trans('title of the news'), 'subtitle' => trans('subtitle of the news'), 'content' => trans('content of the news'), 'data' => trans('values of the data'), 'data.*.value' => trans('value of the data'), 'data.bloc_1_display_picture.value' => trans('visibility of the first picture') ]; } }