Passed
Push — dev5 ( a24f56...eeca7a )
by Ron
08:23
created

CustomerSystems::getSysNameAttribute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace App;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Database\Eloquent\SoftDeletes;
7
8
class CustomerSystems extends Model
9
{
10
    use SoftDeletes;
11
12
    protected $primaryKey = 'cust_sys_id';
13
    protected $fillable   = ['cust_id', 'sys_id', 'shared'];
14
    protected $hidden     = ['created_at', 'updated_at', 'deleted_at', 'SystemTypes'];
15
    protected $appends    = ['sys_name'];
16
17 6
    public function SystemTypes()
18
    {
19 6
        return $this->hasOne('App\SystemTypes', 'sys_id', 'sys_id');
20
    }
21
22 4
    public function CustomerSystemData()
23
    {
24 4
        return $this->hasMany('App\CustomerSystemData', 'cust_sys_id');
25
    }
26
27
    public function SystemDataFields()
28
    {
29
        return $this->belongsToMany('App\SystemDataFields', 'customer_system_data', 'cust_sys_id', 'field_id')->withPivot('value')->orderBy('order', 'ASC');
30
    }
31
32 6
    public function getSysNameAttribute()
33
    {
34 6
        return $this->SystemTypes->name;
35
    }
36
}
37