This article brings you the latest news about Laravel9.47, which mainly introduces the new features of the 9.47 version recently released by the Laravel team. Friends who are interested should take a look at it. I hope it will be helpful to everyone. help.
The Laravel team recently released 9.47, which includes new Eloquent collection visibility methods, "destructible" singleton routing, and support for lazy loading collections with batch fake Etc.:
New Eloquent collection visibility methods
Jess Archer contributed setVisible
and # to Eloquent collections ##setHidden method. The
setVisible method is useful when you want to be explicit about the data you want to return, and it won't leak when adding new properties to the model:
$users->setVisible(['id', 'name'])->toArray(); /* [ [ 'id' => 1, 'name' => 'Test User', ] ] */
Support for lazy loading of collections in BatchFake
Evan Burrell Contributed when using withFakeBatch() with jobs Added support for
LazyCollection. Thanks to this feature, the following features are now available:
use Batchable; Model::cursor() ->map(fn (Model $model) => new ModelJob($model)) ->chunk(1000) ->each(function (LazyCollection $jobs) { $this->batch->add($jobs); }); // 相关测试 [$job] = (new ModelJobBatch())->withFakeBatch(); $job->handle();
Test Simulator.
" available Destroyed "singleton routing
Choraimy Kroonstuiver contributed a simple method to mark singleton routing as "destructible". Routes of this type can be deleted, but are not created by default.
// 以前 Route::singleton(...)->creatable()->except('create', 'store'); // 之后 Route::singleton(...)->destroyable();
9.46.0 and 9.47.0. The following release notes are taken directly from changelog:
v9.47.0New Added support for lazy loading collections (
#45507)
Destructible routing (
#45549)
Fix with regular expression rules (
#45555)
Method (
#45584 )
(
9f6ff48)
laravel video tutorial"
Original address:https://www.php.cn/link/67163b84d38995c8661d9f8a5b1f8d46
Translation address: https://www.php.cn/link/10af1041993950de8d8775280b66277a
The above is the detailed content of Laravel 9.47 is released! Update at a glance~. For more information, please follow other related articles on the PHP Chinese website!