此版本包括計劃任務事件、新的 JSON 斷言方法和所有最新更改。讓我們來看看這個版本中的一些亮點新特性:
首先,在 TestResponse 類中添加了一個 assertJsonPath() 斷言,對于在 JSON 響應中使用針對嵌套屬性的點符號斷言值,這個斷言非常方便:
1
2
3
4
5
6
7
|
$this ->getJson(route( 'api.post.show' , [ $post ->id])) ->assertJsonPath( 'tags' , []) ->assertJsonPath( 'comments.0.user.username' , 'ecrmnn' ) ->assertJsonPath( 'comments.*.body' , [ 'First!' , 'This is my comment' , ]); |
接著,不論生成器類是否有全局/本地的宏,為了便于斷言,向 Eloquent 生成器添加三個新的訪問方法:
1
2
3
|
$builder ->hasMacro( $name ); $builder ->getGlobalMacro( $name ); $builder ->hasGlobalMacro( $name ); |
向 BelongsToMany 關聯添加另一個訪問方法來獲取中間表的列:
1
|
$example ->getPivotColumns(); |
接著,為定時任務準備兩個事件:ScheduledTaskStarting 和 ScheduledTaskFinished 。 你可以在 Michael Dyrynda 的文章 Pull Request #29888 中學習更多這些事件的相關內容。相信你朋友。
此版本中的最后一個新更新是允許使用 inputargument 和 inputoption 對象定義命令參數和選項:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
// 當前樣式,仍受支持 protected function getArguments() { return [ [ 'name' , InputArgument::REQUIRED, 'the argument\'s description' , 'default value' ], ]; } // 新風格 protected function getArguments() { return [ new InputArgument( 'name' , InputArgument::REQUIRED, 'the argument\'s description' , 'default value' ), ]; } |
這個特性以向后兼容的方式工作,只是添加了另一種定義參數和選項的替代方式。
您可以在下面看到修復的完整列表,以及 Github 上 6.0.3 和 6.0.4 之間的全部差異。 Laravel 5.8 的完整發行說明可在 Github v6 changelog 中找到:
Laravel v6.0.4 版本
新增
-
添加了
TestResponse::assertJsonPath()
方法 (#29957) -
向
Eloquent Builder
添加了hasglobalmacro
、getglobalmacro
、hasglobalmacro
方法 (#30008) -
添加了
Illuminate\Database\Eloquent\Relations\BelongsToMany::getPivotColumns()
方法(#30049) -
添加了
ScheduledTaskFinished
ScheduledTaskStarting
計劃任務運行時發出信號的事件 (#29888) -
允許添加帶有
InputArgument
InputOption
對象的命令參數和選項 (#29987)
修復
-
修復了
__()
和null
參數 (#29967) -
修復了在自定義數據透視模型上修改
updated_at
列的問題 (#29970) -
修復了
Illuminate\Redis\Limiters\ConcurrencyLimiter
(#30005) -
修復了
Responsable
接口的響應對象實例時的VerifyCsrfToken
中間件 (#29972) -
修復了
Postgresql
列創建時沒有可選精度的問題 (#29873) - 修復了具有特定文件名的多路徑遷移文件 (#29996)
-
修復了在測試中向
allowed
異常添加NotFoundHttpException
的問題(#29975)
變更
-
使通過
0
/false
禁用加密成為可能 (#29985) -
在
validate dimensions
中允許symfony
文件實例 (#30009) - 使用自定義配置創建存儲模擬數據 (#29999)
-
僅當語言環境有條件地存在時,才在
pendingmail
中設置語言環境 (dd1e0a6) - 改進了從根目錄生成類時按字母順序對導入進行排序 (#29951)
重構
-
在根目錄中將導入更改為
Alpha
排序 (#29954, #29958) - 盡可能使用輔助函數 (#29959)
-
提高了
auth.throttle
翻譯的可讀性 (#30011, #30017)
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持服務器之家。
原文鏈接:https://learnku.com/laravel/t/34895