Categories

Thursday, November 21, 2024
#919814419350 therichposts@gmail.com
LaravelPhp

How easy way to call middleware in laravel Route?

Laravel 7.2 routing with route group auth guard check with prefix

easy way to call middleware in laravel Route

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

therichpost
the authortherichpost
Hello to all. Welcome to therichpost.com. Myself Ajay Malhotra and I am freelance full stack developer. I love coding. I know WordPress, Core php, Angularjs, Angular 19, MedusaJs, Next.js, Bootstrap 5, Nodejs, Laravel, Codeigniter, Shopify, Squarespace, jQuery, Google Map Api, Vuejs, Reactjs, Big commerce etc.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.