Answer the question
In order to leave comments, you need to log in
What is the best way to make authorization in Laravel?
Hello. There is a task to enable users to log in from different tables. Let's say I have a standard users table where simple users are stored. There is also a table where enterprise accounts are stored (almost the same users, but with different data). Here I think how best to deal with authorization:
1. Make a general table and just fill in only certain data (a simple user or companies)
2. Make different tables and somehow do authorization for companies in the controller.
In fact, the functionality almost does not change, so I think to make users in one table and not take a steam bath by screwing Permission. But most likely, with the first option, there will be pitfalls in the future, because. the functionality in the plans is different - something like VK groups. Companies can create a group where users can control all activities. So you have to add "internal administrators", "moderators", etc.
Please tell me the best way to do it.
Answer the question
In order to leave comments, you need to log in
When I did something similar, I had one users table where common data was stored for different groups, and each group had its own table where data unique to it was stored. Not sure if this is a good solution, but it worked
Just add a field in the user table group_id and write down the group ID there. Groups will be stored in a separate database.
Permissions will be tied to the group. And groups are your roles, types of users.
This way you get a lot of flexibility along with versatility, such as promotion/demotion/role change, changing user status, security controls, separation for mailing lists, ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question