use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Http\Exceptions\HttpResponseException;
use Illuminate\Contracts\Validation\Validator;
class BaseRequest extends FormRequest
* Determine if the user is authorized to make this request.
* @return bool
public function authorize()
return true;
public function failedValidation(Validator $validator)
$error= $validator->errors()->all();
throw new HttpResponseException(response()->json(['code'=>400,'message'=>$error[0]]));