本篇文章給大家帶來了關于laravel9.47的最新消息,其中主要介紹了laravel 團隊近期發布的9.47版本都有哪些新功能,感興趣的朋友一起來看一下吧,希望對大家有幫助。
Laravel 團隊近期發布了 9.47,其中包含新的 Eloquent 集合可見性方法、「可銷毀的」單例路由、支持帶有 batch fake 的懶加載集合等等:
新的 Eloquent 集合可見性方法
Jess Archer 為 Eloquent 集合貢獻了 setVisible 和 setHidden 方法。 當你想明確要返回的數據時,setVisible 方法很有用,并且它不會在向模型添加新屬性時泄漏:
$users->setVisible(['id', 'name'])->toArray(); /* [ [ 'id' => 1, 'name' => 'Test User', ] ] */
如果你只有幾個要顯式隱藏的字段,但通常希望默認值可見,則相反的 setHidden 很有用。
在 BatchFake 中支持懶加載集合
Jess Archer 在將 withFakeBatch() 與作業一起使用時貢獻了對 LazyCollection 的支持。 由于此功能,現在可以使用以下功能:
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();
?了解更多關于模擬批處理的信息,請點擊Jess Archer.
“可銷毀的”單例路由
Jess Archer?貢獻了一個簡單的方法,將單例路由標記為”可銷毀”。這種類型的路由可以被刪除,但默認不會被創建。
// 以前 Route::singleton(...)->creatable()->except('create', 'store'); // 之后 Route::singleton(...)->destroyable();
發布說明
你可以在github上看到以下完整的新功能和更新列表以及 Jess Archer 之間的差異。下面的發行說明直接來自 Jess Archer:
v9.47.0
新增
- 在 BatchFake::add() 中添加了支持懶加載集合?(Jess Archer)
- 添加小數到數字規則列表(Jess Archer)
- 添加?Illuminate/Routing/PendingSingletonResourceRegistration::destroyable() 可銷毀路由?(Jess Archer)
- 將 setVisible 和 setHidden 添加到 Eloquent 集合 (Jess Archer)
修復
- 修復綁定方法上下文綁定 (Jess Archer)
- 修復方法 explodeExplicitRule 與正則表達式規則 (Jess Archer)
- 修復?Illuminate/database/Query/Builder::whereIntegerInRaw() 方法?(Jess Archer)
- 修復模板標簽(Jess Archer)
修改
- 轉換屬性時返回模型
(Jess Archer) - 始終顯示完整的遷移路徑?Illuminate/Database/console/Migrations/MigrateMakeCommand.php?(Jess Archer)
- 在 mysql 上添加主鍵時刪除索引名稱 (Jess Archer)
推薦學習:《Jess Archer》
原文地址:Jess Archer
譯文地址:Jess Archer
? 版權聲明
文章版權歸作者所有,未經允許請勿轉載。
THE END