@@ -31,17 +31,19 @@ public function attributes()
3131
3232 public function rules ()
3333 {
34- return [
35- 'location_name ' => ['sometimes ' , 'required ' , 'between:2,32 ' ],
36- 'location_email ' => ['sometimes ' , 'required ' , 'email:filter ' , 'max:96 ' ],
34+ $ method = Request::method ();
35+
36+ $ rules = [
37+ 'location_name ' => ['between:2,32 ' ],
38+ 'location_email ' => ['email:filter ' , 'max:96 ' ],
3739 'location_telephone ' => ['sometimes ' ],
38- 'location_address_1 ' => ['sometimes ' , ' required ' , ' between:2,128 ' ],
40+ 'location_address_1 ' => ['between:2,128 ' ],
3941 'location_address_2 ' => ['max:128 ' ],
4042 'location_city ' => ['max:128 ' ],
4143 'location_state ' => ['max:128 ' ],
4244 'location_postcode ' => ['max:10 ' ],
43- 'location_country_id ' => ['sometimes ' , ' required ' , ' integer ' ],
44- 'options.auto_lat_lng ' => ['sometimes ' , ' required ' , ' boolean ' ],
45+ 'location_country_id ' => ['integer ' ],
46+ 'options.auto_lat_lng ' => ['boolean ' ],
4547 'location_lat ' => ['sometimes ' , 'numeric ' ],
4648 'location_lng ' => ['sometimes ' , 'numeric ' ],
4749 'description ' => ['max:3028 ' ],
@@ -50,5 +52,15 @@ public function rules()
5052 'gallery.title ' => ['max:128 ' ],
5153 'gallery.description ' => ['max:255 ' ],
5254 ];
55+
56+ if ($ method == 'post ' ) {
57+ $ rules ['location_name ' ][] = 'required ' ;
58+ $ rules ['location_email ' ][] = 'required ' ;
59+ $ rules ['options.auto_lat_lng ' ][] = 'required ' ;
60+ $ rules ['location_lng ' ][] = 'required ' ;
61+ $ rules ['location_country_id ' ][] = 'required ' ;
62+ }
63+
64+ return $ rules ;
5365 }
5466}
0 commit comments