Middleware in Laravel: Main Things to Know
In Laravel, you often need to check things before users reach the Controller. For that, you would use Middleware. Let me explain how it works with examples.
We found 8 results for "middleware".
In Laravel, you often need to check things before users reach the Controller. For that, you would use Middleware. Let me explain how it works with examples.
In Laravel 11, there's a new place where you define/configure your Middleware and Exception classes.
When creating an application, you will need some restrictions for your users. Laravel offers a variety of ways how to implement this. In this tutorial, I will show you four examples.
To set the global Laravel language (locale), you need to use the `app()->setLocale()` method. But the question is: where to put this method if you want to set the locale based on a DB field like `users.language`?
A quick example of refactoring the Controller and Route Groups with Middleware.
Another recently released Laravel feature with more elegant syntax for conditions in queued job middlewares.
Let me demonstrate the usage of a function `redirectUsersTo()` that you can call in the bootstrap/app.php file.
Let me show you a few examples where the Middleware class is not restricting anything but actually setting some variables and just moving on.