mercredi 7 novembre 2018

How to exclude a route from a middleware in a group of Laravel routes

I have created a middleware to verify a data, according to this data it is redirected to a specific route.

The process works, but when adding the middleware in the group of routes, the redirection becomes an infinite cycle, since when the data is validated it is redirected to a route that is within the group of routes.

My Middleware is verifyData

public function handle($request, Closure $next)
{
    ....
    if ($existsData === null) {
        return redirect()->route('admin.exclude');
    }
    return $next($request);
}

web.php

Route::group(['prefix' => 'admin', 'middleware' => ['auth', 'verifyData'],
    'namespace' => 'Admin', 'as' => 'admin.'], function () {

        Route::resource('users', 'UserController']);


        Route::get('ruteexclude','OneController@method')->name('exclude);

});

How could you ignore a specific route for middleware, or if there is another way to carry out the process?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire