Passed
Push — dev5a ( bf2271...c9bcfe )
by Ron
08:07
created

CustomerSystems::CustomerSystemData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
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 2
    public function SystemTypes()
18
    {
19 2
        return $this->hasOne('App\SystemTypes', 'sys_id', 'sys_id');
20
    }
21
22
    public function CustomerSystemData()
23
    {
24
        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
    public function getSysNameAttribute()
33
    {
34
        return $this->SystemTypes->name;
35
    }
36
}
37