New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

sarav/laravel-multiauth

A Simple Laravel Package for handling multiple authentication
31,746 49

Larablocks Analysis

sarav/laravel-multiauth works with any PHP project: the latest release (0.0.7, Dec 24, 2015) doesn't depend on Laravel.

Recommendation checks

Not advised

Not advised: no release or commit in over 2 years.

  • No release or commit in over 2 years
  • No release in the last 12 months (last: Dec 24, 2015)
  • 182 downloads a month (needs 10,000)
  • 49 GitHub stars (needs 100)

State

Likely abandoned
  • No release or commit in over 2 years.
  • Last stable release: Dec 24, 2015.
  • No releases in the last 12 months.
  • First released: Nov 13, 2015.
  • Monthly downloads: 182, up 104% from six months ago.
  • 1 open issue on GitHub.

Data from Packagist and GitHub, checked by Larablocks on Dec 2, 2026.

Install
composer require sarav/laravel-multiauth
Latest Version:0.0.7
PHP:>=5.5.9
License:MIT
Last Updated:Aug 5, 2017
Links: GitHub  ·  Packagist
Maintainer: Sarav

Laravel-Multiauth

Latest Stable Version Total Downloads Latest Unstable Version License

A Simple Laravel Package for handling multiple authentication

Check working sample code of this project here

##Step 1 : Require Composer package##

Open your terminal and navigate to your laravel folder. Now run the following command

composer require sarav/laravel-multiauth

or

"require": {
    "sarav/laravel-multiauth": "^0.0.7"
}

##Step 2 : Replacing default auth service provider##

Replace  "Illuminate\Auth\AuthServiceProvider::class" with "Sarav\Multiauth\MultiauthServiceProvider::class"

##Step 3 : Modify auth.php##

Modify auth.php file from the config directory to something like this

'multi' => [
    'user' => [
        'driver' => 'eloquent',
        'model'  => App\User::class,
        'table'  => 'users'
    ],
    'admin' => [
        'driver' => 'eloquent',
        'model'  => App\Admin::class,
        'table'  => 'admins'
    ]
 ],

Note : I have set second user as admin here. Feel free to change yours but don't forget to add its respective driver, model and table.

We are done! Now you can simply login user/admin like the following code

\Auth::loginUsingId("user", 1); // Login user with id 1

\Auth::loginUsingId("admin", 1); // Login user 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']); 

Simply pass the first parameter as key which you have configured in auth.php to perform authentication for either user or admin.

##Improved Guard Class##

Now you can pass Guard class easily through nice "with" function.

$auth = $auth->with('admin');

For more information check out this article.

Alternatives to sarav/laravel-multiauth

hasinhayder/tyro-login

Complete authentication kit for Laravel 12 & 13 — 10 premium layouts, social OAu...

15,836 252
nyoncode/wire-module-auth

The signed-out screens for wire: login, password reset, email verification and t...

2,675 0
brackets/admin-auth

Authentication interface for brackets/admin-ui

265,701 7
sven/super-basic-auth

A lightweight package to add basic authentication to your Laravel app.

4,342 23

Version History

Version Released PHP License
0.0.7 >=5.5.9 MIT
0.0.6 >=5.5.9 MIT
0.0.5 >=5.5.9 MIT
0.0.4 >=5.5.9 MIT
0.0.3 >=5.5.9 MIT