CakePHP 3 Nested Resources Not Working Properly -
apologies rather vague title, i'm not sure how else describe problem i'm having.
i have 'admin' prefix route configured, , within prefix want set nested resources. have following set up:
groups hasmany users users hasmany items items hasmany comments
i want urls reflect relationship between groups, users, items, comments, etc. instance, here example urls:
/admin/groups (list groups) /admin/groups/1 (view group id 1) /admin/groups/1/users (list users group id 1) /admin/groups/1/users/12 (view user id 12 group id 1) /admin/groups/1/users/12/items (list items belonging user id 12) ...you idea.
here relevant part of routes.php file:
router::scope('/', function ($routes) { $routes->prefix('admin', function ($routes) { $routes->resources('groups', function ($routes) { $routes->resources('users', function ($routes) { $routes->resources('items', function ($routes) { $routes->fallbacks('inflectedroute'); }); $routes->fallbacks('inflectedroute'); }); $routes->fallbacks('inflectedroute'); }); $routes->fallbacks('inflectedroute'); }); $routes->fallbacks('inflectedroute'); });
according documentation, should automatically create routes ones want, , degree does. instance, going /admin/groups/ call index() function of groupscontroller.php, , /admin/groups/1 call view($id) function. /admin/groups/1/users work (it calls index() function of userscontroller.php). however, that's far goes.
if go /admin/groups/1/users/1, following error message:
action 1 not defined in userscontroller error: create userscontroller::1() in file: src/controller/admin/userscontroller.php.
it seems nesting works degree, not far i'd expect, , not far documentation says will.
any appreciated.
Comments
Post a Comment