paranoid
paranoid

Reputation: 7105

Multiple authentication table in Laravel 5.1

I have two type user. And two table for them.
1. technicians
2. requesters
Is there any way to Multiple authentication in laravel 5.1?
I see and read this post.
Laravel 5.1 multiple authentication
but I am not separate users by group_id in users table.
I want save user and password in each table. technicians user , pass save in technician table and requsters too.
is there any way? by the way each table has special roules

Upvotes: 0

Views: 235

Answers (1)

aceraven777
aceraven777

Reputation: 4556

You can install this package: https://github.com/Kbwebs/MultiAuth

Please read the documentation.

In this package you can create multiple auth. This will override the laravel's auth system.

For example you want to create auth for user and admin.

In the config/auth.php you define the 2 auth:

'multi-auth' => [
    'admin' => [
        'driver' => 'eloquent',
        'model'  => App\Admin::class
    ],
    'user' => [
        'driver' => 'eloquent',
        'model'  => App\User::class
    ]
]

Also your auth syntax will change, please see image below that will show you camparison in syntax, how to login a user and admin versus the Default laravel auth syntax:

enter image description here

Upvotes: 1

Related Questions