3
我在我的控制器之一中有此功能。Laravel查询生成器不使用变量get方法
public function tourList($country, $category)
{
$tour = Tour::whereHas('country', function($q) {
$q->where('name','=', $country);
})
->whereHas('category', function($r) {
$r->where('name','=', $category);
})
->get();
return view('tour-list.blade.php')->withTour('$tour');
}
虽然从get方法中传递了两个变量。但我得到的
Undefined variable: country
告诉我@zacharyDale – PassionInfinite
路由的路由路径::得到('tour/{country}/{categpry}',['as'=>'tour.list','uses'=>'PublicController @ tourList']); –
这是我的路线 –