Laravel 10.41 - Conditional Job Chains, a Number::spell() Threshold, Configurable model:prune Path, and More
Last updated on by Paul Redmond
This week, the Laravel team released v10.41 with conditional job chain dispatching, a threshold parameter for Number::spell(), a customizable model path for the model:prune
Artisan command, and more.
Add a until and after threshold to the Number spell helper
Caen De Silva contributed a threshold parameter to the Number helper method, which sets a limit for how high numbers are spelled out:
use Illuminate\Support\Number; Number::spell(8, until: 10); // eightNumber::spell(10, until: 10); // 10Number::spell(20, until: 10); // 20Number::spell(11, after: 10); // elevenNumber::spell(12, after: 10); // twelve
model:prune
command
Specify a model path with the @dbhynds contributed the ability to define custom paths to use with the model:prune
command:
php artisan model:prune --path=$PWD//Some/Absolute/Path/Models
You can pass multiple directories to the --path
option if you have models in various places—here's an example of passing multiple paths using the Artisan
facade:
Artisan::call('model:prune', ['--path' => [ 'app/Models', 'app/Domains' ]]);Artisan::call('model:prune', ['--path' => 'app']);Artisan::call('model:prune', ['--path' => 'vendor/some-random-lib']);
Allow Job Chains to be Conditionally Dispatched
Frankie Jarrett contributed two methods to the PendingChain
class, which enables conditionally dispatching a job chain using the if
and unless
style methods:
// Dispatch the chain unless a condition is falseBus::chain([ new JobA(), new JobB(), new JobC(),])->dispatchIf(true); // Dispatch the chain unless a condition is trueBus::chain([ new JobA(), new JobB(), new JobC(),])->dispatchUnless(false);
Add a base parameter for the Stringable toInteger() method
Piotr Adamczyk contributed an optional $base
argument to the Stringable toInteger()
method, which allows you to specify a base value other than the underlying intval()
's default of 10
:
// Before$stringable = Str::of($hexData)->after('#')->beforeLast("\r");$value = intval($stringable, 16); // After$value = Str::of($hexData)->after('#')->beforeLast("\r")->toInteger(16);
Release notes
You can see the complete list of new features and updates below and the diff between 10.40.0 and 10.41.0 on GitHub. The following release notes are directly from the changelog:
v10.40.1
- [10.x] Add a
threshold
parameter to theNumber::spell
helper by @caendesilva in https://github.com/laravel/framework/pull/49610 - Revert "[10.x] Make ComponentAttributeBag Arrayable" by @luanfreitasdev in https://github.com/laravel/framework/pull/49623
- [10.x] Fix return value and docblock by @dwightwatson in https://github.com/laravel/framework/pull/49627
- [10.x] Add an option to specify the default path to the models directory for
php artisan model:prune
by @dbhynds in https://github.com/laravel/framework/pull/49617 - [10.x] Allow job chains to be conditionally dispatched by @fjarrett in https://github.com/laravel/framework/pull/49624
- [10.x] Add test for existing empty test by @lioneaglesolutions in https://github.com/laravel/framework/pull/49632
- [10.x] Add additional context to Mailable assertion messages by @lioneaglesolutions in https://github.com/laravel/framework/pull/49631
- [10.x] Allow job batches to be conditionally dispatched by @fjarrett in https://github.com/laravel/framework/pull/49639
- [10.x] Revert parameter name change by @timacdonald in https://github.com/laravel/framework/pull/49659
- [10.x] Printing Name of The Method that Calls
ensureIntlExtensionIsInstalled
inNumber
class. by @devajmeireles in https://github.com/laravel/framework/pull/49660 - [10.x] Update pagination tailwind.blade.php by @anasmorahhib in https://github.com/laravel/framework/pull/49665
- [10.x] feat: add base argument to Stringable->toInteger() by @adamczykpiotr in https://github.com/laravel/framework/pull/49670
- [10.x]: Remove unused class ShouldBeUnique when make a job by @Kenini1805 in https://github.com/laravel/framework/pull/49669
- [10.x] Add tests for Eloquent methods by @milwad-dev in https://github.com/laravel/framework/pull/49673
- Implement draft workflow by @driesvints in https://github.com/laravel/framework/pull/49683
- [10.x] Fixing Types, Word and Returns of
Number
class. by @devajmeireles in https://github.com/laravel/framework/pull/49681 - [10.x] Test Improvements by @crynobone in https://github.com/laravel/framework/pull/49679
- [10.x] Officially support floats in trans_choice and Translator::choice by @philbates35 in https://github.com/laravel/framework/pull/49693
- [10.x] Use static function by @michaelnabil230 in https://github.com/laravel/framework/pull/49696
- [10.x] Revert "[10.x] Improve numeric comparison for custom casts" by @driesvints in https://github.com/laravel/framework/pull/49702
- [10.x] Add exit code to queue:clear, and queue:forget commands by @bytestream in https://github.com/laravel/framework/pull/49707
- [10.x] Allow StreamInterface as raw HTTP Client body by @janolivermr in https://github.com/laravel/framework/pull/49705