In Laravel 5.2
, below are two different kinds of declarations for middlewares
in Groups.
Route::group(['middleware' => 'web'], function () {
});
Route::group(['middleware' => ['web']], function () {
});
I've seen these two different things through Googling. What is the difference between them please?
Thank you.
Route::group(['middleware' => 'web'], function () {
});
This uses only web middleware. If you want to use multiple middlewares, you have to write like this:
Route::group(['middleware' => ['web']], function () {
});
Then you can add another middleware, for example admin middleware:
Route::group(['middleware' => ['web', 'admin']], function () {
});
Anyway, if you want to use only a middleware i think is better write the first.