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

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

        <small id='4Dmjn'></small><noframes id='4Dmjn'>

          <bdo id='4Dmjn'></bdo><ul id='4Dmjn'></ul>

        Eloquent 將十進制轉換為字符串

        Eloquent casts decimal as string(Eloquent 將十進制轉換為字符串)

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

      1. <legend id='u7wHE'><style id='u7wHE'><dir id='u7wHE'><q id='u7wHE'></q></dir></style></legend>

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

            <i id='u7wHE'><tr id='u7wHE'><dt id='u7wHE'><q id='u7wHE'><span id='u7wHE'><b id='u7wHE'><form id='u7wHE'><ins id='u7wHE'></ins><ul id='u7wHE'></ul><sub id='u7wHE'></sub></form><legend id='u7wHE'></legend><bdo id='u7wHE'><pre id='u7wHE'><center id='u7wHE'></center></pre></bdo></b><th id='u7wHE'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='u7wHE'><tfoot id='u7wHE'></tfoot><dl id='u7wHE'><fieldset id='u7wHE'></fieldset></dl></div>
                  <bdo id='u7wHE'></bdo><ul id='u7wHE'></ul>
                  本文介紹了Eloquent 將十進制轉換為字符串的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我的 Eloquent 模型中有一個十進制字段來表示金錢,但在嘗試向該字段添加一些數字時,我發現了錯誤的結果.

                  經過進一步檢查,我發現decimal 字段被轉換為字符串,就像 tinker 控制臺中的 "1245114.00".

                  我檢查了表結構,可以驗證該字段確實是decimal(11,3).

                  這個問題是之前問過但沒有答案.

                  為什么會這樣?

                  解決方案

                  您需要在模型中定義哪些字段需要轉換為原始屬性.

                  protected $casts = ['my_decimal' =>'漂浮',];

                  <塊引用>

                  模型上的 $casts 屬性提供了一種將屬性轉換為常見數據類型的便捷方法.$casts 屬性應該是一個數組,其中鍵是要轉換的屬性的名稱,值是您希望將列轉換為的類型.支持的轉換類型有:integerrealfloatdoublestringbooleanobjectarraycollectiondatedatetime時間戳

                  這里有一個非常好的解釋:

                  https://mattstauffer.com/blog/laravel-5.0-eloquent-attribute-casting/

                  文檔中也有解釋:

                  https://laravel.com/docs/5.5/eloquent-mutators#屬性轉換

                  I have a decimal field to represent money in my Eloquent Model and I'm noticing erroneous results when trying to add some number to this field.

                  Upon further inspection, I found that the decimal field is being cast as a string, like "1245114.00" in the tinker console.

                  I checked the table structure and I can verify that the field is indeed decimal(11,3).

                  This question was asked before but has no answers.

                  Why is this happening?

                  解決方案

                  You need to define in your model which fields need to be cast to a primitive attribute.

                  protected $casts = [
                      'my_decimal' => 'float',
                  ];
                  

                  The $casts property on your model provides a convenient method of converting attributes to common data types. The $casts property should be an array where the key is the name of the attribute being cast and the value is the type you wish to cast the column to. The supported cast types are: integer, real, float, double, string, boolean, object, array, collection, date, datetime, and timestamp

                  There is a really good explanation here:

                  https://mattstauffer.com/blog/laravel-5.0-eloquent-attribute-casting/

                  Also there is an explanation in the docs:

                  https://laravel.com/docs/5.5/eloquent-mutators#attribute-casting

                  這篇關于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 找不到驅動程序)
                • <tfoot id='bismU'></tfoot>

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

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

                          <legend id='bismU'><style id='bismU'><dir id='bismU'><q id='bismU'></q></dir></style></legend>
                            主站蜘蛛池模板: 国内精品视频免费观看 | 欧美久久一级特黄毛片 | 美女激情av | 亚洲三区在线观看 | 久久一区二区视频 | 久久亚洲精品久久国产一区二区 | 亚洲一区| 99久久免费精品国产男女高不卡 | 久久久久久久av | 91 久久 | 久久精品一 | 欧美日韩亚洲二区 | 一区二区免费在线观看 | 国产精品免费一区二区三区四区 | 久久99视频免费观看 | 久久日本| 一级视频在线免费观看 | 国产成人综合在线 | 91国在线视频 | 久久久精品影院 | 亚洲av毛片成人精品 | 久久高清免费视频 | 亚洲视频免费观看 | 欧美亚洲国产精品 | 久久国产欧美日韩精品 | 国产精品视频在线播放 | 国产日韩一区 | 欧美日韩综合精品 | 亚洲一区精品在线 | 欧美精品一区二区三区蜜臀 | 国产精品久久久久久久久久 | 国产午夜亚洲精品不卡 | 亚洲综合色婷婷 | 天天干人人 | 欧美成人a | 在线伊人网 | 日韩精品成人在线 | 视频在线一区二区 | 国产精品久久免费观看 | 欧美日本韩国一区二区 | 日韩视频二区 |