Test Failed
Push — dev5 ( 7acea7...d3ea14 )
by Ron
07:30
created

Customers::CustomerSystems()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
nc 1
nop 0
dl 0
loc 3
c 1
b 0
f 0
cc 1
ccs 1
cts 1
cp 1
crap 1
rs 10
1
<?php
2
3
namespace App;
4
5
use Illuminate\Database\Eloquent\Model;
6
use Illuminate\Database\Eloquent\SoftDeletes;
7
8
class Customers extends Model
9
{
10
    use SoftDeletes;
11
12
    protected $primaryKey = 'cust_id';
13
    protected $fillable   = ['cust_id', 'parent_id', 'name', 'dba_name', 'address', 'city', 'state', 'zip', 'active'];
14
    protected $hidden     = ['created_at', 'deleted_at', 'updated_at'];
15
    protected $appends    = ['child_count'];
16 16
17
    public function CustomerSystems()
18 16
    {
19
        return $this->hasMany('App\CustomerSystems', 'cust_id', 'cust_id');
20
    }
21
22
    public function getChildCountAttribute()
23
    {
24
        return Customers::where('parent_id', $this->cust_id)->count();
25
    }
26
}
27