From b05d0f3f5602ca4ab0ebb9934952baa3ce04e2ed Mon Sep 17 00:00:00 2001 From: Matt Koch Date: Fri, 19 Oct 2018 03:13:45 +0000 Subject: [PATCH] Add user relationship to client model. --- src/Client.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/Client.php b/src/Client.php index 8e16fa9c9..6165526cd 100644 --- a/src/Client.php +++ b/src/Client.php @@ -61,6 +61,18 @@ public function tokens() return $this->hasMany(Passport::tokenModel(), 'client_id'); } + /** + * Get the user that the client belongs to. + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + */ + public function user() + { + $provider = config('auth.guards.api.provider'); + + return $this->belongsTo(config('auth.providers.'.$provider.'.model')); + } + /** * Determine if the client is a "first party" client. *