AccessToken   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 41
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A user() 0 3 1
A app() 0 3 1
1
<?php
2
3
namespace Yansongda\LaravelApi\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Yansongda\LaravelApi\Api;
7
8
class AccessToken extends Model
9
{
10
    /**
11
     * The database table used by the model.
12
     *
13
     * @var string
14
     */
15
    protected $table = 'api_access_tokens';
16
17
    /**
18
     * The guarded attributes on the model.
19
     *
20
     * @var array
21
     */
22
    protected $guarded = ['id'];
23
24
    /**
25
     * The attributes that should be mutated to dates.
26
     *
27
     * @var array
28
     */
29
    protected $dates = ['expired_at'];
30
31
    /**
32
     * Get the user that the token belongs to.
33
     *
34
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
35
     */
36
    public function user()
37
    {
38
        return $this->belongsTo(Api::$user, 'user_id');
39
    }
40
41
    /**
42
     * Get the app that the token belongs to.
43
     *
44
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
45
     */
46
    public function app()
47
    {
48
        return $this->belongsTo(App::class, 'app_id', 'app_id');
49
    }
50
}
51