Monday, May 6, 2024
HomePHPLaravel 10.41 - Conditional Job Chains, a Quantity::spell() Threshold, Configurable mannequin:prune Path,...

Laravel 10.41 – Conditional Job Chains, a Quantity::spell() Threshold, Configurable mannequin:prune Path, and Extra


This week, the Laravel group launched v10.41 with conditional job chain dispatching, a threshold parameter for Quantity::spell(), a customizable mannequin path for the mannequin:prune Artisan command, and extra.

Add a till and after threshold to the Quantity spell helper

Caen De Silva contributed a threshold parameter to the Quantity helper technique, which units a restrict for the way excessive numbers are spelled out:

use IlluminateSupportNumber;

 

Quantity::spell(8, till: 10); // eight

Quantity::spell(10, till: 10); // 10

Quantity::spell(20, till: 10); // 20

Quantity::spell(11, after: 10); // eleven

Quantity::spell(12, after: 10); // twelve

Specify a mannequin path with the mannequin:prune command

@dbhynds contributed the power to outline customized paths to make use of with the mannequin:prune command:

php artisan mannequin:prune --path=$PWD//Some/Absolute/Path/Fashions

You may move a number of directories to the --path possibility when you have fashions in numerous locations—this is an instance of passing a number of paths utilizing the Artisan facade:

Artisan::name('mannequin:prune', ['--path' => [ 'app/Models', 'app/Domains' ]]);

Artisan::name('mannequin:prune', ['--path' => 'app']);

Artisan::name('mannequin:prune', ['--path' => 'vendor/some-random-lib']);

Enable Job Chains to be Conditionally Dispatched

Frankie Jarrett contributed two strategies to the PendingChain class, which permits conditionally dispatching a job chain utilizing the if and except type strategies:

// Dispatch the chain except a situation is fake

Bus::chain([

new JobA(),

new JobB(),

new JobC(),

])->dispatchIf(true);

 

// Dispatch the chain except a situation is true

Bus::chain([

new JobA(),

new JobB(),

new JobC(),

])->dispatchUnless(false);

Add a base parameter for the Stringable toInteger() technique

Piotr Adamczyk contributed an non-compulsory $base argument to the Stringable toInteger() technique, which lets you specify a base worth aside from the underlying intval()‘s default of 10:

// Earlier than

$stringable = Str::of($hexData)->after('#')->beforeLast("r");

$worth = intval($stringable, 16);

 

// After

$worth = Str::of($hexData)->after('#')->beforeLast("r")->toInteger(16);

Launch notes

You may see the entire listing of latest options and updates under and the diff between 10.40.0 and 10.41.0 on GitHub. The next launch notes are straight from the changelog:

v10.40.1



RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments