status = $httpStatusCode; } public function authorize() { return true; } public function messages() { return [ 'dimensions' => 'Image size must be 1020 x 621' ]; } /** * Get the validation rules that apply to the request. * * @return array */ public function rules(Request $request) { /* Input from PUT requests sent as multipart/form-data is unavailable check thread if fixed : https://github.com/laravel/framework/issues/13457 */ if($this->route('uuid') == null) { // STORE $rules = [ 'title' => 'required|max:32', 'description' => 'required', 'image' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:100|dimensions:max_width=1020,max_height=621,min_width=1020,min_height=621', 'date_start' => ['required', 'date', new DateRange($request)], 'date_end' => 'required|date', 'is_toppromotion' => 'required', 'is_gps' => 'required', 'promo_type' => 'required', ]; return $rules; } else { // UPDATE $uuid = !empty($this->route('promotion')) ? $this->route('promotion') : $this->route('uuid'); $details = Promotions::wherePromotionUuid($uuid)->first(); $rules = [ 'title' => 'required|max:32', 'description' => 'required', 'image' => 'image|mimes:jpeg,png,jpg,gif,svg|max:100|dimensions:max_width=1020,max_height=621,min_width=1020,min_height=621', 'date_start' => ['required', 'date', new DateRange($request)], 'date_end' => 'required|date', 'is_toppromotion' => 'required', 'is_gps' => 'required', 'promo_type' => 'required', ]; return $rules; } } public function response(array $errors) { return $this->status->unprocessableEntity('Form Validation Error',$errors); } } ?>