2016-03-25 01:18:05 -07:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Requests;
|
2017-01-12 02:20:20 -08:00
|
|
|
use App\Helpers\Helper;
|
2016-03-25 01:18:05 -07:00
|
|
|
|
|
|
|
use Illuminate\Foundation\Http\FormRequest;
|
|
|
|
|
|
|
|
abstract class Request extends FormRequest
|
|
|
|
{
|
|
|
|
protected $rules = [];
|
|
|
|
|
|
|
|
public function rules()
|
|
|
|
{
|
|
|
|
return $this->rules;
|
|
|
|
}
|
|
|
|
|
2017-01-12 02:20:20 -08:00
|
|
|
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);
|
|
|
|
}
|
2016-03-25 01:18:05 -07:00
|
|
|
}
|