diff --git a/app/Http/Requests/Request.php b/app/Http/Requests/Request.php index 618c9f30f9..7ab4fc16b2 100644 --- a/app/Http/Requests/Request.php +++ b/app/Http/Requests/Request.php @@ -1,6 +1,7 @@ rules; } - // public function response(array $errors) - // { - // $this->session->flash('errorMessages', $errors); - // return $this->redirector->back()->withErrors($errors)->withInput(); - // } + public function response(array $errors) + { + if ($this->ajax() || $this->wantsJson()) + { + return Helper::formatStandardApiResponse('error', null, $errors); + } + + return $this->redirector->to($this->getRedirectUrl()) + ->withInput($this->except($this->dontFlash)) + ->withErrors($errors, $this->errorBag); + } }