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

Customers::getChildCountAttribute()   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
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
ccs 0
cts 0
cp 0
crap 2
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