久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長(zhǎng)資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      淺析Laravel中isDirty()和wasChanged()的區(qū)別

      本篇文章帶大家聊聊Laravel數(shù)據(jù)模型中isDirty()和wasChanged()的區(qū)別,希望對(duì)大家有所幫助!

      淺析Laravel中isDirty()和wasChanged()的區(qū)別

      Laravel 數(shù)據(jù)模型中 `isDirty()` 和 `wasChanged()` 有區(qū)別嗎?

      答案:是有區(qū)別的。

      相關(guān)代碼: github.com/laravel/framework/blob/…

      isDirty 函數(shù)的代碼如下:

      /**  * 判斷模型或者任意指定模型屬性是否被修改過(guò)  *  * @param  array|string|null  $attributes  * @return bool  */public function isDirty($attributes = null){     return $this->hasChanges(         $this->getDirty(), is_array($attributes) ? $attributes : func_get_args()     );}
      登錄后復(fù)制

      getChanges() 和 getDirty() 函數(shù)的代碼如下

      /**  * 獲取自從最后一次同步以來(lái),被修改的屬性值  *  * @return array  */public function getDirty(){     $dirty = [];     foreach ($this->getAttributes() as $key => $value) {         if (! $this->originalIsEquivalent($key, $value)) {             $dirty[$key] = $value;         }     }     return $dirty;}/**  * 獲取所有已經(jīng)被修改的屬性.  *  * @return array  */public function getChanges(){     return $this->changes;}
      登錄后復(fù)制

      簡(jiǎn)而言之.

      答案引用于: laracasts.com/discuss/channels/elo…

      isDirty (and getDirty) 用在保存前置執(zhí)行, 查看哪些屬性在從數(shù)據(jù)庫(kù)檢索到調(diào)用之間被修改過(guò), 而 wasChanged (and getChanges)是保存后置執(zhí)行,查看屬性是否在上次保存中(從代碼到數(shù)據(jù)庫(kù))被修改或者更新.

      原文地址:https://stackoverflow.com/questions/58312036/incoherence-between-eloquent-isdirty-and-getchanges

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

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