Thursday, April 13, 2017

Using controller middleware with two guards in Laravel 5.2

Im trying to allow two diferent users to use the same method in a controller, this is my controller, 'admin' and 'user' are my guards

public function __construct(){    
$this->middleware(['admin', 'user'], ['only' => [
            'show',
        ]]);

        $this->middleware('user', ['only' => [
            'index',
            'store',
            'create',
        ]]);
}

The problem is that as an admin I can access to the show method and I cant access to index, store and create methods, Thats correct, but as an user I CANT accees to the show method.



via Saucyloco

Advertisement