Sunday, May 12, 2024

Laravel 11.7 is Released, This is a new feature you can use now


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

via emka.web.id

0 comments:

Post a Comment