Laravel 5 Laravel抛出错误的队列调度方法
这是我的代码行Laravel 5 Laravel抛出错误的队列调度方法,laravel-5,jobs,Laravel 5,Jobs,这是我的代码行 public function getVisitedCountriesCountAttribute() { $this->dispatch(new CalculateTotalCountriesVisited($this)); return $this->total_countries; } 这里dispatch方法抛出一个错误 Call to undefined method Illuminate\Database\Query\Builder::
public function getVisitedCountriesCountAttribute()
{
$this->dispatch(new CalculateTotalCountriesVisited($this));
return $this->total_countries;
}
这里dispatch方法抛出一个错误
Call to undefined method Illuminate\Database\Query\Builder::dispatch() (View: /Users/mereeva/sites/rdb-ws/resources/views/users/trips/status.blade.php)
我似乎不明白这背后的原因是什么。我跟着所有的步骤走了进去
任何帮助都将不胜感激。谢谢如果您想从您的模型中调度,您必须使用trait
illumb\Foundation\Bus\DispatchesJobs代码>在其中,否则您将无法执行$this->分派(…
)
不使用此特性的另一种方法是使用dispatch helper:
dispatch(新的CalculateTotalCountries已查看($this));
这将自动解析应用程序容器中的调度程序。哦,非常感谢。Din意识到我在模型中使用了它。非常感谢