Controller not recognized

adonis newbie
for some reason i can’t access methods inside the controller when i try to access the route : ‘admin/regions/allregions’ , i created another new controllers and i still have the same error here’s the screenshots :

I APPRECIATE YOUR HELP !

hi, welcome @Jinzo

you need create Admin folder, inside Http.

30

Like this picture.

Your RegController path is Controllers/Http/RegController.js, should be Controllers/Http/Admin/RegController.js or replace route.

Route.get("regions/allregions","RegController.allregions");

Regards!

2 Likes

thanks @codiplace for you reply and your welcoming :heart_eyes:
the admin folder is already created answer
the other controllers work just fine but all the ones i create now after those first two (CityController & PageController) don’t work

Move controllers inside Admin folder.

1 Like

:grin:

A controller can only be accessed from a route and by default namespaced to App/Controllers/Http

Route.get(url, 'UserController.index')

This case below, the UserController is inside Admin folder.
40

So, our route should be

Route.get(url, 'Admin/UserController.index')

check your routes.js and controller path.

hope will help

2 Likes

i assumed by creating the controllers they’ll automatically go to my Admin folder that i created, i’m stooooopid ! :joy:
Thanks @codiplace :raised_hands:

1 Like

its happens!!

if run adonis command like that

adonis make:controller Admin/User

new UserController will automatically go to Admin folder.

Happy coding!:robot:

3 Likes