PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, October 19, 2022

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

 October 19, 2022     admin, database, laravel, roles     No comments   

Issue

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

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.



Answered By - Mátyás GrÅ‘ger
Answer Checked By - Candace Johnson (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing