Created
May 30, 2018 23:57
-
-
Save whoisryosuke/902f2ebd3b1e0c232b85b0c6ac255105 to your computer and use it in GitHub Desktop.
Laravel Middleware - Apply middleware to specific controller methods (two ways!)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function __construct() | |
{ | |
// Apply middleware to only certain routes | |
$this->middleware('auth', ['only' => ['create', 'store', 'edit', 'delete']]); | |
// Or apply middleware to all routes except these | |
$this->middleware('auth', ['except' => ['index', 'show']]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment