Multi Auth for Laravel
Laravel Packagist : https://packagist.org/packages/hesto/multi-auth
What it does?
With one simple command you can setup multi auth for your Laravel project. The package installs:
- Model
- Migration
- Controllers
- Notification
- Routes
- routes/web.php
- {guard}/login
- {guard}/register
- {guard}/logout
- Password Reset Routes
- {guard}/password/reset
- {guard}/password/email
- routes/{guard}.php
- {guard}/home
- routes/web.php
- Middleware
- Views
- Guard
- Provider
- Password Broker
- Settings
Usage
Step 1: Install Through Composer
Run command :
composer require hesto/multi-auth
Step 2: Add the Service Provider (only for laravel lower than 5.5)
You’ll only want to use these package for local development, so you don’t want to update the production providers
array in config/app.php
. Instead, add the provider in app/Providers/AppServiceProvider.php
, like so:
public function register() { if ($this->app->environment() == 'local') { $this->app->register('Hesto\MultiAuth\MultiAuthServiceProvider'); } }
Step 3: Install Multi-Auth files in your project
php artisan multi-auth:install (for example name admin etc) -f // Examples php artisan multi-auth:install admin -f php artisan multi-auth:install employee -f php artisan multi-auth:install customer -f
Notice: If you don’t provide -f
flag, it will not work. It is a protection against accidental activation.
Alternative:
Step 4: Migrate new model table
Make Auth
artisan make:auth
php artisan migrate
Step 5: Try it
Go to: http://project_url/admin/login
Example: http://myproject.dev/customer/login
Options
If you don’t want model and migration use --model
flag.
php artisan multi-auth:install admin -f --model
If you don’t want views use --views
flag.
php artisan multi-auth:install admin -f --views
If you don’t want routes in your routes/web.php
file, use --routes
flag.
php artisan multi-auth:install admin -f --routes
You are logged in as Customer!
Login Page
Employee Login Page