2017-06-19 103 views
0

添加範圍到工具欄搜索按文件我有以下代碼:在<a href="https://octobercms.com/docs/backend/lists#adding-toolbar" rel="nofollow noreferrer">https://octobercms.com/docs/backend/lists#adding-toolbar</a>十月

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

我不明白爲什麼會出現這個錯誤,因爲我確定我在模型中有正確的代碼來處理這個問題。

回答

2

看起來這是由事實,我在我的columns.yaml

結果searchable: true了兩個不同的模型引起似乎是因爲我在config_list.yaml一個scope: byEmail我需要提供全部scopeByEmail()方法我在columns.yaml

中定義了可搜索字段的模型
相關問題