Laravel 9.45 Released
Published on by Paul Redmond
The Laravel team released 9.45 this week with custom component search paths, a new validation rule, router convenience for ULID route params, and more:
Custom component search paths
Taylor Otwell contributed the registration of root-level anonymous component search paths. This is convenient for projects that have components in various locations.
To configure a search path, add the following to the boot()
method within a registered service provider:
Blade::anonymousComponentPath(__DIR__.'/../components');// I.e., `<x-panel />` // With a prefixed namespaceBlade::anonymousComponentPath( __DIR__.'/../components', 'dashboard'); // I.e., `<x-dashboard::panel />`
See theAnonymous Component Paths documentation for further details.
Decimal validation rule
@Pusparaj contributed a decimal
validation rule with a min, max
configuration. Here are a few examples from the pull request tests:
// Passes validation$v = new Validator($trans, ['foo' => '1.234'], ['foo' => 'Decimal:2,3']);$this->assertTrue($v->passes()); // Fails validation$v = new Validator($trans, ['foo' => '1.2345'], ['foo' => 'Decimal:2,3']);$this->assertFalse($v->passes());
Here's how the rule works:
-
decimal:2
is exactly two digits on the fractional part -
decimal:2,3
either two or three digits on the fractional part -
decimal:0,3
values must have at most three digits in the fractional part and can include zero digits (i.e., integer)
"whereUlid()" Route Support
Jamshed Javed contributed whereUlid()
route support to the collection of commonly-used regular expressions. Given you want a route id
param to match a ULID, you'd use the following now:
Route::get('/user/{id}', function ($id) { //})->whereUlid('id');
Release Notes
You can see the complete list of new features and updates below and the diff between 9.44.0 and 9.45.0 on GitHub. The following release notes are directly from the changelog:
v9.45.0
Added
- Allows the registration of custom, root-level anonymous component search paths. (#45338, 1ff0379)
- Added decimal validation rule (#45356, e89b2b0)
- Added align property to button mail component (#45362)
- Added whereUlid(param) support for routing (#45372)
Fixed
- Fixed single line @php statements to not be parsed as php blocks in BladeCompiler (#45333)
- Added missing code to set locale from model preferred locale in Maillable (#45308)