Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 6 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| AuthCode | |
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 AuthCode extends Moloquent |
| 10 | { |
| 11 | /** |
| 12 | * The database table used by the model. |
| 13 | * |
| 14 | * @var string |
| 15 | */ |
| 16 | protected $table = 'oauth_auth_codes'; |
| 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 | * Indicates if the IDs are auto-incrementing. |
| 29 | * |
| 30 | * @var bool |
| 31 | */ |
| 32 | public $incrementing = false; |
| 33 | |
| 34 | /** |
| 35 | * The guarded attributes on the model. |
| 36 | * |
| 37 | * @var array |
| 38 | */ |
| 39 | protected $guarded = []; |
| 40 | |
| 41 | /** |
| 42 | * The attributes that should be cast to native types. |
| 43 | * |
| 44 | * @var array |
| 45 | */ |
| 46 | protected $casts = [ |
| 47 | 'expires_at' => 'datetime', |
| 48 | 'revoked' => 'bool', |
| 49 | ]; |
| 50 | |
| 51 | /** |
| 52 | * Indicates if the model should be timestamped. |
| 53 | * |
| 54 | * @var bool |
| 55 | */ |
| 56 | public $timestamps = false; |
| 57 | |
| 58 | /** |
| 59 | * The "type" of the primary key ID. |
| 60 | * |
| 61 | * @var string |
| 62 | */ |
| 63 | protected $keyType = 'string'; |
| 64 | |
| 65 | /** |
| 66 | * Get the client that owns the authentication code. |
| 67 | */ |
| 68 | public function client(): BelongsTo |
| 69 | { |
| 70 | return $this->belongsTo(Passport::clientModel()); |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * Get the current connection name for the model. |
| 75 | */ |
| 76 | public function getConnectionName(): ?string |
| 77 | { |
| 78 | return config('passport.storage.database.connection') ?? $this->connection; |
| 79 | } |
| 80 | } |