What is middleware ?

What is middleware ?

Friends, middleware is a very useful thing in Laravel. We can put a restriction on which user can access which of our pages and if that user is unable to fulfill that criteria, then we can direct him to some other page. This work is done by middleware.

For example, if a user is not logged in and he wants to access any of our pages which can only be accessed by the logged in user because we have placed some codes on that page so that it can get the details of the user who logged in and the user has not logged in so it will not be able to locate his details and hence will not allow the user to visit in there and redirect them to login page.

The second example is that you must have noticed that to access many pages, we need a middleware. For example, suppose I talk about 18 plus content, there is a mandatory requirement that you should be 18 years old only then you can access that page. So, the work of applying all these restrictions is done by middleware.

Friends, Middle Bear is a very big topic. I will not be able to explain it in this introduction video because you will not understand it. For this, I will first explain to you the controller, model and view. Only then you will be able to understand Middle Bear in detail. And if you understand it.

 

 

Leave a Reply