久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

  • <small id='hQV5r'></small><noframes id='hQV5r'>

    1. <i id='hQV5r'><tr id='hQV5r'><dt id='hQV5r'><q id='hQV5r'><span id='hQV5r'><b id='hQV5r'><form id='hQV5r'><ins id='hQV5r'></ins><ul id='hQV5r'></ul><sub id='hQV5r'></sub></form><legend id='hQV5r'></legend><bdo id='hQV5r'><pre id='hQV5r'><center id='hQV5r'></center></pre></bdo></b><th id='hQV5r'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='hQV5r'><tfoot id='hQV5r'></tfoot><dl id='hQV5r'><fieldset id='hQV5r'></fieldset></dl></div>
      <legend id='hQV5r'><style id='hQV5r'><dir id='hQV5r'><q id='hQV5r'></q></dir></style></legend>

      • <bdo id='hQV5r'></bdo><ul id='hQV5r'></ul>

        <tfoot id='hQV5r'></tfoot>

      1. 如何為 Laravel/Eloquent 模型設置默認屬性值?

        How to set a default attribute value for a Laravel / Eloquent model?(如何為 Laravel/Eloquent 模型設置默認屬性值?)

          <i id='Unixb'><tr id='Unixb'><dt id='Unixb'><q id='Unixb'><span id='Unixb'><b id='Unixb'><form id='Unixb'><ins id='Unixb'></ins><ul id='Unixb'></ul><sub id='Unixb'></sub></form><legend id='Unixb'></legend><bdo id='Unixb'><pre id='Unixb'><center id='Unixb'></center></pre></bdo></b><th id='Unixb'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Unixb'><tfoot id='Unixb'></tfoot><dl id='Unixb'><fieldset id='Unixb'></fieldset></dl></div>

          <tfoot id='Unixb'></tfoot>
            <tbody id='Unixb'></tbody>

              <small id='Unixb'></small><noframes id='Unixb'>

                <legend id='Unixb'><style id='Unixb'><dir id='Unixb'><q id='Unixb'></q></dir></style></legend>

                  <bdo id='Unixb'></bdo><ul id='Unixb'></ul>

                  本文介紹了如何為 Laravel/Eloquent 模型設置默認屬性值?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  如果我嘗試聲明一個屬性,如下所示:

                  public $quantity = 9;

                  ...它不起作用,因為它不被視為屬性",而只是模型類的屬性.不僅如此,我還阻止了對實際真實存在的數量"屬性的訪問.

                  那我該怎么辦?

                  解決方案

                  這就是我現在正在做的:

                  protected $defaults = array('數量' =>9、);公共函數 __construct(array $attributes = array()){$this->setRawAttributes($this->defaults, true);parent::__construct($attributes);}

                  我建議將此作為 PR,因此我們不需要在每個模型中都聲明此構造函數,并且只需在我們的模型中聲明 $defaults 數組即可輕松應用...<小時>

                  更新:

                  正如 cmfolio 所指出的,實際的答案很簡單:

                  只需覆蓋 $attributes 屬性即可!像這樣:

                  protected $attributes = array('數量' =>9、);

                  在此處討論了該問題.

                  If I try declaring a property, like this:

                  public $quantity = 9;
                  

                  ...it doesn't work, because it is not considered an "attribute", but merely a property of the model class. Not only this, but also I am blocking access to the actually real and existent "quantity" attribute.

                  What should I do, then?

                  解決方案

                  This is what I'm doing now:

                  protected $defaults = array(
                     'quantity' => 9,
                  );
                  
                  public function __construct(array $attributes = array())
                  {
                      $this->setRawAttributes($this->defaults, true);
                      parent::__construct($attributes);
                  }
                  

                  I will suggest this as a PR so we don't need to declare this constructor at every Model, and can easily apply by simply declaring the $defaults array in our models...


                  UPDATE:

                  As pointed by cmfolio, the actual ANSWER is quite simple:

                  Just override the $attributes property! Like this:

                  protected $attributes = array(
                     'quantity' => 9,
                  );
                  

                  The issue was discussed here.

                  這篇關于如何為 Laravel/Eloquent 模型設置默認屬性值?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死鎖異常代碼?)
                  PHP PDO MySQL scrollable cursor doesn#39;t work(PHP PDO MySQL 可滾動游標不起作用)
                  PHP PDO ODBC connection(PHP PDO ODBC 連接)
                  Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔術方法)
                  php pdo get only one value from mysql; value that equals to variable(php pdo 只從 mysql 獲取一個值;等于變量的值)
                  MSSQL PDO could not find driver(MSSQL PDO 找不到驅動程序)

                  <small id='qFaD2'></small><noframes id='qFaD2'>

                  <legend id='qFaD2'><style id='qFaD2'><dir id='qFaD2'><q id='qFaD2'></q></dir></style></legend>

                  • <tfoot id='qFaD2'></tfoot>
                  • <i id='qFaD2'><tr id='qFaD2'><dt id='qFaD2'><q id='qFaD2'><span id='qFaD2'><b id='qFaD2'><form id='qFaD2'><ins id='qFaD2'></ins><ul id='qFaD2'></ul><sub id='qFaD2'></sub></form><legend id='qFaD2'></legend><bdo id='qFaD2'><pre id='qFaD2'><center id='qFaD2'></center></pre></bdo></b><th id='qFaD2'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='qFaD2'><tfoot id='qFaD2'></tfoot><dl id='qFaD2'><fieldset id='qFaD2'></fieldset></dl></div>

                        • <bdo id='qFaD2'></bdo><ul id='qFaD2'></ul>
                            <tbody id='qFaD2'></tbody>
                          1. 主站蜘蛛池模板: 久久久久久久久久久国产 | 国产三区av| 日韩毛片视频 | 巨大荫蒂视频欧美另类大 | 国产精品二区三区在线观看 | 全免费a级毛片免费看视频免 | 欧美freesex黑人又粗又大 | 网站国产| 国产午夜精品久久久 | 国产一区二区高清在线 | 亚洲精品乱码久久久久久按摩观 | 久久天天躁狠狠躁夜夜躁2014 | 欧美一区免费 | 91偷拍精品一区二区三区 | 午夜国产一级 | 久久久成人一区二区免费影院 | 一区精品视频在线观看 | 久久久久久99 | 久久久精品一区 | 久久综合一区 | 国产一区二区电影 | 欧美日韩三区 | 亚洲区视频 | 国产99免费视频 | 极品销魂美女一区二区 | 欧美激情在线观看一区二区三区 | 国产成人av在线 | 国产成人jvid在线播放 | 日韩a在线 | 欧美精品一区二区三区蜜桃视频 | 中文字幕一区二区三区在线视频 | 久久国产成人精品国产成人亚洲 | 精品在线一区二区三区 | 免费一级淫片aaa片毛片a级 | 成人综合一区二区 | 麻豆91精品91久久久 | 国产美女黄色片 | 日韩网站在线观看 | 看一级毛片 | 亚洲第一av| 日韩免费av|