App::user()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Yansongda\LaravelApi\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Yansongda\LaravelApi\Api;
7
8
class App extends Model
9
{
10
    /**
11
     * The database table used by the model.
12
     *
13
     * @var string
14
     */
15
    protected $table = 'api_apps';
16
17
    /**
18
     * The primary key for the model.
19
     *
20
     * @var string
21
     */
22
    protected $primaryKey = 'app_id';
23
24
    /**
25
     * The "type" of the auto-incrementing ID.
26
     *
27
     * @var string
28
     */
29
    protected $keyType = 'string';
30
31
    /**
32
     * Indicates if the IDs are auto-incrementing.
33
     *
34
     * @var bool
35
     */
36
    public $incrementing = false;
37
38
    /**
39
     * The guarded attributes on the model.
40
     *
41
     * @var array
42
     */
43
    protected $guarded = [];
44
45
    /**
46
     * The attributes excluded from the model's JSON form.
47
     *
48
     * @var array
49
     */
50
    protected $hidden = ['app_secret'];
51
52
    /**
53
     * Get the user that the token belongs to.
54
     *
55
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
56
     */
57
    public function user()
58
    {
59
        return $this->belongsTo(Api::$user, 'user_id');
60
    }
61
62
    /**
63
     * Get the app that the token belongs to.
64
     *
65
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
66
     */
67
    public function token()
68
    {
69
        return $this->hasOne(AccessToken::class, 'app_id', 'app_id');
70
    }
71
}
72