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

Jamie Ross picture Jamie Ross · Feb 28, 2017 · Viewed 9.4k times · Source

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?

Answer

ankit picture ankit · Mar 11, 2017

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