Search code examples
phplaravel-5.3laravel-5.4laravel-passport

Call to undefined method Illuminate\Database\Query\Builder::withAccessToken()


This error has come up when I use postman with the api.php file.

Using the documentation example of Laravel 5.4 here is the code in the file.

Route::get('/user', function (Request $request) {
return $request->user() ; })->middleware('auth:api');

In postman I have these settings. Image of postman with accept and Auth settings

It seems really unusual to have these errors as HasApiTokens are in the relevant Models, so what is the problem?


Solution

  • i solved this by adding "use HasApiTokens, Notifiable;" in App/User.php