0

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

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

4

1 回答 1

2

似乎这是由于我有searchable: true两个不同的模型columns.yaml

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

于 2017-06-19T13:15:34.387 回答