Skip to content

Instantly share code, notes, and snippets.

@whoisryosuke
Created May 30, 2018 23:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whoisryosuke/902f2ebd3b1e0c232b85b0c6ac255105 to your computer and use it in GitHub Desktop.
Save whoisryosuke/902f2ebd3b1e0c232b85b0c6ac255105 to your computer and use it in GitHub Desktop.
Laravel Middleware - Apply middleware to specific controller methods (two ways!)
<?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