Integrate plugin middleware

Since s-cart/core 6.4.1, middleware group of "front, admin" defined in "vendor/s-cart/core/Config/middleware.php"

return [
    'admin' => [
        1 => 'admin.auth',
        2 => 'admin.permission',
        3 => 'admin.log',
        4 => 'admin.storeId',
        5 => 'admin.theme',
        6 => 'localization',
    ],
    'front' => [
        1 => 'localization',
        2 => 'currency',
        3 => 'checkdomain',
    ],
];

Therefore, the middleware in the plugin can be easily integrated into the "front, admin" middleware, by adding a new middleware value in the corresponding group.
The following example will automatically add middleware to the "front" group:
In the plugin's Provider.php file:

        app('router')->aliasMiddleware('password_website', \App\Plugins\Other\PasswordWebsite\Middleware::class); // define a new middleware
        //Add new middleware to group "front"
        $configDefault = config('middleware.front');
        $configDefault[] = 'password_website';
        config(['middleware.front' => $configDefault]);


Related topics

Latest Document