【发布时间】:2023-03-03 00:01:01
【问题描述】:
我有一个这样的模型:
class Event extends Eloquent
{
protected $softDelete = true;
public function scopeSearchEvents($search_criteria)
{
return Event::whereIn('title',$search_criteria)
->orWhereIn('description',$search_criteria)
->whereApproved('1')
->orderBy('event_date','desc')
->get();
}
}
我像这样从控制器调用它:
$data = Event::search($search_criteria);
但它给出了这个错误:
Symfony \ Component \ Debug \ Exception \ FatalErrorException
Call to undefined method Illuminate\Events\Dispatcher::search()
从控制器调用自定义模型方法的最佳方式是什么?
【问题讨论】:
标签: php model controller laravel-4 eloquent