Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function register(){
- Auth::extend('adminEloquent', function($app){
- // you can use Config::get() to retrieve the model class name from config file
- $myProvider = new EloquentUserProvider($app['hash'], 'AppAdminModel')
- return new Guard($myProvider, $app['session.store']);
- })
- $app->singleton('auth.driver_admin', function($app){
- return Auth::driver('adminEloquent');
- });
- }
- class AdminAuth extends Facade {
- protected static function getFacadeAccessor() { return 'auth.driver_admin'; }
- }
- 'aliases' => [
- //has to be beneath the 'Auth' alias
- 'AdminAuth' => 'AppFacadesAdminAuth'
- ]
- composer require sarav/laravel-multiauth dev-master
- IlluminateAuthAuthServiceProvider::class
- SaravMultiauthMultiauthServiceProvider
- 'multi' => [
- 'user' => [
- 'driver' => 'eloquent',
- 'model' => AppUser::class,
- 'table' => 'users'
- ],
- 'admin' => [
- 'driver' => 'eloquent',
- 'model' => AppAdmin::class,
- 'table' => 'admins'
- ]
- ],
- Auth::loginUsingId("user", 1); // Login user with id 1
- Auth::loginUsingId("admin", 1); // Login admin with id 1
- // Attempts to login user with email id johndoe@gmail.com
- 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']);
Add Comment
Please, Sign In to add comment