Completed
Push — develop ( 5f1168...aa9d13 )
by Daniel
05:30
created

User::ports()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace App;
4
5
use Illuminate\Foundation\Auth\User as Authenticatable;
6
7
class User extends Authenticatable
8
{
9
    /**
10
     * The attributes that are mass assignable.
11
     *
12
     * @var array
13
     */
14
    protected $fillable = [
15
        'realname', 'username', 'password', 'email', 'level',
16
    ];
17
    protected $primaryKey = 'user_id';
18
19
    /**
20
     * The attributes excluded from the model's JSON form.
21
     *
22
     * @var array
23
     */
24
    protected $hidden = [
25
        'password', 'remember_token',
26
    ];
27
28
    // ---- Define Reletionships ----
29
30
    /**
31
     * Returns a list of devices this user has access to
32
     */
33
    public function devices() {
34
        return $this->belongsToMany('App\Devices', 'devices_perms', 'user_id', 'device_id');
35
    }
36
37
    /**
38
     * Returns a list of ports this user has access to
39
     */
40
    public function ports() {
41
        return $this->belongsToMany('App\Ports', 'ports_perms', 'user_id', 'port_id');
42
    }
43
}
44