check(); } /** * Prepare the data for validation. * * @return void * @ignore phpcs:disable Generic.Metrics.CyclomaticComplexity.TooHigh */ protected function prepareForValidation(): void { $tabFour = [ 'id' => 0, 'name' => 'Four', 'url' => '/assets/images/produits_details/four.png', 'time' => $this->time_cook0, 'temp' => $this->temp_cook0, 'status' => $this->is_activated0 ? true : false ]; $tabFriteuse = [ 'id' => 1, 'name' => 'Friteuse', 'url' => '/assets/images/produits_details/friteuse.png', 'time' => $this->time_cook1, 'temp' => $this->temp_cook1, 'status' => $this->is_activated1 ? true : false ]; $tabPoele = [ 'id' => 2, 'name' => 'Poêle', 'url' => '/assets/images/produits_details/poele.png', 'time' => $this->time_cook2, 'temp' => $this->temp_cook2, 'status' => $this->is_activated2 ? true : false ]; $tabCocotte = [ 'id' => 3, 'name' => 'Cocotte', 'url' => '/assets/images/produits_details/cocotte.png', 'time' => $this->time_cook3, 'temp' => $this->temp_cook3, 'status' => $this->is_activated3 ? true : false ]; $tabPlancha = [ 'id' => 4, 'name' => 'Plancha', 'url' => '/assets/images/produits_details/plancha.png', 'time' => $this->time_cook4, 'temp' => $this->temp_cook4, 'status' => $this->is_activated4 ? true : false ]; $tabCuisson = json_encode([ 'four' => $tabFour, 'friteuse' => $tabFriteuse, 'poele' => $tabPoele, 'cocotte' => $tabCocotte, 'plancha' => $tabPlancha, ]); $urlPlusProduit = ""; if ($this->pictogramme0) { $urlPlusProduit = "/assets/images/" . $this->pictogramme0->getClientOriginalName(); } $tabPlusProduit1 = [ 'id' => 0, 'name' => $this->content0, 'url' => $urlPlusProduit, ]; $urlPlusProduit = ""; if ($this->pictogramme1) { $urlPlusProduit = "/assets/images/" . $this->pictogramme1->getClientOriginalName(); } $tabPlusProduit2 = [ 'id' => 1, 'name' => $this->content1, 'url' => $urlPlusProduit, ]; $urlPlusProduit = ""; if ($this->pictogramme2) { $urlPlusProduit = "/assets/images/" . $this->pictogramme2->getClientOriginalName(); } $tabPlusProduit3 = [ 'id' => 2, 'name' => $this->content2, 'url' => $urlPlusProduit, ]; $tabPlusProduit = json_encode([$tabPlusProduit1, $tabPlusProduit2, $tabPlusProduit3]); $this->merge([ 'slug' => Str::slug($this->name), 'gamme_id' => $this->gamme_id === '0' ? null : $this->gamme_id, 'pictos' => $tabCuisson, 'plusproduit' => $tabPlusProduit, 'is_published' => $this->is_published ? true : false, ]); $this->merge([ 'picture3_display' => $this->picture3_display ? true : false ]); } /** * Get the validation rules that apply to the request. * * @return array */ public function rules(): array { return [ 'gamme_id' => 'sometimes|nullable|exists:gammes,id', 'name' => 'required|max:255', 'slug' => 'required|unique:products', 'description' => 'required|min:20', 'picture1' => 'image|mimes:jpeg,png,jpg|max:1024|dimensions:width=370,height=370', 'alt_text_picture1' => 'max:255', 'picture2' => 'image|mimes:jpeg,png,jpg|max:1024|dimensions:width=530,height=530', 'alt_text_picture2' => 'max:255', 'picture3' => 'image|mimes:jpeg,png,jpg|max:1024|dimensions:width=300,height=200', 'alt_text_picture3' => 'sometimes|max:255', 'picture3_display' => 'sometimes|boolean', 'pictos' => 'sometimes|nullable', 'plusproduit' => 'sometimes|nullable', 'pictogramme0' => 'nullable|image|mimes:png|max:1024|dimensions:width=141,height=100', 'pictogramme1' => 'nullable|image|mimes:png|max:1024|dimensions:width=141,height=100', 'pictogramme2' => 'nullable|image|mimes:png|max:1024|dimensions:width=141,height=100', 'is_published' => 'nullable|boolean', 'seo_title' => 'max:255', 'seo_description' => 'max:255', 'seo_keywords' => 'max:255', ]; } /** * 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('libellé') ]; } }