Skip to content

Instantly share code, notes, and snippets.

@matiit
Created October 21, 2014 13:53
Show Gist options
  • Save matiit/3053d64edac883951be9 to your computer and use it in GitHub Desktop.
Save matiit/3053d64edac883951be9 to your computer and use it in GitHub Desktop.
<?php namespace App\Http\Middleware;
use App;
use Closure;
use Illuminate\Contracts\Routing\Middleware;
class MyMiddleware implements Middleware {
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if ($request->get('xxxxxx') == 1) {
App::abort();
}
return $next($request);
}
}
// Bind middleware
// App\Providers\AppServiceProvider
// ...
protected $middleware = [
'auth' = 'App\Http\Middleware\AuthMiddleware',
'auth.basic' => 'App\Http\Middleware\BasicAuthMiddleware',
'csrf' => 'App\Http\Middleware\CsrfMiddleware',
'guest' => 'App\Http\Middleware\GuestMiddleware'
'mymiddleware' => 'App\Http\Middleware\MyMiddleware',
];
// ...
// Controller:
class SomeController Extends Controller {
/**
* @Middleware("auth.basic")
* @Middleware("auth")
*/
public function index() {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment