Test Setup Failed
Push — master ( ad0913...368932 )
by Dennis
14:58
created

Region::model()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
namespace SimpleCMS\Region\Models;
4
5
use Carbon\Carbon;
6
use Illuminate\Database\Eloquent\Model;
7
use SimpleCMS\Region\Casts\Point;
8
9
/**
10
 * Region Model
11
 
12
 * @author Dennis Lui <[email protected]>
13
 *
14
 * @property string $id 主键
15
 * @property string $name 社区名称
16
 * @property string $city_code 城市代码
17
 * @property string $city 城市名称
18
 * @property string $province_code 省份名称
19
 * @property string $province 省份名称
20
 * @property string $county_code 县区名称
21
 * @property string $county 县区名称
22
 * @property ?array $geo 地理信息
23
 * @property string $address 地址
24
 * @property-read ?Carbon $created_at 创建时间
25
 * @property-read ?Carbon $updated_at 更新时间
26
 * @property-read ?\Illuminate\Database\Eloquent\Relations\MorphTo $model 关联模型
27
 */
28
class Region extends Model
29
{
30
    
31
    /**
32
     * 可输入字段
33
     */
34
    protected $fillable = [
35
        'id',
36
        'name',
37
        'city_code',
38
        'city',
39
        'province_code',
40
        'province',
41
        'county_code',
42
        'county',
43
        'geo',
44
        'address'
45
    ];
46
47
    /**
48
     * 显示字段类型
49
     */
50
    public $casts = [
51
        'created_at' => 'datetime',
52
        'updated_at' => 'datetime',
53
        'geo' => Point::class
54
    ];
55
56
    /**
57
     * 关联模型
58
     *
59
     * @author Dennis Lui <[email protected]>
60
     * @return ?\Illuminate\Database\Eloquent\Relations\MorphTo
61
     */
62
    public function model()
63
    {
64
        return $this->morphTo();
65
    }
66
}
67