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
directives to accompany
@pushIf and complete a full
set of conditional push directives:
@pushIf($type == 'tailwind', 'css') <link href="https://d1zflb13a857us.cloudfront.net/public/css/tailwind.css" media="all" rel="stylesheet"> @elsePushIf($type == 'boostrap', 'css') <link href="https://d1zflb13a857us.cloudfront.net/public/css/bootstrap.css" media="all" rel="stylesheet"> @elsePush('css') <link href="https://d1zflb13a857us.cloudfront.net/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:
Here's an example using the
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.
- [10.x] Add
@pushElseby @jasonmccreary in https://github.com/laravel/framework/pull/48990
- 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
getGlobalMiddlewaremethod 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
presentbased on other fields by @diamondobama in https://github.com/laravel/framework/pull/48908
- [10.x] Refactor set_error_handler callback to use arrow
InteractsWithDeprecationHandlingby @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
Join the Laravel Newsletter to get all the latest Laravel articles like this directly in your inbox.