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

  • <tfoot id='elCKy'></tfoot>

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

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

        Laravel Eloquent Sum of關(guān)系的列

        Laravel Eloquent Sum of relation#39;s column(Laravel Eloquent Sum of關(guān)系的列)
        1. <legend id='EvNXU'><style id='EvNXU'><dir id='EvNXU'><q id='EvNXU'></q></dir></style></legend>
        2. <small id='EvNXU'></small><noframes id='EvNXU'>

          <tfoot id='EvNXU'></tfoot>

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

                  <tbody id='EvNXU'></tbody>

                  本文介紹了Laravel Eloquent Sum of關(guān)系的列的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我一直在開發(fā)一個購物車應(yīng)用程序,現(xiàn)在我遇到了以下問題..

                  I've been working on a shopping cart application and now I've come to the following issue..

                  有一個用戶、一個產(chǎn)品和一個購物車對象.

                  • 購物車表僅包含以下列:id、user_id、product_id 和時間戳.
                  • UserModel hasMany Carts(因為一個用戶可以存儲多個產(chǎn)品).
                  • CartModel belongsTo 用戶和 CartModel hasMany 產(chǎn)品.
                  • The Cart table only contains the following columns: id, user_id, product_id and timestamps.
                  • The UserModel hasMany Carts (because a user can store multiple products).
                  • The CartModel belongsTo a User and CartModel hasMany Products.

                  現(xiàn)在計算我可以調(diào)用的總產(chǎn)品數(shù):Auth::user()->cart()->count().

                  Now to calculate the total products I can just call: Auth::user()->cart()->count().

                  我的問題是:如何獲得該用戶購物車中產(chǎn)品的價格(一列產(chǎn)品)的SUM()?
                  我想使用 Eloquent 而不是使用查詢來完成此操作(主要是因為我認為它更簡潔).

                  My question is: How can I get the SUM() of prices (a column of product) of the products in cart by this User?
                  I would like to accomplish this with Eloquent and not by using a query (mainly because I believe it is a lot cleaner).

                  推薦答案

                  Auth::user()->products->sum('price');
                  

                  文檔對某些 Collection 方法略顯簡單,但除了 avg() 之外,所有查詢構(gòu)建器聚合似乎都可用,可在 http://laravel.com/docs/queries#aggregates.

                  The documentation is a little light for some of the Collection methods but all the query builder aggregates are seemingly available besides avg() that can be found at http://laravel.com/docs/queries#aggregates.

                  這篇關(guān)于Laravel Eloquent Sum of關(guān)系的列的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  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 和魔術(shù)方法)
                  php pdo get only one value from mysql; value that equals to variable(php pdo 只從 mysql 獲取一個值;等于變量的值)
                  MSSQL PDO could not find driver(MSSQL PDO 找不到驅(qū)動程序)
                    <tbody id='nEKjL'></tbody>

                      <tfoot id='nEKjL'></tfoot>
                      • <bdo id='nEKjL'></bdo><ul id='nEKjL'></ul>

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

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

                          • 主站蜘蛛池模板: 天天综合永久 | 青青久久av北条麻妃海外网 | 性做久久久久久免费观看欧美 | 天天干天天爱天天爽 | 久久久精品天堂 | 青草青草久热精品视频在线观看 | 一区二区影院 | 精品国产一区二区三区久久狼黑人 | 一区二区三区四区国产 | 夜夜操天天艹 | 亚洲精品电影在线观看 | av在线一区二区三区 | 在线精品亚洲欧美日韩国产 | 国产a区| 2018国产大陆天天弄 | 国产精品永久久久久久久www | 精品国产乱码久久久久久老虎 | 久久成人综合 | 久久亚洲精品久久国产一区二区 | 国产精品18久久久久久久 | 伊人网站在线观看 | 欧美成人一区二区三区片免费 | 天天干天天干 | www久久久 | 日韩中文字幕免费在线观看 | 日本人做爰大片免费观看一老师 | 中文字幕一区二区三区四区不卡 | 免费三级黄 | 久久亚洲欧美日韩精品专区 | 欧美日韩高清免费 | 久久久精品高清 | 热99在线| 久久网站黄 | 一区二区三区影院 | 久久国产精品视频观看 | 久久综合久久久 | 欧美成年黄网站色视频 | 浮生影院免费观看中文版 | 国产一区精品 | 欧美一区二区三 | 国产精品婷婷 |