How to create 2 same name controllers managing same table schema

I would like to create controllers.
One controller is preferred to be located ‘https://xxx/shops’ for general users.
The other controller is preferred to be located ‘https://xxx/admin/shops’ for admin users.

Both controllers are different but same names.
However I would like to have both controllers manage same shop table in DB.

How can I create them with ‘mix phx.gen.html’ ?

My idea is following.

controllers/shop_controller.ex for General Users.
controllers/admin/shop_controller.ex for Admin Users.

Thanks.

From the documentation:

Web namespace

By default, the controller and view will be namespaced by the schema name. You can customize the web module namespace by passing the --web flag with a module name, for example:

mix phx.gen.html Sales User users --web Sales

Which would generate a lib/app_web/controllers/sales/user_controller.ex and lib/app_web/views/sales/user_view.ex .

3 Likes