Skip to content

Commit 5d35277

Browse files
committed
Fix broken relations when auth identifier is not PK
1 parent 951fe86 commit 5d35277

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/HasApiTokens.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ trait HasApiTokens
2727
*/
2828
public function clients(): HasMany
2929
{
30-
return $this->hasMany(Passport::clientModel(), 'user_id');
30+
return $this->hasMany(Passport::clientModel(), 'user_id', $this->getAuthIdentifierName());
3131
}
3232

3333
/**
@@ -37,7 +37,7 @@ public function clients(): HasMany
3737
*/
3838
public function oauthApps(): MorphMany
3939
{
40-
return $this->morphMany(Passport::clientModel(), 'owner');
40+
return $this->morphMany(Passport::clientModel(), 'owner', null, null, $this->getAuthIdentifierName());
4141
}
4242

4343
/**
@@ -47,7 +47,7 @@ public function oauthApps(): MorphMany
4747
*/
4848
public function tokens(): HasMany
4949
{
50-
return $this->hasMany(Passport::tokenModel(), 'user_id')
50+
return $this->hasMany(Passport::tokenModel(), 'user_id', $this->getAuthIdentifierName())
5151
->where(function (Builder $query): void {
5252
$query->whereHas('client', function (Builder $query): void {
5353
$query->where(function (Builder $query): void {

0 commit comments

Comments
 (0)