Six Essential Laravel Updates to Streamline Your Code

The

ecosystem moves fast, and staying on top of small, ergonomic updates can significantly reduce boilerplate in your daily workflow. The latest releases, 10.39 and 10.40, introduce several helper methods and testing assertions that make the developer experience feel even more polished.

Refined Session Retrieval with Except

Managing user preferences often involves pulling a bulk of data from the

. Previously, if you wanted everything except a few specific keys, you had to manually filter the array. The new except method allows you to provide an array of keys to exclude directly. This is particularly useful when you need to pass a subset of session data to a view or a third-party API without leaking sensitive or irrelevant configuration toggles.

Smarter Testing Assertions

Testing is where

really shines, and two new assertions make your test suite more expressive. First, assertViewEmpty provides a clean way to verify that a view contains no content—perfect for testing conditional UI components or authorization blocks where a guest should see nothing at all. Additionally, when testing queued jobs, you can now use assertCount on the
Laravel Queue
fake. Instead of just checking if a job was pushed, you can verify the exact volume of traffic your application generates, ensuring you aren't accidentally double-dispatching expensive tasks.

Title Casing and Dynamic Job Retries

Strings and Queues also received some love. The string helper now supports

title casing via the apa method. This differs from the standard title method by following specific grammatical rules—like keeping small words lowercase unless they start the string. On the infrastructure side, jobs now support a tries() method. While the public $tries property is still available, the method allows you to dynamically calculate retry attempts based on the configuration or the specific state of the job instance.

Constraining Values with Number Clamp

Perhaps the most versatile addition is the Number::clamp method. It solves the common problem of keeping a value within a specific range. By providing a target number, a minimum, and a maximum,

handles the logic for you. If the number exceeds the max, it returns the max; if it’s below the min, it returns the min. This is a staple in graphics and audio processing that is now natively available for your business logic.

These updates prove that

isn't just about big features; it's about the constant refinement of the tools we use every day. Implementing these helpers will keep your controllers thin and your tests readable.

3 min read