Skip to content

Instantly share code, notes, and snippets.

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/eba07bfc894a2625898fcba0510542b9 to your computer and use it in GitHub Desktop.
Save whoisryosuke/eba07bfc894a2625898fcba0510542b9 to your computer and use it in GitHub Desktop.
Laravel - Apply Middleware in the Controller to "only" certain methods, or "except" certain methods.
<?php
public function __construct()
{
// Only apply middleware to these methods
$this->middleware('auth', ['only' => ['create', 'store', 'edit', 'delete']]);
// Or exclude middleware from these methods
$this->middleware('auth', ['except' => ['confirmPage', 'confirmOrder', 'invoice']]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment