diff --git a/apiresources/requests/MenuItemOptionRequest.php b/apiresources/requests/MenuItemOptionRequest.php index e653b8c..d403bfe 100644 --- a/apiresources/requests/MenuItemOptionRequest.php +++ b/apiresources/requests/MenuItemOptionRequest.php @@ -6,16 +6,29 @@ class MenuItemOptionRequest extends FormRequest { + public function attributes() + { + return [ + 'menu_id', lang('admin::lang.menus.label_option'), + 'option_id', lang('admin::lang.menus.label_option_id'), + 'priority', lang('admin::lang.menus.label_option'), + 'required', lang('admin::lang.menus.label_option_required'), + 'min_selected', lang('admin::lang.menus.label_min_selected'), + 'max_selected', lang('admin::lang.menus.label_max_selected'), + 'menu_option_values.*', lang('admin::lang.label_option_value_id'), + ]; + } + public function rules() { return [ - ['menu_id', 'admin::lang.menus.label_option', 'nullable|integer'], - ['option_id', 'admin::lang.menus.label_option_id', 'required|integer'], - ['priority', 'admin::lang.menus.label_option', 'integer'], - ['required', 'admin::lang.menus.label_option_required', 'boolean'], - ['min_selected', 'admin::lang.menus.label_min_selected', 'integer|lte:max_selected'], - ['max_selected', 'admin::lang.menus.label_max_selected', 'integer|gte:min_selected'], - ['menu_option_values.*', 'lang:admin::lang.label_option_value_id', 'array'], + 'menu_id' => ['nullable', 'integer'], + 'option_id' => ['required', 'integer'], + 'priority' => ['integer'], + 'required' => ['boolean'], + 'min_selected' => ['integer', 'lte:max_selected'], + 'max_selected' => ['integer', 'gte:min_selected'], + 'menu_option_values.*' => ['array'], ]; } } diff --git a/apiresources/requests/MenuOptionRequest.php b/apiresources/requests/MenuOptionRequest.php index 55c3932..0bbcc70 100644 --- a/apiresources/requests/MenuOptionRequest.php +++ b/apiresources/requests/MenuOptionRequest.php @@ -6,19 +6,35 @@ class MenuOptionRequest extends FormRequest { + public function attributes() + { + return [ + 'option_name' => lang('admin::lang.menu_options.label_option_name'), + 'display_type' => lang('admin::lang.menu_options.label_display_type'), + 'priority' => lang('admin::lang.menu_options.label_priority'), + 'locations.*' => lang('admin::lang.label_location'), + 'option_values.*.option_value_id' => lang('admin::lang.label_option_value_id'), + 'option_values.*.option_id' => lang('admin::lang.label_option_id'), + 'option_values.*.value' => lang('admin::lang.menu_options.label_option_value'), + 'option_values.*.price' => lang('admin::lang.menu_options.label_option_price'), + 'option_values.*.priority' => lang('admin::lang.menu_options.label_option_price'), + 'option_values.*.allergens.*' => lang('admin::lang.menus.label_allergens'), + ]; + } + public function rules() { return [ - ['option_name', 'lang:admin::lang.menu_options.label_option_name', 'required|min:2|max:32'], - ['display_type', 'lang:admin::lang.menu_options.label_display_type', 'required|alpha'], - ['priority', 'lang:admin::lang.menu_options.label_priority', 'integer'], - ['locations.*', 'lang:admin::lang.label_location', 'integer'], - ['option_values.*.option_value_id', 'lang:admin::lang.label_option_value_id', 'integer'], - ['option_values.*.option_id', 'lang:admin::lang.label_option_id', 'integer'], - ['option_values.*.value', 'lang:admin::lang.menu_options.label_option_value', 'min:2|max:128'], - ['option_values.*.price', 'lang:admin::lang.menu_options.label_option_price', 'numeric|min:0'], - ['option_values.*.priority', 'lang:admin::lang.menu_options.label_option_price', 'integer'], - ['option_values.*.allergens.*', 'lang:admin::lang.menus.label_allergens', 'integer'], + 'option_name' => ['required', 'min:2', 'max:32'], + 'display_type' => ['required', 'alpha'], + 'priority' => ['integer'], + 'locations.*' => ['integer'], + 'option_values.*.option_value_id' => ['integer'], + 'option_values.*.option_id' => ['integer'], + 'option_values.*.value' => ['min:2', 'max:128'], + 'option_values.*.price' => ['numeric', 'min:0'], + 'option_values.*.priority' => ['integer'], + 'option_values.*.allergens.*' => ['integer'], ]; } } diff --git a/apiresources/requests/OrderRequest.php b/apiresources/requests/OrderRequest.php index 064d998..52f5114 100644 --- a/apiresources/requests/OrderRequest.php +++ b/apiresources/requests/OrderRequest.php @@ -7,30 +7,54 @@ class OrderRequest extends FormRequest { + public function attributes() + { + return [ + 'first_name' => lang('igniter.cart::default.checkout.label_first_name'), + 'last_name' => lang('igniter.cart::default.checkout.label_last_name'), + 'email' => lang('igniter.cart::default.checkout.label_email'), + 'telephone' => lang('igniter.cart::default.checkout.label_telephone'), + 'comment' => lang('igniter.cart::default.checkout.label_comment'), + 'payment' => lang('igniter.cart::default.checkout.label_payment_method'), + 'order_type' => lang('igniter.cart::default.checkout.label_order_type'), + 'address_id' => lang('igniter.cart::default.checkout.label_address'), + 'address.address_1' => lang('igniter.cart::default.checkout.label_address_1'), + 'address.address_2' => lang('igniter.cart::default.checkout.label_address_2'), + 'address.city' => lang('igniter.cart::default.checkout.label_city'), + 'address.state' => lang('igniter.cart::default.checkout.label_state'), + 'address.postcode' => lang('igniter.cart::default.checkout.label_postcode'), + 'address.country_id' => lang('igniter.cart::default.checkout.label_country'), + ]; + } + public function rules() { $method = Request::method(); - $namedRules = [ - ['first_name', 'lang:igniter.cart::default.checkout.label_first_name', ($method == 'post' ? 'required|' : '').'between:1,48'], - ['last_name', 'lang:igniter.cart::default.checkout.label_last_name', ($method == 'post' ? 'required|' : '').'between:1,48'], - ['email', 'lang:igniter.cart::default.checkout.label_email', 'sometimes|required|email:filter|max:96'], - ['telephone', 'lang:igniter.cart::default.checkout.label_telephone', ''], - ['comment', 'lang:igniter.cart::default.checkout.label_comment', 'max:500'], - ['payment', 'lang:igniter.cart::default.checkout.label_payment_method', 'sometimes|required|alpha_dash'], - ['order_type', 'lang:igniter.cart::default.checkout.label_order_type', ($method == 'post' ? 'required' : '')], + $rules = [ + 'first_name' => ['between:1,48'], + 'last_name' => ['between:1,48'], + 'email' => ['sometimes', 'required', 'email:filter', 'max:96'], + 'comment' => ['max:500'], + 'payment' => ['sometimes', 'required', 'alpha_dash'], ]; + if ($method == 'post') { + $rules['first_name'][] = 'required'; + $rules['last_name'][] = 'required'; + $rules['order_type'][] = 'required'; + } + if (Request::input('order_type', 'collection') == 'delivery') { - $namedRules[] = ['address_id', 'lang:igniter.cart::default.checkout.label_address', 'required|integer']; - $namedRules[] = ['address.address_1', 'lang:igniter.cart::default.checkout.label_address_1', 'required|min:3|max:128']; - $namedRules[] = ['address.address_2', 'lang:igniter.cart::default.checkout.label_address_2', 'sometimes|min:3|max:128']; - $namedRules[] = ['address.city', 'lang:igniter.cart::default.checkout.label_city', 'sometimes|min:2|max:128']; - $namedRules[] = ['address.state', 'lang:igniter.cart::default.checkout.label_state', 'sometimes|max:128']; - $namedRules[] = ['address.postcode', 'lang:igniter.cart::default.checkout.label_postcode', 'string']; - $namedRules[] = ['address.country_id', 'lang:igniter.cart::default.checkout.label_country', 'sometimes|required|integer']; + $rules['address_id'] = ['required', 'integer']; + $rules['address.address_1'] = ['required', 'min:3', 'max:128']; + $rules['address.address_2'] = ['sometimes', 'min:3', 'max:128']; + $rules['address.city'] = ['sometimes', 'min:2', 'max:128']; + $rules['address.state'] = ['sometimes', 'max:128']; + $rules['address.postcode'] = ['string']; + $rules['address.country_id'] = ['sometimes', 'required', 'integer']; } - return $namedRules; + return $rules; } } diff --git a/apiresources/requests/ReservationRequest.php b/apiresources/requests/ReservationRequest.php index c2a407b..1153a24 100644 --- a/apiresources/requests/ReservationRequest.php +++ b/apiresources/requests/ReservationRequest.php @@ -6,19 +6,35 @@ class ReservationRequest extends FormRequest { + public function attributes() + { + return [ + 'table_id' => lang('admin::lang.reservations.column_table'), + 'location_id' => lang('igniter.reservation::default.label_location'), + 'guest_num' => lang('igniter.reservation::default.label_guest_num'), + 'reserve_date' => lang('igniter.reservation::default.label_date'), + 'reserve_time' => lang('igniter.reservation::default.label_time'), + 'first_name' => lang('igniter.reservation::default.label_first_name'), + 'last_name' => lang('igniter.reservation::default.label_last_name'), + 'email' => lang('igniter.reservation::default.label_email'), + 'telephone' => lang('igniter.reservation::default.label_telephone'), + 'comment' => lang('igniter.reservation::default.label_comment'), + ]; + } + public function rules() { return [ - ['table_id', 'lang:admin::lang.reservations.column_table', 'required|integer'], - ['location_id', 'lang:igniter.reservation::default.label_location', 'required|integer'], - ['guest_num', 'lang:igniter.reservation::default.label_guest_num', 'required|integer'], - ['reserve_date', 'lang:igniter.reservation::default.label_date', 'required|date_format:Y-m-d'], - ['reserve_time', 'lang:igniter.reservation::default.label_time', 'required|date_format:H:i'], - ['first_name', 'lang:igniter.reservation::default.label_first_name', 'required|between:1,48'], - ['last_name', 'lang:igniter.reservation::default.label_last_name', 'required|between:1,48'], - ['email', 'lang:igniter.reservation::default.label_email', 'required|email:filter|max:96'], - ['telephone', 'lang:igniter.reservation::default.label_telephone', 'required'], - ['comment', 'lang:igniter.reservation::default.label_comment', 'max:520'], + 'table_id' => ['required', 'integer'], + 'location_id' => ['required', 'integer'], + 'guest_num' => ['required', 'integer'], + 'reserve_date' => ['required', 'date_format:Y-m-d'], + 'reserve_time' => ['required', 'date_format:H:i'], + 'first_name' => ['required', 'between:1,48'], + 'last_name' => ['required', 'between:1,48'], + 'email' => ['required', 'email:filter', 'max:96'], + 'telephone' => ['required'], + 'comment' => ['max:520'], ]; } }