check(); } /** * Prepare the data for validation. * * @return void */ protected function prepareForValidation(): void { $this->merge([ 'slug' => Str::slug($this->title), 'parent_gamme_id' => $this->parent_gamme_id === '0' ? null : $this->parent_gamme_id, ]); } /** * Get the validation rules that apply to the request. * * @return array */ public function rules(): array { return [ 'parent_gamme_id' => 'sometimes|nullable|exists:gammes,id', 'title' => 'required|string|max:255', 'slug' => 'required|unique:gammes', 'text' => 'required|string|max:500', 'picture1' => 'sometimes|image|mimes:jpeg,png,jpg|max:2048|dimensions:width=370,height=370', 'alt_text_picture1' => 'required|max:255', 'picture2' => 'sometimes|image|mimes:jpeg,png,jpg|max:2048|dimensions:width=1920,height=591', 'alt_text_picture2' => 'required|max:255', 'picture3' => 'sometimes|image|mimes:jpeg,png,jpg|max:2048|dimensions:width=84,height=84', 'alt_text_picture3' => 'sometimes|max:255', 'category' => 'sometimes|nullable', ]; } /** * Get custom messages for validator errors. * * @return array */ public function messages(): array { return []; } /** * Get custom attributes for validator errors. * * @return array */ public function attributes(): array { return [ 'slug' => trans('Nom') ]; } }