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

baytemizel's avatar

Different authentication with Laravel

Hi,

I wanna make two auth types in login form. When the form will submitted, in a radio button can decide which auth must submitted. I have trouble with different user table in auth. For example a student and a personel login. If the user check the personel button in login form, form will Auth::attempt in users table. But if the user will check the student button it must be check in students table.

The other problem is how can i fix a similar session for a student and a user.

Thanks for your answers.

0 likes
3 replies
Jaytee's avatar

You could use one Table and assign them id's and then there is no need to use a radio box.

Example:

    $table->increments('id');
    $table->string('email');
    $table->string('password');
    $table->integer('group_id'); // Or whatever you prefer to call it.

Then do a query search / add middleware etc, if the user has a id of '1' then they are a Student etc.

baytemizel's avatar

@DPJack & @Mahesh thanks for your posts. I m not wondering users role or two types of users in a table. I have 2 tables and when the user will login with one of them, how can i set user's informations. For example if the user is logged i can see the user information in JSON like this.

{ 'user_type' => 'student', 'name' => '', 'surname' => '', ... .. . }

Please or to participate in this conversation.