Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
66.67% covered (warning)
66.67%
4 / 6
66.67% covered (warning)
66.67%
2 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
PersonalAccessClient
66.67% covered (warning)
66.67%
4 / 6
66.67% covered (warning)
66.67%
2 / 3
4.59
0.00% covered (danger)
0.00%
0 / 1
 booted
50.00% covered (danger)
50.00%
2 / 4
0.00% covered (danger)
0.00%
0 / 1
2.50
 client
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getConnectionName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
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 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    /**
29     * The guarded attributes on the model.
30     *
31     * @var array
32     */
33    protected $guarded = [];
34
35    /**
36     * Get all of the authentication codes for the client.
37     */
38    public function client(): BelongsTo
39    {
40        return $this->belongsTo(Passport::clientModel());
41    }
42
43    /**
44     * Get the current connection name for the model.
45     */
46    public function getConnectionName(): ?string
47    {
48        return config('passport.storage.database.connection') ?? $this->connection;
49    }
50}