I am using the following code in Routes.php to bind multiple parameters (using my own resolution logic). It works ok, but seems a bit clunky. Anyone know of a better way?
Route::bind('cat', function($value)
{
return \App\Page::where('category', $value)->first();
});
Route::bind('subcat', function($value)
{
return \App\Page::where('sub_category', $value)->first();
});
Route::get('{cat}/{subcat}', function (App\Page $cat, App\Page $subcat)
{
return dd($subcat);
});
....Actually I really need to be able to bind both 'cat' and 'subcat' together in the same Closure, rather than seperately. Otherwise 'subcats' with the same name (but in different 'cats') wont be returned. Anyone know a way to do this?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community