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

Laravel 9.47 is released! Update at a glance~

藏色散人
Release: 2023-01-28 19:51:18
forward
1722 people have browsed it

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',
    ]
]
*/
Copy after login
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();
Copy after login
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();
Copy after login
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!

Related labels:
source:learnku.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template