Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

kamran186's avatar

Problem in creating 2 entities in Registration

I want to create Login form and I got 2 type of users. Student, Teacher. I have created it by php artisan make:auth But there is only 1 type of user. Please help me what to do and please if you can explain with the help of example...

0 likes
2 replies
xmarks's avatar

You will need to:

  1. Duplicate the Registration Form. They can be similar, except each will POST to a different Route.
  2. You can leave the default Routes to take care of the Teacher, for example. Next you will need 2 additional Route for the Student, like:
Route::get('/student_register', 'Auth\StudentRegistrationController@showRegistrationForm')->name('registerStudent');
Route::post('/student_register', 'Auth\StudentRegistrationController@create')->name('createStudent');

Now on this new Controller, you can basically copy-paste what you have on your RegisterController, except here you will add the data for your Student, not the Teacher.

  • Finally, you will probably need something to differentiate them, so on your users Table, you will need to add a user_type which will be teacher or student, and will be set during the Registration process
1 like
Stratos's avatar

No need to make a new view/controller for each type of user. Just keep it all with the basic auth laravel gives. You differentiate them by adding a user_type field in your users table and setting that upon registration.

You can have a select that asks if theyre either a student or a teacher.

2 likes

Please or to participate in this conversation.