Test Failed
Push — dev6 ( e3f62b...d58043 )
by Ron
17:13
created

CustomerEquipment::CustomerEquipmentData()   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 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
ccs 2
cts 2
cp 1
cc 1
nc 1
nop 0
crap 1
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 CustomerEquipment extends Model
10
{
11
    use HasFactory;
12
    use SoftDeletes;
13
14
    protected $primaryKey = 'cust_equip_id';
15
    protected $guarded    = ['cust_equip_id', 'updated_at', 'created_at'];
16
    protected $hidden     = ['created_at', 'updated_at', 'deleted_at', 'cust_id'];
17
    protected $appends    = ['name'];
18
    protected $casts      = [
19
        'shared'     => 'boolean',
20
        'deleted_at' => 'datetime:M d, Y',
21
    ];
22
23
    /*
24
    *   Get the name of the equipment without attaching the entire equipment object
25
    */
26 5
    public function getNameAttribute()
27
    {
28 5
        return EquipmentType::find($this->equip_id)->name;
29
    }
30
31
    /*
32
    *   Site specific information for the selected piece of equipment
33
    */
34 2
    public function CustomerEquipmentData()
35
    {
36 2
        return $this->hasMany('App\Models\CustomerEquipmentData', 'cust_equip_id', 'cust_equip_id');
37
    }
38
}
39