久久久久久久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久9| 国产成人精品久久二区二区91 | 国产精品一区在线观看 | 三级av在线 | 免费视频99| 国产美女黄色 | 自拍偷拍中文字幕 | 久久91精品国产一区二区 | 国产精品视频久久久久久 | 久久久久国产精品一区二区 | 在线中文视频 | 美女一区 | 亚洲视频区 | 91亚洲精华国产 | 天天干免费视频 | av大全在线| 国产探花在线精品一区二区 | 成人污污视频 | 久久99深爱久久99精品 | 日韩在线一区二区三区 | 精品亚洲视频在线 | 一区二区三区免费观看 | 成人免费看 | 大香网伊人 | 午夜不卡一区二区 | 久久精品久久精品 | 久久精品在线播放 | 激情婷婷 | 国产高清视频在线播放 | 99久久久久久久久 | 欧美视频一区 | 一区二区三区四区在线 |