Test Setup Failed
Push — dev6 ( 01d104...b652d0 )
by Ron
17:32
created

Customer::CustomerFile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace App\Models;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Database\Eloquent\SoftDeletes;
7
use Illuminate\Database\Eloquent\Factories\HasFactory;
8
9
class Customer extends Model
10
{
11
    use HasFactory;
12
    use SoftDeletes;
13
14
    protected $primaryKey = 'cust_id';
15
    protected $guarded    = ['updated_at', 'created_at', 'deleted_at'];
16
    protected $hidden     = ['updated_at', 'created_at', 'deleted_at'];
17
18
    public function EquipmentType()
19
    {
20
        return $this->hasManyThrough('App\Models\EquipmentType', 'App\Models\CustomerEquipment', 'cust_id', 'equip_id', 'cust_id', 'equip_id');
21
    }
22
23
    //  TODO - ParentEquipmentType()
24
25
    public function ParentEquipment()
26
    {
27
        //  TODO - verify only shared equipment make it through
28
        return $this->hasMany(CustomerEquipment::class, 'cust_id', 'parent_id')->where('shared', true);
29
    }
30
31
    public function CustomerEquipment()
32
    {
33
        return $this->hasMany(CustomerEquipment::class, 'cust_id', 'cust_id');
34
    }
35
36
    public function Parent()
37
    {
38
        return $this->belongsTo(Customer::class, 'parent_id', 'cust_id');
39
    }
40
41
    public function CustomerContact()
42
    {
43
        return $this->hasMany(CustomerContact::class, 'cust_id', 'cust_id');
44
    }
45
46
    public function ParentContact()
47
    {
48
        return $this->hasMany(CustomerContact::class, 'cust_id', 'parent_id')->where('shared', true);
49
    }
50
51
    public function CustomerNote()
52
    {
53
        return $this->hasMany(CustomerNote::class, 'cust_id', 'cust_id');
54
    }
55
56
    public function CustomerFile()
57
    {
58
        return $this->hasMany(CustomerFile::class, 'cust_id', 'cust_id');
59
    }
60
61
    public function ParentFile()
62
    {
63
        return $this->hasMany(CustomerFile::class, 'cust_id', 'parent_id')->where('shared', true);
64
    }
65
}
66