Mainly Middleware used for Authentication. For Creating and registering the Middleware please follow this link.
Let's suppose there is a third party API that needs access to our system. Then we can create a Middleware for it. So in the handle function of the Middleware we can have our own logic to authenticate.
So our Route will look something like this:
Route::group(['middleware' => ['web']], function () {
Route::group(['middleware' => ['thirdPartyAPI']], function () {
//Routes
});
});
Here "web" Middleware is the wrapper of the "thirdPartyAPI" Middleware. So Routes will be filtered by Web and then by thirdPartyAPI.
Another common scenario is when we have Admin, Super Admin access in our system. So for this we can create a Middlewares for these as well. Have our own logic in Handle function.
So our Route will look something like this:
Route::group(['middleware' => ['web']], function () {
Route::group(['middleware' => ['auth']], function () {
Route::group(['middleware' => ['admin']], function () {
//Routes
});
});
});
Here "auth" Middleware is for Session authentication. Admins have some special abilities in our system. So those abilities will go here.
Let's suppose there is a third party API that needs access to our system. Then we can create a Middleware for it. So in the handle function of the Middleware we can have our own logic to authenticate.
So our Route will look something like this:
Route::group(['middleware' => ['web']], function () {
Route::group(['middleware' => ['thirdPartyAPI']], function () {
//Routes
});
});
Here "web" Middleware is the wrapper of the "thirdPartyAPI" Middleware. So Routes will be filtered by Web and then by thirdPartyAPI.
Another common scenario is when we have Admin, Super Admin access in our system. So for this we can create a Middlewares for these as well. Have our own logic in Handle function.
So our Route will look something like this:
Route::group(['middleware' => ['web']], function () {
Route::group(['middleware' => ['auth']], function () {
Route::group(['middleware' => ['admin']], function () {
//Routes
});
});
});
Here "auth" Middleware is for Session authentication. Admins have some special abilities in our system. So those abilities will go here.
No comments:
Post a Comment