If I have two route groups (for simple prefixing of routes) is it possible to Route::bind per just that group?
When I do the following:
Route::group( array('prefix'=>'pre1'), function(){
Route::bind('items', function( $value, $route ){
$item = Item::find( $value );
if( !$item ) App::abort( 404 );
return $item;
})
Route::resource('items', .... );
})
Route::group( array('prefix'=>'pre2'), function(){
//put bind for users here...
Route::bind('items', function( $value, $route ){
$user_id = $route->parameter('users')->getAttribute('id');
$item = Item::where('id', $value)->whereUserId( $user_id );
if( !$item ) App::abort( 404 );
return $item;
})
Route::resource('users.items', ....)
})
The first bind to 'items' is overridden by the last one declared. I would rename the 'items' to something else, but nested Resource routes are auto generated by laravel.
Ie the first route is
/items/{items}
where the second is
/users/{users}/items/{items}
I would simply rename the end routes, but they make sense with regards to the resources being used from an admin having permissions on one resource and users on the other.