Refined Enum Queries in Eloquent Laravel has long supported PHP enums for casting, but a significant friction point remained when querying databases. Previously, while you could cast a model attribute to an enum, passing that same enum directly into a `where` clause often led to unexpected failures. The framework now handles this natively. You can pass a backed enum case directly into Eloquent query methods, and it correctly resolves the underlying value. This eliminates the need for manual `->value` calls, making your repository and service layers significantly cleaner. Automatic Password Re-hashing Security standards change, and Laravel 11 now makes it easier to keep up without forcing a mass password reset. The framework has updated its default BCrypt work factor from 10 rounds to 12, matching PHP 8.4 standards. The real magic happens during authentication: if a user logs in and the framework detects their stored hash uses an outdated work factor, it automatically re-hashes the password using the new configuration. This ensures your user data stays secure against modern brute-force hardware without any manual migration scripts. Capturing Metadata with Context Modern applications involve complex request lifecycles—controllers, jobs, and listeners often need access to the same metadata. The new Context facade provides a centralized way to store information that persists across the entire request. By adding a simple middleware, you can inject data like request IDs, current URLs, or authenticated user IDs into the global context. This data is automatically appended to log messages, providing an incredible audit trail for debugging without cluttering your code with repetitive log context arrays. Beyond Logging: Hidden Context The Context feature isn't just for logs. Developers can store hidden data that doesn't appear in logs but remains accessible throughout the execution thread. This is perfect for passing tenant IDs in multi-tenant apps or tracking internal execution flags. By centralizing this metadata, you reduce the need for passing variables through deep call stacks, keeping your method signatures focused on their primary logic.
Context
Products
Mar 2024 • 1 videos
High activity month for Context. Laravel among the most active voices, with 1 videos across 1 sources.
Mar 2024
- Mar 28, 2024