Laravel 團隊昨天發布了 v7.5.0,其中包含了框架的一些更新的最新功能、修復和優化:
新的 Http 客戶端斷言
Christoph Rumpel 為 Http 客戶端提供了兩個新的測驗方法:
Http::assertNotSent(function ($request) {
return $request->hasHeader('X-First', 'foo') &&
$request->url() == 'http://test.com/users' &&
$request['name'] == 'Taylor' &&
$request['role'] == 'Developer';
});
Http::assertNothingSent();
assertNotSent() 應該回傳一個 boolean 值條件,并帶有你需要匹配請求的約束條件,這些方法補充了現有的 assertSent() 方法,在代碼應導致不發送特定請求或不發送請求的情況下提供相反情況的檢查,
重命名欄位添加列舉支持
根據此功能的 PR “在遷移中,無法在帶有列舉列的表中通過 renameColumn () 或 change () 方法重命名或修改列型別,”
如果我正確理解 PR 的話,你可以在列舉列上面呼叫 change() 方法:
更新: PR 作者澄清了 PR 提供的功能:
更新: PR 作者澄清了 PR 提供的功能:
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->increments('age');
$table->enum('color', ['red', 'blue']);
});
// PR 提交前不支持
Schema::table('users', function (Blueprint $table) {
$table->integer('age')->change();
});
// PR 提交前不支持
Schema::table('users', function (Blueprint $table) {
$table->rename('name', 'username');
});
提醒一下,檔案目前提供以下可修改欄位型別的說明:
只有以下欄位型別支持呼叫 “changed”: bigInteger, binary,boolean, date, dateTime, dateTimeTz, decimal, integer, json, longText, mediumText, smallInteger, string, text, time, unsignedBigInteger, unsignedInteger 和 unsignedSmallInteger,
更多的轉換更新
Brent Roose 在 Castable::castUsing 實作中提供了直接實體化:
class EloquentDataTransferObject extends DataTransferObject implements Castable
{
public static function castUsing()
{
return new DataTransferObjectCaster(static::class);
}
}
在 PR #32225 中了解更多與此相關的功能, Laravel 7.4 版本引入了 Castable 介面,查看最新版本獲取更多詳細資訊, Eloquent 修改器 檔案是另外一個了解自定義轉換的好地方,
發布說明
你可以在下面的 GitHub 鏈接中看到新功能和更新串列以及 7.4.0 和 7.5.0 之間的區別, 完整版的 Laravel 7.x 發行說明已經在最新版本 v7 更新日志 中:
v7.5.0
新增
為 Illuminate\Http\Client\Factory 類新增 assertNotSent() 和 assertNothingSent() 方法 (#32197)
- 增加對
renameColumn()的列舉支持 (#32205) - 支持回傳 caster 實體 (#32225)
修復
- 避免超長 URL 破壞郵件布局 (#32189)
- 修復駝峰轉換關聯名稱 (#32217)
- 修復 Blade 組件中合并 boolean 和 null 屬性的問題 (#32245)
- 修復 Console 預期的斷言順序 (#32258)
- 修復
route自定義系結鍵幫助方法 (#32264) - 修復 UriValidator 中的雙斜線匹配 (修復快取路由和不快取路由不一致) (#32260)
- 修復郵件發送 header 設定 (#32272)
優化
- 優化
Container::resolve()方法 (#32194) - 優化
data_get()方法性能 (#32192) - 優化
Str::startsWith()(#32243)
原文地址:https://laravel-news.com/laravel-7-5-rel...
譯文地址:https://learnku.com/laravel/t/43206
更多學習內容請訪問:
八重櫻:騰訊T3-T4標準精品PHP架構師教程目錄大全,只要你看完保證薪資上升一個臺階(持續更新)?zhuanlan.zhihu.com
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/55100.html
標籤:PHP
