根据https://octobercms.com/docs/backend/lists#adding-toolbar的文档,我有以下代码:
config_list.yaml
toolbar:
buttons: list_toolbar
search:
prompt: 'backend::lang.list.search_prompt'
scope: byEmail
Job.php (型号)
public function scopeByEmail($string, $query)
{
return $query->where('email', 'LIKE', '%' . $string . '%');
}
不幸的是,这会产生错误:Call to undefined method October\Rain\Database\QueryBuilder::byEmail()
我不明白为什么会出现这种错误,因为我确信我在模型中有正确的代码来处理这个错误。
答案 0 :(得分:2)
这似乎是因为我columns.yaml
scope: byEmail
结果似乎是因为我config_list.yaml
中有一个scopeByEmail()
我需要在我为{中定义的可搜索字段的所有模型中提供columns.yaml
方法{1}}