Level 32
Route::get('/', [
'middleware' => 'authm',
'uses' => 'MainController@index'
]);
You can always check the registered middlewares with php artisan route:list
10x @Codenator81
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
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 or to participate in this conversation.