0
votes

I have a project where I have changed the User model primary key from "id" to "MemberX" using the following command in my User.php model file:

protected $primaryKey = 'MemberID'

But my Passport accessToken Table Still uses "id".I want "MemberX"

id

user_id :::::Here i want MemberID not id

client_id name scopes revoked created_at updated_at expires_at

2
Why does it matter what the Passport table uses? (And why not use standard Laravel naming conventions?)ceejayoz
what passport table uses it refects in the token. The token contains "id" and i want to change the primary key id to another keysatish ray

2 Answers

1
votes

Add this code to your User model

{
   return $this->hasMany(Passport::clientModel(), 'user_id', 'MemberID');
}
0
votes

Maybe you should check if the driver on the laravel/config/auth.php has eloquent instead of database?

'providers' => [
        'users' => [
            'driver' => 'eloquent', //instead of database
            'model' => App\User::class,
        ],

database uses DatabaseUserProvider which the find method only looks on the id column.

eloquent uses EloquentUserProvider which the find method looks at the primary key if $primaryKey is defined before looking at id.