Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vincent15000's avatar

Admin and superadmin roles

Hello,

I wonder if there is a best pratice to add an admin and a superadmin role to users.

It is possible to :

  • add a boolean admin and a boolean superadmin fields to the user table
  • add a new roles table and a role_id to the user table considering that a superadmin has more rights than an admin who has more rights than a member (simply connected)
  • add a new roles table and a user_role table to be able to give several roles to a user

And then I protect my routes with a middleware to verify if the user has a wanted role or not.

Do you any opinion about the better way to do that ?

Thank you.

V

0 likes
3 replies
vincent15000's avatar

Thank you @sinnbeck, I have read this doc. Well ... I'm not sure I need a real superadmin role.

My superadmin will be an admin who's able to add or revoke the admin role for a user, only that.

My admin will be able to manage the shared datas of the app (for example : categories, types, ...) and activate or deactivate a user and perhaps delete some datas published by the members if there are abuses.

All the other users are simple members and are only able to manage their own events, organizations, ...

Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

Then I would just use the package to give special permissions to both admin and "superadmin" roles

Please or to participate in this conversation.