欧美亚洲中文,在线国自产视频,欧洲一区在线观看视频,亚洲综合中文字幕在线观看

      1. <dfn id="rfwes"></dfn>
          <object id="rfwes"></object>
        1. 站長(zhǎng)資訊網(wǎng)
          最全最豐富的資訊網(wǎng)站

          Laravel 9.35 發(fā)布啦!看看都有哪些新變化?

          下面由Laravel教程欄目給大家介紹關(guān)于最新發(fā)布的Laravel 9.35版本都有哪些變化,希望對(duì)大家有所幫助!

          Laravel 團(tuán)隊(duì)發(fā)布了9.35版本,它有一個(gè)新的令人興奮的備用郵件語(yǔ)法、一個(gè)Eloquent的 “嚴(yán)格模式” 功能等。

          備用郵件語(yǔ)法

          Taylor Otwell 通過(guò)返回 “指定可郵件內(nèi)容和屬性的精簡(jiǎn)對(duì)象”,貢獻(xiàn)了一個(gè)可郵件語(yǔ)法。

          這是他的一個(gè)例子 pull request description:

          namespace AppMail;  use IlluminateBusQueueable; use IlluminateContractsQueueShouldQueue; use IlluminateMailMailable; use IlluminateMailMailablesAddress; use IlluminateMailMailablesAttachment; use IlluminateMailMailablesContent; use IlluminateMailMailablesEnvelope; use IlluminateQueueSerializesModels;  class InvoicePaid extends Mailable {     use Queueable, SerializesModels;      /**      * 創(chuàng)建一個(gè)郵件實(shí)例      *      * @return void      */     public function __construct()     {         //     }      /**      * 獲取郵件信封      *      * @return IlluminateMailMailablesEnvelope      */     public function envelope()     {         return new Envelope(             subject: 'Invoice Paid',             cc: [new Address('foo@example.com', 'Example Name')],             tags: [],             metadata: [],         );     }      /**      * 獲取郵件內(nèi)容定義      *      * @return IlluminateMailMailablesContent      */     public function content()     {         return new Content(             view: 'html-view-name',             text: 'text-view-name',         );     }      /**      * 獲取郵件的附件      *      * @return IlluminateMailMailablesAttachment[]      */     public function attachments()     {         return [             Attachment::fromPath('/path/to/file'),         ];     } }
          登錄后復(fù)制

          使用build() 定義郵件的傳統(tǒng)方式不會(huì)被刪除。 我喜歡上面的例子是因?yàn)槭褂?PHP 8 的命名參數(shù)更一目了然。

          Eloquent “嚴(yán)格”模式

          Chris Morrell 和 Taylor Otwell 合作開(kāi)發(fā)了 Eloquent 嚴(yán)格模式,該模式支持以下功能:

          • 沒(méi)有延遲加載
          • 分配不可填充屬性時(shí)的例外情況
          • 訪問(wèn)未檢索或不存在的屬性的異常

          要在開(kāi)發(fā)中使用嚴(yán)格模式,方法是將以下內(nèi)容添加到已注冊(cè)服務(wù)提供者的 boot() 方法中:

          Model::shouldBeStrict();
          登錄后復(fù)制

          shouldBeStrict() 方法是啟用以下所有功能的快捷方式:

          Model::preventLazyLoading(); Model::preventSilentlyDiscardingAttributes(); Model::preventsAccessingMissingAttributes();
          登錄后復(fù)制

          使用資源路由加載廢棄模型

          Andrew Brown 提供了使用以下路由語(yǔ)法加載帶有資源路由的廢棄模型的能力:

          // 所有終結(jié)點(diǎn) Route::resource('users', UserController::class)->withTrashed();  // 僅`顯示` Route::resource('users', UserController::class)->withTrashed(['show']);
          登錄后復(fù)制

          發(fā)行說(shuō)明

          你可以在GitHub上看到下面完整的新功能和更新列表以及[9.34.0]和9.35.0](github.com/laravel/framework/compa…) 之間的區(qū)別。以下發(fā)行說(shuō)明直接來(lái)自 changelog:

          v9.35.0

          添加

          • 允許為資源路由加載廢棄模型 (#44405)
          • 添加到 Illuminate/Database/Eloquent/Model::shouldBeStrict() 和其他 (#44283)
          • 沒(méi)有解析控制器的控制器中間件 (#44516)
          • 選擇可郵寄的語(yǔ)法 (#44462)

          修復(fù)

          • 修復(fù)自引用多對(duì)多關(guān)系中的聚合函數(shù)(withSum 等)問(wèn)題(#44286)
          • 修復(fù)了使用靜態(tài)類(lèi)屬性作為模板屬性的問(wèn)題 (#44473)
          • Traversable 在 Enumerate Values 中應(yīng)該優(yōu)先于 JsonSerializable(#44456)
          • 修復(fù)了make:cast --inbound,所以它是一個(gè)布爾選項(xiàng),而不是值 (#44505)

          修改

          • 測(cè)試方法。 使用 json_encode 使錯(cuò)誤消息更具可讀性(#44397)
          • Model::without Timestamps() 返回回調(diào)的返回值 (#44457)
          • 僅在相關(guān)路由上加載廢棄模型(#44478)
          • 向 shouldBlockPhpUpload 函數(shù)添加額外的 PHP 擴(kuò)展 (#44512)
          • 為特別嘈雜的對(duì)象注冊(cè) cutInternals casters (#44514)
          • 使用 get 方法訪問(wèn)應(yīng)用程序區(qū)域設(shè)置 (#44521)
          • 僅返回來(lái)自頻道的非空響應(yīng) (09d53ee, 3944a3e)
          • 正確的頻道匹配 (#44531)
          • 遷移郵件組件 (#44527)

          原文地址:https://laravel-news.com/laravel-9-35-0

          譯文地址:https://learnku.com/laravel/t/72658

          贊(0)
          分享到: 更多 (0)
          網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)