vendredi 24 juin 2016

laravel 5.1 error controller Missing argument 1

i have a foreach with my list of products in my index.blade.php, it work well, now i'm tryng to filter, i done my menu with my categories and genders.

I would like show products with category = "t-shirt" and gender= "woman" but i have this error:

ErrorException in StoreController.php line 36: Missing argument 1 for dixard\Http\Controllers\StoreController::products()

i'm using this link:

<a href="" title="">
     <span>Woman</span>
</a>

my route:

Route::get('shop', 'StoreController@index');
Route::get('shop/{category}/{gender}','StoreController@products');

My controller

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'));   


    }



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire