E
E
E6APB2017-09-26 16:33:58
Laravel
E6APB, 2017-09-26 16:33:58

How to make 3 different user groups in Laravel?

I will have 3 different user groups. They will not be similar to each other - there are too many differences in the fields. It is clear that you can make 3 tables for each user and create a guard for each, but this creates many restrictions, for example, when working with Laravel Passport - the user_id field is used in the table (that is, it is possible to work with only 1 group). How do I properly work with 3 very different groups?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Aksentiev, 2017-09-26
@E6APB

Never make different tables for users.
Especially if they intersect in the code, it will be such a hassle that you won’t rake it up later.
What does strong difference mean? Different fields in profiles, different accesses?
For this, they are divided into a group by any RBAC package.
And for super different profile fields, you can create a key value table and store absolutely any data in it. Instead of a ton of new columns in the user table.
A simplified version of the EAV approach.

A
Alexander Talalaev, 2017-09-26
@neuotq

If you are specifically concerned about Passport, then you can go by introducing a system of roles for users.
For example, there is an interesting package for organizing ACL https://github.com/spatie/laravel-permission , then all users will be in one table, and then you simply distribute roles and / or rights to each user.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question