Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What is the better wat ro create admin role in Laravel?

I want to create simple SPA with admin-panel. I did panel and fronted part. Now I have two solutions way:

  • Use enum type of row in database: $table->enum(‘role’, [‘user’, ‘admin]);
  • Create another ‘roles’ table and insert there: ‘user’ and ‘admin’
    Which is the better way and why?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Always try to go for the simplest, clearest solution. As long a you only have 2 roles, admin and user, and a customer can only have one role, the first solution is much easier.

Defining a new table would give unwanted complexity, and also to ask for each user it’s role from a different table could be timeconsuming.

Perhaps if you have more roles, and a user can have multiple roles, the second solution is more clear.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading