Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Multiple Guards Laravel Package

shiftechafrica/laravel-multiple-guards

View on GitHub
Deep Wiki
Context7

Introduction

This library helps one to handle multiple guards. Read through to understand how to use it.

Installing

The recommended way to install laravel-multiple-guards is through Composer.

# Install package via composer
composer require shiftechafrica/laravel-multiple-guards

Next, run the Composer command to install the latest stable version of shiftechafrica/laravel-multiple-guards:

# Update package via composer
 composer update shiftechafrica/laravel-multiple-guards --lock

After installing, the package will be auto discovered, But if need you may run:

# run for auto discovery <-- If the package is not detected automatically -->
composer dump-autoload

Then run this, to get the config/laravel-multiple-guards.php for your own configurations:

# run this to get the configuration file at config/laravel-multiple-guards.php <-- read through it -->
php artisan vendor:publish --provider="LaravelMultipleGuards\LaravelMultipleGuardsServiceProvider"

A config/laravel-multiple-guards.php file will be created, follow the example below to define your guards.

# set all the guards to use within the system
SYSTEM_GUARDS=admin,web

Usage

Follow the steps below on how to use the laravel-multiple-guards:

How to use the Library

How to use the guards within your controller...

class HomeController extends Controller
{
    use FindGuard;
    
        /**
         * Create a new controller instance.
         *
         * @return void
         */
        public function __construct()
        {
            $this->middleware($this->setGuardMiddleware()); //@todo this sets the middleware automatically i.e auth, auth:admin that you have defined in the config/auth.php
        }
    
        /**
         * Show the application dashboard.
         *
         * @return Renderable
         */
        public function index()
        {
            return view('home');
        }
    
        /**
         * get authenticated user
         */
        public function getUser()
        {
            return $this->findGuardType()->user();
        }
    
        /**
         * logout user
         * @return RedirectResponse
         */
        public function logout()
        {
            $this->findGuardType()->logout();
            return redirect()->route('login');
        }
}

/**
 * How to get the guard name
 * authorized
*/
 return $this->findGuardType(true); //@todo this returns the guard name i.e web , admin

Version Guidance

Version Status Packagist Namespace Repo
1.x EOL shiftechafrica/laravel-multiple-guards LaravelMultipleGuards v1.1.9
2.x Latest shiftechafrica/laravel-multiple-guards LaravelMultipleGuards v2.0.1

Security Vulnerabilities

For any security vulnerabilities, please email to Support.

License

This package is open-source, licensed under the MIT License.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours