Laravel 團隊昨天發佈了 v7.5.0,其中包含了框架的一些更新的最新功能、修複和優化: 新的 Http 客戶端斷言 Christoph Rumpel 為 Http 客戶端提供了兩個新的測試方法: Http::assertNotSent(function ($request) { return ...
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)
修複
- 避免超長 URL 破壞郵件佈局 (#32189)
- 修複駝峰轉換關聯名稱 (#32217)
- 修複 Blade 組件中合併 boolean 和 null 屬性的問題 (#32245)
- 修複 Console 預期的斷言順序 (#32258)
- 修複
route
自定義綁定鍵幫助方法 (#32264) - 修複 UriValidator 中的雙斜線匹配 (修複緩存路由和不緩存路由不一致) (#32260)
- 修複郵件發送 header 設置 (#32272)
優化
原文地址:https://laravel-news.com/laravel-7-5-rel...
譯文地址:https://learnku.com/laravel/t/43206
更多學習內容請訪問:
八重櫻:騰訊T3-T4標準精品PHP架構師教程目錄大全,只要你看完保證薪資上升一個臺階(持續更新)