我有我的index.blade.php中的產品列表foreach,它工作得很好,現在我嘗試過濾,我做了我的菜單與我的類別和性別。laravel 5.1錯誤控制器缺少參數1
我想展示產品類別= 「T恤」 和性別= 「女」,但我有此錯誤:
ErrorException in StoreController.php line 36: Missing argument 1 for dixard\Http\Controllers\StoreController::products()
我使用這個鏈接:
<a href="{{url('shop', ['category'=> 't-shirt', 'gender' => 'woman'])}}" title="">
<span>Woman</span>
</a>
我的路線:
Route::get('shop', '[email protected]');
Route::get('shop/{category}/{gender}','[email protected]');
我控制器
public function products($category, $gender)
{
$gender_id= Gender::where('gender', $gender)->first();
$category_id= Category::where('name', $category)->first();
$filter = ['gender_id' => $gender_id->id, 'category_id' => $category_id->id];
$products = Product::where($filter)->orderBy('id', 'asc')->get();
$categories = Category::all();
return view('store.index', compact('products','categories'));
}
哪行在你的控制器代碼中是36? – Yani
@Yani第36行 - >公共函數產品($ category,$ gender) –