mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 05:34:06 -08:00
Added better form request handling
This will break a ton of things
This commit is contained in:
parent
15373d5f4a
commit
fddcc0fefd
|
@ -1,6 +1,7 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
use App\Helpers\Helper;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
|
@ -13,9 +14,15 @@ abstract class Request extends FormRequest
|
|||
return $this->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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue