π What is Middleware in Laravel?
Middleware acts as a filter between an HTTP request and the application logic.
Flow:
Request β Middleware β Controller β Response
Middleware is commonly used for:
Authentication
Authorization
Logging
Rate limiting
Request modification
πΉ Built-in Middleware Examples
Laravel provides many built-in middleware:
| Middleware | Purpose |
| ---------- | ------------------------ |
| `auth` | Authenticated users only |
| `guest` | Guest users only |
| `verified` | Email verified users |
| `throttle` | Rate limiting |
| `csrf` | CSRF protection |
