Laravel continues its tradition of empowering developers with the release of version 11.7. This iteration introduces an array of exciting updates, including a refined validation method, enhanced MySQL JSON support, a new password reset event, and seamless Slack integration via Socialite. Let's delve deeper into these remarkable additions.
Simplified Validation with Rule::array()
Jakub Potocký introduces the Rule::array() method, simplifying the validation of multiple array keys using array validation rules. This method eliminates the need for cumbersome dynamic value concatenation, providing a cleaner and more intuitive approach:
use Illuminate\Validation\Rule;
// Previous approach
['array:' . MyBackedEnum::VALUE->value . ',' . MyBackedEnum::VALUE_2->value];
// Using Rule::array()
Rule::array('key_1', 'key_2', 'key_3');
Rule::array(['key_1', 'key_2', 'key_3']);
Rule::array(collect(['key_1', 'key_2', 'key_3']));
Rule::array([UnitEnum::key_1, UnitEnum::key_2, UnitEnum::key_3]);
Rule::array([BackedEnum::key_1, BackedEnum::key_2, BackedEnum::key_3]);
This elegant solution streamlines array validation, making your code more concise and readable.
Expanded Stringable Support in blank() and filled() Helpers
Stefan R. enhances the blank() and filled() helper functions by adding support for Stringable values. This simplifies the process of checking for empty or filled values in Stringable objects:
// true
filled(str('FooBar '));
// true
blank(str(' '));
This addition further strengthens Laravel's commitment to intuitive and versatile code.
MySQL's whereJsonOverlaps() Method: Seamless JSON Comparison
Leveraging MySQL's new json_overlaps feature, Laravel 11.7 introduces the whereJsonOverlaps() method. This powerful addition simplifies the comparison of JSON documents within your database queries:
User::whereJsonOverlaps('languages', ['en', 'fr'])->exists();
User::whereJsonDoesntOverlap('languages', ['en', 'fr'])->exists();
This streamlined approach to JSON comparison enhances efficiency and readability in your code.
Enhanced Control with the PasswordResetLinkSent Event
Matt Jones introduces a new event called PasswordResetLinkSent. This event triggers when a password reset link is dispatched, granting developers greater control and flexibility in managing the password reset process. This enables custom actions to be taken immediately after a reset link is sent, further enhancing the user experience.
Streamlined Slack Authentication with Socialite's OpenID Provider
Maarten Paauw introduces a dedicated Slack OpenID provider for Laravel Socialite. This addition simplifies the integration of Slack authentication within your applications, offering a seamless and secure way to authenticate users through their Slack credentials. This streamlines the user onboarding process and leverages the familiarity of existing platforms.
Laravel 11.7's updates extend beyond these highlighted features. The complete release notes detail an extensive list of bug fixes, performance enhancements, and new additions, further solidifying Laravel's position as a powerful and developer-friendly framework.
These enhancements demonstrate Laravel's dedication to continuous improvement and its focus on providing developers with the tools they need to build sophisticated and efficient web applications. With its focus on clarity, efficiency, and integration with popular platforms, Laravel 11.7 empowers developers to create exceptional web experiences.
Laravel v11.7 change log:
v11.7.0
- [11.x] Fix SesV2Transport to use correct
EmailTags
argument by @Tietew in https://github.com/laravel/framework/pull/51265 - [11.x] Add Databases nightly workflow by @Jubeki in https://github.com/laravel/framework/pull/51218
- [11.x] update "min" and "max" rule comments by @browner12 in https://github.com/laravel/framework/pull/51274
- [11.x] Fix namespace and improvement PSR in
ClassMakeCommandTest.php
by @saMahmoudzadeh in https://github.com/laravel/framework/pull/51280 - [11.x] improvement test coverage for view components. by @saMahmoudzadeh in https://github.com/laravel/framework/pull/51271
- [11.x] Introduce method
Rule::array()
by @Jacobs63 in https://github.com/laravel/framework/pull/51250 - [11.x] Fix docblock for collection pluck methods by @SanderMuller in https://github.com/laravel/framework/pull/51295
- [11.x] Add tests for handling non-baked enum and empty string requests by @hrant1020 in https://github.com/laravel/framework/pull/51289
- blank and filled now support stringable by @lava83 in https://github.com/laravel/framework/pull/51300
- [11.x] Fix ratio validation for high ratio images by @ahmedbally in https://github.com/laravel/framework/pull/51296
- [11.x] Add int|float support to e method by @trippo in https://github.com/laravel/framework/pull/51314
- [11.x] Add release notes by @driesvints in https://github.com/laravel/framework/pull/51310
- [11.x]
Stringable
is also an interface of symfony by @lava83 in https://github.com/laravel/framework/pull/51309 - [11.x] Add some tests and improvement test coverage for
Str::camel
by @saMahmoudzadeh in https://github.com/laravel/framework/pull/51308 - [11.x] Using the
??
Operator (Null Coalescing Operator) by @saMahmoudzadeh in https://github.com/laravel/framework/pull/51305 - [11.x] Add ability to override the default loading cached Routes for application by @ahmedabdel3al in https://github.com/laravel/framework/pull/51292
- [11.x] Add ->whereJsonOverlaps() for mysql by @parkourben99 in https://github.com/laravel/framework/pull/51288
- [11.x] Add
InteractsWithInput
methods toValidatedInput
by @aydinfatih in https://github.com/laravel/framework/pull/51316 - [11.x] Adding PasswordResetLinkSent event by @Muffinman in https://github.com/laravel/framework/pull/51253
via emka.web.id
0 comments:
Post a Comment