Laravel 10.32 Released
Published on by Paul Redmond
This week, the Laravel team released v10.32, with new conditional push Blade directives, conditional "present" validation rules, and more. Laravel 10 saw 15 individual contributions, including updates, fixes, and improvements. Here is a bit more info about the new features introduced this week:
Add @pushElseIf and @pushElse Blade directives (v10.32.1)
Jason McCreary contributed the @pushElseIf
and @pushElse
Blade directives to accompany @pushIf
and complete a full set of conditional push directives:
@pushIf($type == 'tailwind', 'css') <link href="public/css/tailwind.css" media="all" rel="stylesheet">@elsePushIf($type == 'boostrap', 'css') <link href="public/css/bootstrap.css" media="all" rel="stylesheet">@elsePush('css') <link href="public/css/app.css" media="all" rel="stylesheet">@pushEndIf
See Pull Request #48990 to learn more about the implementation.
Additional "present" validation rules
@diamondobama contributed additional "present" validation rules to validate data based on the presence of other fields. Previously, the present
validation rule would validate that a given field was present in the request.
Now we have the following "present" rules:
-
present_if
-
present_unless
-
present_with
-
present_with_all
Here's an example using the present_if
validation rule:
use Illuminate\Support\Facades\Validator; Validator::validate( ['foo' => 1], ['foo' => 'required', 'bar' => 'present_if:foo,1']); // ValidationException Validator::validate( ['foo' => 1, 'bar' => null], ['foo' => 'required', 'bar' => 'present_if:foo,1']); // [ "foo" => 1, "bar" => null ]
Check out the tests in Pull Request #48908 for examples of each rule.
Release notes
You can see the complete list of new features and updates below and the diff between 10.31.0 and 10.32.1 on GitHub. The following release notes are directly from the changelog:
v10.32.1
- [10.x] Add
@pushElseIf
and@pushElse
by @jasonmccreary in https://github.com/laravel/framework/pull/48990
v10.32.0
- Update PendingRequest.php by @mattkingshott in https://github.com/laravel/framework/pull/48939
- [10.x] Change array_key_exists with null coalescing assignment operator in FilesystemAdapter by @miladev95 in https://github.com/laravel/framework/pull/48943
- [10.x] Use container to resolve email validator class by @orkhanahmadov in https://github.com/laravel/framework/pull/48942
- [10.x] Added
getGlobalMiddleware
method to HTTP Client Factory by @pascalbaljet in https://github.com/laravel/framework/pull/48950 - [10.x] Detect MySQL read-only mode error as a lost connection by @cosmastech in https://github.com/laravel/framework/pull/48937
- [10.x] Adds more implicit validation rules for
present
based on other fields by @diamondobama in https://github.com/laravel/framework/pull/48908 - [10.x] Refactor set_error_handler callback to use arrow function in
InteractsWithDeprecationHandling
by @miladev95 in https://github.com/laravel/framework/pull/48954 - [10.x] Test Improvements by @crynobone in https://github.com/laravel/framework/pull/48962
- Fix issue that prevents BladeCompiler to raise an exception when temporal compiled blade template is not found. by @juanparati in https://github.com/laravel/framework/pull/48957
- [10.x] Fix how nested transaction callbacks are handled by @mateusjatenee in https://github.com/laravel/framework/pull/48859
- [10.x] Fixes Batch Callbacks not triggering if job timeout while in transaction by @crynobone in https://github.com/laravel/framework/pull/48961
- [10.x] expressions in migration computations fail by @tpetry in https://github.com/laravel/framework/pull/48976
- [10.x] Fixes Exception: Cannot traverse an already closed generator when running Arr::first with an empty generator and no callback by @moshe-autoleadstar in https://github.com/laravel/framework/pull/48979
- fixes issue with stderr when there was "]" character. by @nikopeikrishvili in https://github.com/laravel/framework/pull/48975
- [10.x] Fix Postgres cache store failed to put exist cache in transaction by @xdevor in https://github.com/laravel/framework/pull/48968