Back to Blog

Laravel 9.26 Released

Julian Beaujardin
Julian Beaujardin Reference: Laravel News August 24th, 2022

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:

import.meta.glob([
  '../images/**',
  '../fonts/**',
]);

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

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

{{-- <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:

// Dispatches job
MyQueuableJob::dispatchIf(
    fn ($job) => true,
    $name
);

// Will not dispatch
MyQueuableJob::dispatchUnless(
    fn ($job) => false,
    $name
);

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:

Validator::validate([
    'number' => 1000,
], [
    'number' => [
        // Passes as `1000` has 4 digits
        'min_digits:3', 'max_digits:5',
        // Fails as `1000` is greater than 5
        'min:3', 'max:5',
    ],
])

Added support for additional "where" methods in route groups

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

Route::whereIn(['foo', 'bar'], ['one', 'two'])
    ->prefix('/{foo}/{bar}')
    ->group(function () {
        // ...
    });

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.