Hello to all, welcome to therichpost.com. In this post, I will tell you, How easy way to call middleware in laravel Route? Laravel is one of the top php mvc framework.
Middleware in laravel use between request and response. Laravel Routes is of the best thing in laravel framework.
Here are the ways to call middleware in laravel Route into your routes/web.php file:
//First Method Route::post('/testpage', 'TestController@TestFunction')->middleware('ajax'); //Second if you have many routes in one Middleware Route::middleware('ajax')->group(function () { Route::post('/testpage', 'TestController@TestFunction'); Route::post('/testpage2', 'TestController@TestFunction2'); Route::post('/testpage3', 'TestController@TestFunction3'); }); //Third if you have Multiple Middleware in one Route Route::group(['middleware' => ['auth', 'web']], function() { Route::post('/testpage', 'TestController@TestFunction'); }); Route::get('/', function () { // })->middleware('auth', 'web');
There are so many code tricks in laravel and i will let you know all. Please do comment if you any query related to this post. Thank you. Therichpost.com
Recent Comments