Laravel 11.11版本發(fā)布 - 查看模型中的第三方關(guān)系:show
Laravel  /  管理員 發(fā)布于 9個月前   535
本周,Laravel團隊發(fā)布了v11.11,支持模型中的第三方關(guān)系:show命令、新的Collection方法、
新的緩存事件等等。
采集前后方法
Ryuta Hamasaki為Collection和LazyCollection實例貢獻了before和after方法
以下是pull請求描述中before方法的示例:
$collection = collect([1, 2, 3, 4, 5, 'name' => 'taylor', 'framework' => 'laravel']);
$collection->before(2) // 1
$collection->before('taylor') // 5
$collection->before('laravel') // 'taylor'
$collection->before(fn ($value) => $value > 4) // 4
$collection->before(fn ($value) => ! is_numeric($value)) // 5
$collection->before(1) // null
$collection->before('not found') // null
以下是pull請求描述中after方法的示例:
$collection = collect([1, 2, 3, 4, 5, 'name' => 'taylor', 'framework' => 'laravel']);
$collection->after(1) // 2
$collection->after('taylor') // 'laravel'
$collection->after(fn ($value) => $value > 4) // 'taylor'
$collection->after(fn ($value) => ! is_numeric($value)) // 'laravel'
$collection->after('laravel') // null
$collection->after('not found') // null
緩存事件
Alex Bouma為應用程序可以監(jiān)聽的框架貢獻了新的緩存事件:
use Illuminate\Cache\Events\ForgettingKey;
use Illuminate\Cache\Events\KeyForgetFailed;
use Illuminate\Cache\Events\KeyWriteFailed;
// Two public properties: `$this->value` and `$this->seconds`
use Illuminate\Cache\Events\RetrievingKey;
use Illuminate\Cache\Events\RetrievingManyKeys;
// One public property: `$this->keys`
use Illuminate\Cache\Events\WritingKey
// Two public properties: `$this->value` and `$this->seconds`
use Illuminate\Cache\Events\WritingManyKeys;
// Three public properties:
// `$this->keys`, `$this->values` and `$this->seconds`
支持模型中的第三方關(guān)系:show
Jonas Staudenmeir貢獻了將第三方包模型關(guān)系包括在模型中的能力:show命令:
model:show命令通過分析模型方法的代碼并查找$this->hasMany(等)來查找模型的關(guān)系。
這不會檢測到第三方關(guān)系(就像雄辯的hasMany-depth一樣)。
我們可以構(gòu)建一個完整的系統(tǒng)來連接包,但這太過分了,IMO。
相反,我們可以檢查方法的返回類型,看看它是否是基類Relation的子類。
不是每個人都使用返回類型,但我希望現(xiàn)在大多數(shù)人都這樣做。
您可以在拉取請求#51807中了解更多關(guān)于此添加的信息。
會話ID獲取器
Tim MacDonald為Session facade貢獻了Session::id()方法:
Session::id();
// You can still use `getId()` too:
Session::getId();
時區(qū)和區(qū)域設置添加到about命令
Amir Khalife Soltani為Laravel的about命令添加Locale和Timezone值做出了貢獻。
現(xiàn)在,您可以通過其他重要的環(huán)境信息快速確定配置的區(qū)域設置和時區(qū):
具有“時區(qū)”和“區(qū)域設置”值的“about”命令
422不可處理的內(nèi)容狀態(tài)代碼
Dwight Watson對用于確定422狀態(tài)代碼的狀態(tài)代碼方法進行了更新,
該狀態(tài)代碼現(xiàn)在被稱為422不可處理內(nèi)容而不是不可處理實體。
您與斷言422狀態(tài)代碼的交互方式?jīng)]有改變:
$response = $this->postJson('/example', []);
$response->assertUnprocessable();
有關(guān)詳細信息,請參閱RFC 9110:HTTP語義和拉取請求#51815。
添加關(guān)系::getMorphAlias()方法
Dennis Koch貢獻了一個Relation::getMorphAlias()方法
由于有一個Relation::getMorphedModel(),我認為添加反向的getMorphAlias是有益的。
此添加對測試特別有益,因為它使用$This->assertDatabaseHas簡化了斷言。
開發(fā)人員不再需要調(diào)用所使用的變形別名:
$this->assertDatabaseHas('taskables', [
'taskable_type' => Relation::getMorphAlias(Document::class),
'taskable_id' => $mitigation->id,
'task_id' => $taskB->id
]);
發(fā)布說明
你可以在下面看到新功能和更新的完整列表,以及GitHub上11.10.0和11.11.0之間的差異。
以下發(fā)行說明直接來自更改日志:
https://github.com/laravel/framework/compare/v11.10.0...v11.11.0
https://github.com/laravel/framework/blob/ae63a5b968f764ad0c5ecd86669bcc5fb8be90f7/CHANGELOG.md#v11110---2024-06-18
v11.11.0
[11.x]通過@stayallive在中添加獲取、寫入和忘記緩存事件
https://github.com/laravel/framework/pull/51560
[11.x]為Arr::sortRecursiveDes()方法添加測試。
由@lmottasin在https://github.com/laravel/framework/pull/51716
[11.x]通過@benholmen在中修復db:table命令中缺少的表名
https://github.com/laravel/framework/pull/51710
確保存在要安裝的文件:由@jasonmccrreary在中廣播
https://github.com/laravel/framework/pull/51719
[11.x]通過@jessarcher在中恢復異常/錯誤以測試斷言失敗消息
https://github.com/laravel/framework/pull/51725
[11.x]@crynobone在中的測試改進
https://github.com/laravel/framework/pull/51723
[11.x]添加可訪問的測試,并在中使用@saMahmoudzadeh的方法
https://github.com/laravel/framework/pull/51724
當@yankewei在中添加一些作業(yè)時,增加BatchFake的totalJobs屬性
https://github.com/laravel/framework/pull/51742
[11.x]通過@timacdonald在中對會話ID檢索進行Laravel處理
https://github.com/laravel/framework/pull/51732
[11.x]通過@rookiexxk在splitIn方法中將chunk方法固定為整數(shù)類型
https://github.com/laravel/framework/pull/51733
更新:通過@mehdi fathi在中更新名稱方法和文檔
https://github.com/laravel/framework/pull/51744
[11.x]修復了config:publish,其中@crynobone將dontMergeFrameworkConfiguration()
設置為true
https://github.com/laravel/framework/pull/51751
由@boris-grumbpler在中更新了用于Builder::from()的phpdoc
https://github.com/laravel/framework/pull/51767
[11.x]修復了默認Beankstalkd隊列在@rinocs未特別添加時彈出的問題
https://github.com/laravel/framework/pull/51759
[11.x]在中通過@avosalmon將前后方法添加到Collection
https://github.com/laravel/framework/pull/51752
[11.x]通過@jacob418更改afterCreateing和afterMaking回調(diào)的范圍
https://github.com/laravel/framework/pull/51772
在中由@AmirKhalifehSoltani在文件規(guī)則驗證中使用數(shù)字文字分隔符
https://github.com/laravel/framework/pull/51781
[11.x]在中通過@seriquynh為Renderer\Exception導入模型類
https://github.com/laravel/framework/pull/51778
[11.x]關(guān)于@AmirKhalifehSoltani在中的命令改進
https://github.com/laravel/framework/pull/51791
[11.x]在中通過@seriquynh測試中止行為
https://github.com/laravel/framework/pull/51800
[11.x]容器共享固定值/初始化的實例,而不是中@seriquynh的單例閉包解析
https://github.com/laravel/framework/pull/51804
[11.x]修復了在中通過@hafezdivandari更改SQLite上具有默認0列的表的問題
https://github.com/laravel/framework/pull/51803
[11.x]通過@tamiroh修復VendorPublishCommand中的拼寫錯誤
https://github.com/laravel/framework/pull/51812
[11.x]通過@tamiroh在中修復測試中的一些拼寫錯誤
https://github.com/laravel/framework/pull/51811
[11.x]在中通過@dwightwatson添加unprocessableContent并更新unprocessableEntity
https://github.com/laravel/framework/pull/51815
[11.x]改進隊列::assertNothingPushed()錯誤消息,由中的@SjorsO發(fā)出
https://github.com/laravel/framework/pull/51814
[11.x]在中通過@pxlrbt添加關(guān)系::getMorphAlias()
https://github.com/laravel/framework/pull/51809
[11.x]支持模型中的第三方關(guān)系:在中通過@staudenmeir顯示命令
https://github.com/laravel/framework/pull/51807
[11.x]通過@owenandrews在中修復嵌套規(guī)則自定義屬性名稱
https://github.com/laravel/framework/pull/51805
[11.x]修復@seriquynh在中的\Illuminate\Http\Response的docblock
https://github.com/laravel/framework/pull/51823
轉(zhuǎn):
https://laravel-news.com/laravel-11-11-0
123 在
Clash for Windows作者刪庫跑路了,github已404中評論 按理說只要你在國內(nèi),所有的流量進出都在監(jiān)控范圍內(nèi),不管你怎么隱藏也沒用,想搞你分..原梓番博客 在
在Laravel框架中使用模型Model分表最簡單的方法中評論 好久好久都沒看友情鏈接申請了,今天剛看,已經(jīng)添加。..博主 在
佛跳墻vpn軟件不會用?上不了網(wǎng)?佛跳墻vpn常見問題以及解決辦法中評論 @1111老鐵這個不行了,可以看看近期評論的其他文章..1111 在
佛跳墻vpn軟件不會用?上不了網(wǎng)?佛跳墻vpn常見問題以及解決辦法中評論 網(wǎng)站不能打開,博主百忙中能否發(fā)個APP下載鏈接,佛跳墻或極光..路人 在
php中使用hyperf框架調(diào)用訊飛星火大模型實現(xiàn)國內(nèi)版chatgpt功能示例中評論 教程很詳細,如果加個前端chatgpt對話頁面就完美了..
Copyright·? 2019 侯體宗版權(quán)所有·
粵ICP備20027696號