Today, the Laravel group launched v10.19 with a collection portion approach, customized occasion exploration course resolution, vibrant line up audience hold-up, as well as a lot more:
Word cover string approach
Josh Bonnick added a wordWrap
approach to the Laravel String API, which divides strings within a string utilizing a personality limitation. This approach is a wrapper for PHP’s wordwrap feature:
usage IlluminateSupportStr;
$ message = " A long woooooooooooord."
// Str
Str:: wordWrap( string: $message, personalities: 8);
/ *
A really
long
wooooooo
ooooord.
*/
// Stringable
str($ message)->> wordWrap( string: $message, personalities: 8);
Include portion approach to collections
Wendell Adriel added a portion()
approach to collections that permits you to determine a percent based upon customized reasoning utilizing a fact
examination:
$ collection = brand-new $collection([
['name' => 'Taylor', 'foo' => 'foo'],
['name' => 'Nuno', 'foo' => 'bar'],
['name' => 'Dries', 'foo' => 'bar'],
['name' => 'Jess', 'foo' => 'baz'],
];
$ collection->> portion( fn ($ worth) => > $worth['foo'] == = ' foo'); // 25.00
$ collection->> portion( fn ($ worth) => > $worth['foo'] == = ' bar'); // 50.00
$ collection->> portion( fn ($ worth) => > $worth['foo'] == = ' baz'); // 25.00
$ collection->> portion( fn ($ worth) => > $worth['foo'] == = ' examination'); // 0.00
Capability to personalize course resolution in Occasion exploration
@bastien- phi added the capacity to personalize course resolution for Occasion exploration:
This public relations includes the capacity to personalize the method the translation is done as well as opens occasion exploration in such DDD frameworks.
Below’s an instance of a customized callback in Pull Demand # 48031‘s examinations, which shows exactly how this can be utilized:
usage IlluminateFoundationEventsDiscoverEvents;
DiscoverEvents:: guessClassNamesUsing( feature ( SplFileInfo $documents, $basePath) {
return Str:: of($ documents->> getRealPath())
->> after($ basePath DIRECTORY_SEPARATOR)
->> prior to('. php')
->> change( DIRECTORY_SEPARATOR, ' ')
->> ucfirst()
->> prepend(' Light Up ')
->> toString();
} );
Specify audience hold-up dynamically
@CalebW added assistance for audiences to specify a withDelay()
approach that can establish line up audience hold-up:
course Audience executes ShouldQueue
{
public feature __ conjure up( Occasion $occasion): gap
{
// ...
}
public feature withDelay( Occasion $occasion): int
{
return $occasion->> fooBar
? <: <
; } } Include vibrant return kinds to the rescue assistant Choraimy Kroonstuiver
added a PHPDoc upgrade to aid fixed evaluation devices recognize the common return kinds of the
rescue()
assistant. There are no code instances to see right here, yet the upgraded Docblock looks as succeeds this upgrade:
/ ** * Capture a possible exemption as well as return a default worth. *
* @template TRescueValue
* @template TRescueFallback
*
*
@param
callable
():
TRescueValue $ callback * @ param ( callable
( Throwable): TRescueFallback)| TRescueFallback $ rescue * @ param bool|
callable $ record * @ return TRescueValue|
TRescueFallback */ feature rescue(
callable
$callback, $rescue = void, $record = real ) {// ... }
// Instances:
assertType
(
' int|null'
,
rescue( fn () => > 123)); assertType(' int',
rescue( fn () => > 123, 345)); assertType(' int',
rescue( fn () => > 123, fn () => > 345)); You can discover more regarding Generics By Instances on the PHPStan blog site. Include matter debate to createMany as well as createManyQuietly
Jordan Welch added the capacity to pass an integer to createMany()
as well as
createManyQuietly() on version manufacturing facilities to produce that variety of designs: // Prior To:
$ individuals =
Customer
::
manufacturing facility() ->> createMany(, , ]; [[]// After: []$ individuals [] =
Customer
::
manufacturing facility() ->> createMany( 3); $ this->> assertCount
(
3, $individuals);$ this->> assertInstanceOf(
EloquentCollection:: course, $individuals); Launch notes You can see the full listing of brand-new attributes as well as updates listed below as well as the diff in between 10.18.0 as well as 10.19.0 on GitHub. The complying with launch notes are straight from the
changelog
: v10.19.0 Repair typo in upgrade HasUniqueIds by
@iamcarlos94
- [10.x] in https://github.com/laravel/framework/pull/47994
With dignity manage clinical symbols by
@timacdonald in https://github.com/laravel/framework/pull/48002 Repair docblocks for throw_if as well as throw_unless by - [10.x] @AbdelElrafa in https://github.com/laravel/framework/pull/48003 Include
- [10.x] wordWrap to Str
- [10.x] by
@joshbonnick
in https://github.com/laravel/framework/pull/48012Repair RetryBatchCommand overlapping of fallen short tasks when run simultaneously with the very same Set ID utilizing isolatableId by
@rybakihor in https://github.com/laravel/framework/pull/48000 Repair - [10.x] assertRedirectToRoute when path uri is vacant by @khernik93
- [10.x] in https://github.com/laravel/framework/pull/48023
Repair vacant table showed when utilizing the-- pending alternative yet there are no pending movements by
@TheBlckbird in https://github.com/laravel/framework/pull/48019 Repair required use create DB link by - [10.x] @oleksiikhr in https://github.com/laravel/framework/pull/48015 Usage version cast when contractor developed upgraded at worth by
- [10.x] @timacdonald in https://github.com/laravel/framework/pull/47942 Repair Collection:: search as well as LazyCollection:: search return kind by
- [10.x] @bastien- phi in https://github.com/laravel/framework/pull/48030 Include capacity to personalize course resolution in occasion exploration by
- [10.x] @bastien- phi in https://github.com/laravel/framework/pull/48031 Include
- [10.x] portion approach to Collections by @WendellAdriel
- [10.x] in https://github.com/laravel/framework/pull/48034
Repair analyzing mistake in console when criterion summary includes
— by @rxrw - [10.x] in https://github.com/laravel/framework/pull/48021
Enable Audiences to dynamically define hold-up utilizing
withDelay by @CalebDW - [10.x] in https://github.com/laravel/framework/pull/48026
Include vibrant return kinds to rescue assistant by
@axlon in https://github.com/laravel/framework/pull/48062 createMany & & createManyQuietly include matter debate by - [10.x] @JHWelch in https://github.com/laravel/framework/pull/48048 Connects assistance on default element port by
- [10.x] @royduin in https://github.com/laravel/framework/pull/48039 Include WithoutRelations connect for version serialization by
- [10.x] @Neol3108 in https://github.com/laravel/framework/pull/47989 Can use WithoutRelations to whole course by
- [10.x] @cosmastech in https://github.com/laravel/framework/pull/48068 createMany & & createManyQuietly make debate optional by
- [10.x] @JHWelch in https://github.com/laravel/framework/pull/48070