参考:https://learnku.com/articles/22328

$fillable = [
    '可批量填充的字段'
];

$guarded = [
    '与上相反'
];

$hidden = [
    '模型转换为数组时应当隐藏的字段'
];

$visable = [
    '与上相反'
];

$appends = [
    '模型转换为数组时应当追加的虚拟字段' // 例如访问器
];

$with = [
    '应当预加载的关联关系',
];

$attributes = [
    '字段名' => '字段默认值'
];

$casts = [
    '字段名' => '自动类型转换的目标类型'
];

$dates = [
    '应当被转换为日期时间的字段'
];

$touches = [
    '模型更新时应当一并更新的关联关系'
];

// 以下为部分扩展包使用的属性

// https://github.com/dwightwatson/validating
$rules = [
    '字段' => '模型自身验证规则'
];

// https://github.com/Askedio/laravel-soft-cascade
$softCascade = [
    '软删除时一并删除的关联'
];

// https://github.com/spatie/eloquent-sortable
$sortable = [
    'order_column_name' => 'order_column',
    'sort_when_creating' => true,
];

// https://github.com/nicolaslopezj/searchable
$searchable = [
    'columns' => [],
    'joins' => [],
];
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
上次更新: 6/29/2020, 11:34:37 AM