I'm using laravel 6 and I want to create an app with two different users. One user is a user registering on the app as an individual while the other user is a user registering on behalf of a company/organization. For an individual user, firstname, lastname, email and password fields are required while for the company/organization, the companyname, email and password are required. I would like to have two registration forms to register the two types of users. I have searched for a similar question but the one I found on this platform wasn't answered. Kindly help.
Asked
Active
Viewed 2,089 times
1
-
You can add another field in users table `role` and add users based on role. – farooq Mar 19 '20 at 11:21
-
You'd have to create two separate registration forms (and potentially two separate controllers) to handle these two user types. Start by looking at what Laravel auth already gives you and then duplicate that and modify as needed. I'm not sure if there is a simple answer here. – Luka Peharda Mar 19 '20 at 14:15
-
@LukaPeharda I tried doing that but the problem was with the user models. There seemed to be a conflict when I had two user models. Is there a way to declare two tables in one user model? – ItsCharlie4real Mar 31 '20 at 16:49
-
1@ItsCharlie4real you should use the same user model. Just add additional attribute on the model (and the DB table) to separate user types. Add `type` attribute/column which can then have value of "individual" or "company". Then when doing separate registration set this `type` as needed. – Luka Peharda Mar 31 '20 at 18:29
-
Thank you @LukaPeharda. That makes a lot of sense. I will definitely try working it out that way. – ItsCharlie4real Apr 02 '20 at 09:00
1 Answers
0
Seems to me that this tutorial could be what you're looking for: https://laravelarticle.com/laravel-multi-authentication
It creates authentication system for two user groups - regular and admin users.

Luka Peharda
- 1,003
- 8
- 18