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

CustomerSystems   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 75%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 27
ccs 6
cts 8
cp 0.75
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A SystemTypes() 0 3 1
A getSysNameAttribute() 0 3 1
A SystemDataFields() 0 3 1
A CustomerSystemData() 0 3 1
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