Laravel0Laravel 9.26 Released | Laravel News

[ad_1]

The Laravel team released 9.26 with a Vite asset helper, Closure support to dispatch conditionals, min and max digit validation rules, and more:

Vite asset URL helper

Tim MacDonald contributed a Vite asset URL helper to generate a URL in Blade. Given the following code in your app’s JS entrypoint, Vite will process all images and fonts in these paths:

1import.meta.glob([

2 '../images/**',

3 '../fonts/**',

4]);

Now, using the Vite asset helper method, it will point to your project’s build assets within a blade template:

1<img src="{{ Vite::asset('resources/images/logo.jpeg') }}">

2 

3{{-- <img src="http://asset-url.com/build/assets/logo.1ddf943b.jpeg"> --}}

See Processing Static Assets With Vite in the Vite documentation for further details.

Add Closure support to dispatch conditionals

@Italo contributed the usage of a Closure to dispatch jobs conditionally. The entire job instance is passed to the closure:

1// Dispatches job

2MyQueuableJob::dispatchIf(

3 fn ($job) => true,

4 $name

5);

6 

7// Will not dispatch

8MyQueuableJob::dispatchUnless(

9 fn ($job) => false,

10 $name

11);

Min and max digits validation

Dan Harrin contributed min_digits and max_digits built-in validation rules. These rules require the integer under validation must have a minimum or maximum length of value:

1Validator::validate([

2 'number' => 1000,

3], [

4 'number' => [

5 // Passes as `1000` has 4 digits

6 'min_digits:3', 'max_digits:5',

7 // Fails as `1000` is greater than 5

8 'min:3', 'max:5',

9 ],

10])

Added support for additional “where” methods in route groups

Ollie Read contributed support for all remaining where* methods available on routes to route groups:

1Route::whereIn(['foo', 'bar'], ['one', 'two'])

2 ->prefix('/{foo}/{bar}')

3 ->group(function () {

4 // ...

5 });

Release Notes

You can see the complete list of new features and updates below and the diff between 9.25.0 and 9.26.0 on GitHub.

[ad_2]

Source link

Leave a Reply

Your email address will not be published. Required fields are marked *