Using Laravel 5 Auth Middleware

To restrict pages in your app to authentication status, add the middleware to the controller’s constructor.

To restrict a page to guests only (not signed in):

public function __construct()
{
    $this->middleware('guest');
}

For signed in users:

public function __construct()
{
    $this->middleware('auth');
}

If you want to make exceptions for certain methods, just pass those parameters in as an array for the second argument.

$this->middleware('auth', ['except' => 'show']);

 

Leave a Reply

Your email address will not be published. Required fields are marked *