How to configure relational routing in config file for REST API.
Long story short question: How to configure config/main.php to get this url
app.com/api/v1/roles/1/users
Full question:
I have already configured route for users and roles like this
GET all users
app.com/api/v1/users
GET user 1
app.com/api/v1/users/1
GET all roles
app.com/api/v1/roles
GET role 1
app.com/api/v1/roles/1
For the above routing i have something like this in my common/config/main.php. And i have placed model User and Role in modules/v1/models and placed controller UserController and RoleController in modules/v1/controller.
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [
[
'class' => 'yii\rest\UrlRule',
'controller' => [
'v1/user',
'v1/role'
],
'tokens' => [
'{id}' => '<id:\\w+>'
],
]
],
],
So what should i write in the urlManager to get the users of a particular role in this url format