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']); –
這是我的路線 –