Home >PHP Framework >Laravel >Laravel 9.47 is released! Update at a glance~

Laravel 9.47 is released! Update at a glance~

藏色散人
藏色散人forward
2023-01-28 16:40:341718browse

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.

Laravel 9.47 is released! Update at a glance~

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',
    ]
]
*/
If you only have a few to explicitly hide field, but usually want the default value to be visible, the opposite setHidden is useful.

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();
To learn more about simulating batches, click

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();
Release Notes

You can see the full list of new features and updates below on GitHub as well as the differences between

9.46.0 and 9.47.0. The following release notes are taken directly from changelog:

v9.47.0

New

    in
  • BatchFake::add() Added support for lazy loading collections (#45507)
  • Add decimals to the number rule list (
  • #45533)
  • Add
  • Illuminate/Routing/PendingSingletonResourceRegistration::destroyable() Destructible routing (#45549)
  • Add setVisible and setHidden to the Eloquent collection (
  • #45558)
Fix

    Fix binding method context binding (
  • #45500)
  • Fix method
  • explodeExplicitRule Fix with regular expression rules (#45555)
  • Illuminate/Database/Query/Builder::whereIntegerInRaw() Method (#45584 )
  • Fix template tag (
  • #45490)
Modify

    Return model when converting attributes
  • (
    #45539)
  • Always display the complete migration path
  • Illuminate/Database/Console/Migrations/MigrateMakeCommand.php (9f6ff48)
  • Delete the index name when adding a primary key on MySQL (
  • #45515)
Recommended learning: "
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!

Statement:
This article is reproduced at:learnku.com. If there is any infringement, please contact admin@php.cn delete