Middleware not working in Laravel 5

I am using laravel 5. I have created a new middleware called permission

public function handle($request, Closure $next)

    $user = Auth::user();
    $route = $request->route();

    $actions = $route->getAction();

    $user = Auth::user();

    if (array_key_exists('permission', $actions)) {
        $permission = $actions['permission'];

        if (!$user->can($permission)) {
            return redirect()->guest(route('auth.login'));

    return $next($request);

This is the middleware code. I have added
'permission' => 'AppHttpMiddlewarePermissions', in routeMiddleware array of Kernal.php.

But this is not working when I try to do:

Route::group(['middleware' => ['permissioin']], function()
    Route::get('organisations', [
        'as' => 'organisation', 'uses' => 'OrganisationsController@index'

Source: laravel

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.