Permalink
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
31 lines (30 sloc) 1.02 KB
<?php
namespace App\Http\Controllers\Api\V1;
use App\Models\User;
use Dingo\Api\Http\Response;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Dingo\Api\Exception\ValidationHttpException;
use Dingo\Api\Routing\Helpers;
use Illuminate\Support\Facades\Auth;
use Laravel\Passport\Http\Controllers\AccessTokenController;
use Psr\Http\Message\ServerRequestInterface;
class DingoController extends Controller
{
use Helpers;
/**
* This method forces Laravel to put its validation errors
* into the errors array of a Dingo Response
*
* @param Request $request
* @param \Illuminate\Contracts\Validation\Validator $validator
*/
protected function throwValidationException(Request $request, $validator) {
throw new ValidationHttpException($validator->getMessageBag()->toArray());
}
protected function validateByValidator(Request $request, $validator) {
if ($validator->fails()){
$this->throwValidationException($request, $validator);
}
}
}