Hi there I have two routes that look identical except that one has an extra paramter called genre how do make them call their on routines and not have them mixed up.
Route::get('browse/{product_slug}', array(
'as' => 'products.view_by_producttype',
function($slug)
{
}
))->where('product_slug', '[A-Za-z\-]+');
Route::get('browse/{producttype_slug}/{genre_slug}', array(
'as' => 'products.view_by_producttype_genre',
function($productype_slug, $genre_slug)
{
}
))->where('producttype_slug', '[A-Za-z\-]+')->where('genre_slug', '[A-Za-z\-]+');
Upated Code and order:
Route::get('browse/{producttype_slug}', array(
'as' => 'products.view_by_producttype',
function($producttype_slug)
{
$producttype = ProductTypes::where('slug', '=', $producttype_slug)->firstOrFail();
$items = DB::table('products')->join('productvariations', function($join) {
$join->on('productvariations.product_id', '=', 'products.id');
})->where('producttype_id', '=', $producttype->id)->paginate(1);
return View::make('products.view_by_producttype')->with(compact('items', 'producttype'));
}
))->where('producttype_slug', '[A-Za-z\-]+');
Route::get('browse/{producttype_slug}/{genre_slug}', array(
'as' => 'products.view_by_producttype_genre',
function($producttype_slug, $genre_slug)
{
$producttype = ProductTypes::where('slug', '=', $producttype_slug)->firstOrFail();
$genre = GenreTypes::where('slug', '=', $genre_slug)->firstOrFail();
$items = DB::table('products')->join('product_genretypes', function($join) {
$join->on('product_genretypes.product_id', '=', 'products.id');
})->join('productvariations', function($join) {
$join->on('productvariations.product_id', '=', 'products.id');
})
->where('genretype_id', '=', $genre->id)
->where('producttype_id', '=', $producttype->id)
->paginate(1);
return View::make('products.view_by_type_genre')->with(compact('items', 'producttype', 'genre'));
}
))->where('producttype_slug', '[A-Za-z\-]+')->where('genre_slug', '[A-Za-z\-]+');