在10月份将工作区添加到工具栏搜索

时间:2017-06-19 11:54:23

标签: octobercms octobercms-backend

根据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()

我不明白为什么会出现这种错误,因为我确信我在模型中有正确的代码来处理这个错误。

1 个答案:

答案 0 :(得分:2)

这似乎是因为我columns.yaml

中有两个不同模型的scope: byEmail

结果似乎是因为我config_list.yaml中有一个scopeByEmail()我需要在我为{中定义的可搜索字段的所有模型中提供columns.yaml方法{1}}