Entity   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 14
dl 0
loc 32
rs 10
c 2
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fields() 0 3 1
A scopeExternal() 0 3 1
1
<?php
2
/**
3
 * @author  Eddy <[email protected]>
4
 */
5
6
namespace App\Model\Admin;
7
8
class Entity extends Model
9
{
10
    const COMMENT_ENABLE = 1;
11
    const COMMENT_DISABLE = 0;
12
13
    const INTERNAL_YES = 1;
14
    const INTERNAL_NO = 0;
15
16
    const CONTENT_MANAGE_YES = 1;
17
    const CONTENT_MANAGE_NO = 0;
18
19
    protected $guarded = [];
20
21
    public static $listField = [
22
        'name' => '名称',
23
        'table_name' => '数据库表名',
24
        'description' => '描述',
25
    ];
26
27
    public function fields()
28
    {
29
        return $this->hasMany('App\Model\Admin\EntityField', 'entity_id');
30
    }
31
32
    /**
33
     * 限制查询外部模型
34
     *
35
     * @return \Illuminate\Database\Eloquent\Builder
36
     */
37
    public function scopeExternal($query)
38
    {
39
        return $query->where('is_internal', self::INTERNAL_NO);
40
    }
41
}
42