Category::entity()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * @author  Eddy <[email protected]>
4
 */
5
6
namespace App\Model\Admin;
7
8
class Category extends Model
9
{
10
    protected $guarded = [];
11
12
    public static $searchField = [
13
        'name' => '名称',
14
    ];
15
16
    public static $listField = [
17
        'parentName' => '上级分类',
18
        'entityName' => '关联模型',
19
        'order' => '排序',
20
    ];
21
22
    public function parent()
23
    {
24
        return $this->belongsTo('App\Model\Admin\Category', 'pid');
25
    }
26
27
    public function children()
28
    {
29
        return $this->hasMany('App\Model\Admin\Category', 'pid');
30
    }
31
32
    public function entity()
33
    {
34
        return $this->belongsTo('App\Model\Admin\Entity', 'model_id');
35
    }
36
}
37