I’m using Laravel 5.8 and I have a route like this:
Route::get("certs","CertController@index")->name('certificate.front')->middleware('auth');
Now I wanted to add another middleware to this route, so I tried this:
Route::get("certs", "CertController@index")->name('certificate.front')->middleware('prevent-back-history','auth');
Now I don’t get any error and it works But I wonder is this way better or not:
Route::get("certs", "CertController@index")->name('certificate.front')->middleware(['prevent-back-history','auth']);
So which is better and correct in this case?
Note that I don’t want to use Route groups and needed to specify the middleware name directly to the route.