Added better form request handling

This will break a ton of things
This commit is contained in:
snipe 2017-01-12 02:20:20 -08:00
parent 15373d5f4a
commit fddcc0fefd

View file

@ -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);
}
}