public function validate(Request $request, array $rules, array $messages = [], array $customAttributes = [])
{
$validator = $this->getValidationFactory()->make($request->all(), $rules, $messages, $customAttributes);
if ($validator->fails()) {
if (Route::current()->getPrefix() === 'api') {
$message = $validator->errors()->first();
throw new ValidationException($message);
} else {
throw new ValidationException($this);
}
}
}