Custom route model binding :)
<?php
Route::get('{parentCategory}/...', 'controller@method');
And bind 'parentCategory' to the route, see: http://laravel.com/docs/routing#route-model-binding. And add some more bindings for more layers.
Question
I have a route:
Route::get('/{slug}c{id}','Category@index');
which works for http://domain.tld/arbitrarycategory-c22
but I'd like to make a wildcard route that matches any arbitrary sub directory as well. My controller only cares about the -c{id} portion of the route, anything before that is arbitrary and ignored. I'm looking for one route that would match these two:
http://domain.tld/arbitrarycategory-c22
http://domain.tld/parentcategory/childcategory/category-c22
Any ideas?
Solution
Custom route model binding :)
<?php
Route::get('{parentCategory}/...', 'controller@method');
And bind 'parentCategory' to the route, see: http://laravel.com/docs/routing#route-model-binding. And add some more bindings for more layers.