在此整理一下模型常用屬性,以備日後查詢。
$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' => [],
];