Let's assume we have 2 such routes:
Route::get('{categoryitem}', ['as' => 'category_index', 'uses' => 'CategoryDisplayController@index']);
Route::get('{entryitem}', ['as' => 'entry', 'uses' => 'EntryController@show']);
There are no parameter constraints for parameters and 2 following route model bindings are defined:
Route::bind('categoryitem', function($slug)
{
return Category::whereSlug($slug)->root()->firstOrFail();
});
Route::bind('entryitem', function($slug)
{
return Entry::whereSlug($slug)->firstOrFail();
});
Now let's assume that URL we run is http://project/something
. Is it possible to make Laravel look first in route categoryitem
for something
slug and in case no model is found it will look in the second route for entry with slug something
? I haven't found solution for this other than adding some prefix/suffix to route