Passed
Push — dev5 ( e66ef8...5a922b )
by Ron
05:53
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'];
14
    protected $hidden = ['created_at', 'updated_at'];
15
16
    // public function Customers()
17
    // {
18
    //     return $this->belongsTo('App\customers', 'cust_id', 'cust_id');
19
    // }
20
21 4
    public function SystemTypes()
22
    {
23 4
        return $this->hasOne('App\SystemTypes', 'sys_id', 'sys_id');
24
    }
25
26
    public function CustomerSystemData()
27
    {
28
        return $this->hasMany('App\CustomerSystemData', 'cust_sys_id');
29
    }
30
31
    // public function SystemDataFields()
32
    // {
33
    //     return $this->hasManyThrough('App\SystemDataFields', 'App\CustomerSystemData', 'cust_sys_id', 'field_id', 'cust_sys_id', 'field_id');
34
    // }
35
36 2
    public function SystemDataFields()
37
    {
38 2
        return $this->belongsToMany('App\SystemDataFields', 'customer_system_data', 'cust_sys_id', 'field_id')->withPivot('value')->orderBy('order', 'ASC');
39
    }
40
}
41