Multipule table authentication using laravel 5.1:
1. Install laravel 5.1
2.Open terminal and go to laravel instalation folder.
3.Run the following command.
composer require sarav/laravel-mltiauth dev-master
4.Open config/app.php
Replace Illuminate\Auth\AuthServiceProvider:: class with Sarav\Multiauth\MultiauthServiceProvider
5.Modify auth.php
'multi' => [
'user' => [
'driver' => 'eloquent',
'model' => App\User::class,
'table' => 'users'
],
'admin' => [
'driver' => 'eloquent',
'model' => App\Admin::class,
'table' => 'admins'
]
],
6. Create admins table
7.login using follwing details.
\Auth::attempt("user", ['email' => 'johndoe@gmail.com', 'password' => 'password']);
// Attempts to login admin with email id johndoe@gmail.com
\Auth::attempt("admin", ['email' => 'johndoe@gmail.com', 'password' => 'password']);
1. Install laravel 5.1
2.Open terminal and go to laravel instalation folder.
3.Run the following command.
composer require sarav/laravel-mltiauth dev-master
4.Open config/app.php
Replace Illuminate\Auth\AuthServiceProvider:: class with Sarav\Multiauth\MultiauthServiceProvider
5.Modify auth.php
'multi' => [
'user' => [
'driver' => 'eloquent',
'model' => App\User::class,
'table' => 'users'
],
'admin' => [
'driver' => 'eloquent',
'model' => App\Admin::class,
'table' => 'admins'
]
],
6. Create admins table
7.login using follwing details.
\Auth::attempt("user", ['email' => 'johndoe@gmail.com', 'password' => 'password']);
// Attempts to login admin with email id johndoe@gmail.com
\Auth::attempt("admin", ['email' => 'johndoe@gmail.com', 'password' => 'password']);