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

        <legend id='UZ56n'><style id='UZ56n'><dir id='UZ56n'><q id='UZ56n'></q></dir></style></legend>
      1. <small id='UZ56n'></small><noframes id='UZ56n'>

      2. <tfoot id='UZ56n'></tfoot>

        Laravel 查询多对多

        时间:2023-09-23
            <tbody id='biIQk'></tbody>
          • <tfoot id='biIQk'></tfoot>
            <i id='biIQk'><tr id='biIQk'><dt id='biIQk'><q id='biIQk'><span id='biIQk'><b id='biIQk'><form id='biIQk'><ins id='biIQk'></ins><ul id='biIQk'></ul><sub id='biIQk'></sub></form><legend id='biIQk'></legend><bdo id='biIQk'><pre id='biIQk'><center id='biIQk'></center></pre></bdo></b><th id='biIQk'></th></span></q></dt></tr></i><div id='biIQk'><tfoot id='biIQk'></tfoot><dl id='biIQk'><fieldset id='biIQk'></fieldset></dl></div>
              <bdo id='biIQk'></bdo><ul id='biIQk'></ul>
            • <small id='biIQk'></small><noframes id='biIQk'>

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

                1. 本文介绍了Laravel 查询多对多的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我需要帮助.我有 2 个表 productscategories:

                  I need help.I have 2 tables products and categories:

                  获取请求发送类别 ID.我的问题是:如何使用产品模型构建查询???(查询看起来像这样:输出类别 id 等于 $ request-> category 的产品).表连接配置好了,我只需要查询,(我看了文档,但没看懂)

                  Get request sends category id. My question is: how to build a query using the product model??? (The query looks like this: Output the product where the category id is equal to $ request-> category). Table connections are configured, I only need the query, (I read the documentation, but do not not understand it)

                  推荐答案

                  您可以使用:

                  $products = Product::whereHas('categories', function($q) use ($categoryId) {
                     $q->where('id', $categoryId);
                  })->get();
                  

                  阅读查询关系

                  当然你需要配置Product模型和categories关系.

                  Of course you need to have configured Product model with categories relationship.

                  这篇关于Laravel 查询多对多的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Laravel 身份验证与雄辩的角色驱动程序 下一篇:如何在 Laravel 上更新数据透视表?

                  相关文章

                  最新文章

                    <bdo id='VnLot'></bdo><ul id='VnLot'></ul>
                2. <legend id='VnLot'><style id='VnLot'><dir id='VnLot'><q id='VnLot'></q></dir></style></legend>

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

                  <tfoot id='VnLot'></tfoot>

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