app/Passport/Client.php
<?php
namespace App\Passport;
use App\Models\User;
use Laravel\Passport\Client as PassportClient;
class Client extends PassportClient
{
/**
* The database table used by the model.
*
* @var string
*/
protected $table = 'oauth_clients';
/**
* The guarded attributes on the model.
*
* @var array
*/
protected $guarded = [];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = [
'secret',
];
/**
* Disable find by id.
*
* @var bool
*/
public $incrementing = false;
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'grant_types' => 'array',
'personal_access_client' => 'bool',
'password_client' => 'bool',
'revoked' => 'bool',
];
/**
* Determine if the client is a "first party" client.
*
* @return bool
*/
public function firstParty()
{
return $this->personal_access_client || $this->password_client;
}
/**
* Determine if the client should skip the authorization prompt.
*
* @return bool
*/
public function skipsAuthorization()
{
return false;
}
/**
* Determine if the client is a confidential client.
*
* @return bool
*/
public function confidential()
{
return ! empty($this->secret);
}
/**
* Get the route key for the model.
*
* @return string
*/
public function getRouteKeyName()
{
return 'uuid';
}
/**
* Get the user that the client belongs to.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function user()
{
return $this->belongsTo(
User::class,
'user_id',
'uuid'
);
}
/**
* Get all of the authentication codes for the client.
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function authCodes()
{
return $this->hasMany(AuthCode::class, 'client_id',
'id');
}
/**
* Get all of the tokens that belong to the client.
*
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function tokens()
{
return $this->hasMany(Token::class, 'client_id', 'id');
}
}