I have two type of users (admin and normal user). There are two tables in database one for admin and other for normal users. I have created admin login using Auth driver, but i can set only one model and table for Auth driver in app/config/auth.php
Please help me solve this issue. I want to use Auth driver for both tables.
Why don't you have only one table for users and add a flag to identify user type.
this will also reduce the redundancy in user details, such as: first_name, last_name, email, etc...
You really should only be using one table to store users. What happens if you need to add another type of user, say moderators? Are you going to create a third table?
What would be a good approach to this? I am currently working on a project for a construction company and I have staff users who are actually admin users with different levels of permissions (some can only create certain resources and some can also delete resources) and contractors who are only able to view job documentation, financial docs pertaining to their jobs etc. I am trying to keep all users in the same table, but the logic quickly becomes convoluted. With every request I have to check "is it an admin?", "is it a contractor?", "if it's an admin, can they delete this, or create the other?", "if it's a contractor, can they view this, upload the other?" etc. On top of that, the client is talking about introducing multiple logins associated with their account after this phase of the project is done. I do believe having two tables for staff and contractors would keep things cleaner and easier to maintain and upgrade.
So a user can belong to multiple groups and each group can have multiple (and overlapping) permissions. This solved a problem similar to the one you described.
The article is for L4 but I created a middleware to use it with L5.
I agree with @S4m4N.
you think application has 10,000 users and 5 employee that they has several permission like:VIP users normal users and in admin panel:super Admin, administrator, staff and etc.
so if all users in one table . you have hard code and low performances
it's better employees and user have different tables. (This is my idea and maybe wrong )
sorry for my note. my english is not good enough.
Is there someone who has a complete guide on doing the multi auth from scratch? I really will appreciate if someone shares a site... I dont want to use the make:auth provided by laravel... I have admins and users tables Loging in and out is really hectic for me... Kindly assist...
It is an old subject but I wanted to point out something for devs who thinks that doesn't make any sense. So when you have single model and table for all members and use single auth control to handle all types of members in your table, it makes impersonation impossible since you can only login as one user. Also if you have implemented some sort of API with Passport then your user table also gets cluttered with api only users. So multi level auth makes sense.