Tutorial by Examples

To define a new middleware we have to create the middleware class: class AuthenticationMiddleware { //this method will execute when the middleware will be triggered public function handle ( $request, Closure $next ) { if ( ! Auth::user() ) { return red...
An example of "before" middleware would be as follows: <?php namespace App\Http\Middleware; use Closure; class BeforeMiddleware { public function handle($request, Closure $next) { // Perform action return $next($request); } } while &quot...
Any middleware registered as routeMiddleware in app/Http/Kernel.php can be assigned to a route. There are a few different ways to assign middleware, but they all do the same. Route::get('/admin', 'AdminController@index')->middleware('auth', 'admin'); Route::get('admin/profile', ['using' => ...

Page 1 of 1