Completed
Pull Request — develop (#7)
by
unknown
08:55
created

Devices   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 3
c 1
b 1
f 0
lcom 1
cbo 1
dl 0
loc 31
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getIpAttribute() 0 4 1
A setIpAttribute() 0 4 1
A users() 0 3 1
1
<?php
2
3
namespace App;
4
5
use Illuminate\Database\Eloquent\Model;
6
7
class Devices extends Model
8
{
9
    protected $table = 'devices';
10
    protected $primaryKey = 'device_id';
11
12
    /**
13
     * Indicates if the model should be timestamped.
14
     *
15
     * @var bool
16
     */
17
    public $timestamps = false;
18
19
    public function getIpAttribute( $ip )
20
    {
21
        return inet_ntop( $ip );
22
    }
23
24
    public function setIpAttribute( $ip )
25
    {
26
        $this->attributes['ip'] = inet_pton( $ip );
27
    }
28
29
    // -- Define Reletionships --
30
31
    /**
32
     * Returns a list of users that can access this device
33
     */
34
    public function users() {
35
        return $this->belongsToMany('App\User', 'devices_perms', 'device_id', 'user_id');
36
    }
37
}
38
39