文章轉發自專業的Laravel開發者社區,原始連接: https://learnku.com/laravel/t...
Laravel 團隊宣佈 Laravel v6.0.4 即將發佈。 此版本包括計劃任務事件、新的 JSON 斷言方法和全部最新更改。laravel
讓咱們來看看這個版本中的一些亮點新特性:git
首先,在 TestResponse 類中添加了一個 assertJsonPath()
斷言,對於在 JSON 響應中使用針對嵌套屬性的點符號斷言值,這個斷言很是方便:github
$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
生成器添加三個新的訪問方法:sql
$builder->hasMacro($name); $builder->getGlobalMacro($name); $builder->hasGlobalMacro($name);
向 BelongsToMany
關聯添加另外一個訪問方法來獲取中間表的列:api
$example->getPivotColumns();
接着,爲定時任務準備兩個事件:ScheduledTaskStarting
和 ScheduledTaskFinished
。 你能夠在 Michael Dyrynda 的文章 Pull Request #29888 中學習更多這些事件的相關內容。相信你朋友。函數
此版本中的最後一個新更新是容許使用 inputargument
和 inputoption
對象定義命令參數和選項:post
// 當前樣式,仍受支持 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 中找到:測試
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)allowed
異常添加 NotFoundHttpException
的問題(#29975)0
/false
禁用加密成爲可能 (#29985)validate dimensions
中容許 symfony
文件實例 (#30009)pendingmail
中設置語言環境 (dd1e0a6)