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