Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 6 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| PersonalAccessClient | |
0.00% |
0 / 6 |
|
0.00% |
0 / 3 |
20 | |
0.00% |
0 / 1 |
| booted | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
6 | |||
| client | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getConnectionName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Http\Models\Passport; |
| 4 | |
| 5 | use App\Http\Models\Moloquent; |
| 6 | use Illuminate\Database\Eloquent\Relations\BelongsTo; |
| 7 | use Laravel\Passport\Passport; |
| 8 | |
| 9 | class PersonalAccessClient extends Moloquent |
| 10 | { |
| 11 | /** |
| 12 | * The database table used by the model. |
| 13 | * |
| 14 | * @var string |
| 15 | */ |
| 16 | protected $table = 'oauth_personal_access_clients'; |
| 17 | |
| 18 | // protected $primaryKey = 'id'; // Passport espera este campo |
| 19 | protected static function booted() |
| 20 | { |
| 21 | static::creating(function ($model) { |
| 22 | if (empty($model->id)) { |
| 23 | $model->id = (string) \Str::uuid(); // Ou crie um hash/token Ășnico! |
| 24 | } |
| 25 | }); |
| 26 | } |
| 27 | /** |
| 28 | * The guarded attributes on the model. |
| 29 | * |
| 30 | * @var array |
| 31 | */ |
| 32 | protected $guarded = []; |
| 33 | |
| 34 | /** |
| 35 | * Get all of the authentication codes for the client. |
| 36 | */ |
| 37 | public function client(): BelongsTo |
| 38 | { |
| 39 | return $this->belongsTo(Passport::clientModel()); |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * Get the current connection name for the model. |
| 44 | */ |
| 45 | public function getConnectionName(): ?string |
| 46 | { |
| 47 | return config('passport.storage.database.connection') ?? $this->connection; |
| 48 | } |
| 49 | } |