0
votes

I am creating REST API using Cake resource. I have route for users:

/users

and now I want to create nested resource for users on projects

/projects/:projectId/users

However I don't want to use UsersController for this one, I want to use different controller. My routing looks like this:

$routes->resources('Users');
$routes->resources('Projects', function ($routes) {
    $routes->resources('Members');
});

I don't know how to set up that the route for MembersControlles is not members but users.

1
I don't think it is possible to create that type of alias, although I think it could be very useful. Try opening a enhancement request ticket in github. - José Lorenzo Rodríguez

1 Answers

1
votes

There are no aliases for resources from memory. The string passed to the resource is the controller name. So passing 'Members', CakePHP is going to look for the MembersController. But your Entity is obviously called User and your controller is UsersController? Which should contain your index, add, edit, delete methods for the RESTful API. To create an alias you could try inheritance, you could create a MembersController and have it extend your UsersController?