deb44
321
3
Laravel

Laravel 5.1 - Middleware to route

Posted 4 years ago by deb44

Hy all!

I have tried to assign middleware to specific route(s). I failed. :(

So...

The doc: http://laravel.com/docs/5.1/middleware#registering-middleware

Laravel version: 5.1.4

Middleware name: AuthMiddleware

app/Http/Kernel.php:

protected $routeMiddleware = [
...
'authm' => \App\Http\Middleware\AuthMiddleware::class,

];

The route (routes.php):

Route::get('/', 'MainController@index', ['middleware' => 'authm']);

If i put the middleware to $middleware (global middlewares), then it works. Only route specific middleware can't.. :(

Please help me! Thank you. :)

Please sign in or create an account to participate in this conversation.