DEV Community

Discussion on: Implementing Laravel's built-in token authentication

Collapse
 
luisya22 profile image
luisya22

Undefined index: id in file \vendor\laravel\framework\src\Illuminate\Auth\GenericUser.php on line 44

When trying to make a request I receive this error

Collapse
 
grantholle profile image
Grant

Hey! It sounds like your User model doesn't have an id?

Whatever your "user" is will need to return your identifying attribute. By default it's id, but you can add this function to your User (or whatever) to return the right id column:

public function getAuthIdentifierName()
{
    // Change this to be your id column of your database
    return 'id';
}
Enter fullscreen mode Exit fullscreen mode