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

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

      • <bdo id='RV7dz'></bdo><ul id='RV7dz'></ul>
      <legend id='RV7dz'><style id='RV7dz'><dir id='RV7dz'><q id='RV7dz'></q></dir></style></legend>

      1. L5.6 - 數據透視表的關系

        L5.6 - Relation on pivot table(L5.6 - 數據透視表的關系)

        <tfoot id='WMyxh'></tfoot>

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

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

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

                  <tbody id='WMyxh'></tbody>
                • <legend id='WMyxh'><style id='WMyxh'><dir id='WMyxh'><q id='WMyxh'></q></dir></style></legend>
                • 本文介紹了L5.6 - 數據透視表的關系的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我在樞軸表上有一個關系;我如何擴展它?

                  I've a relation on a pivot table; how I can expand It?

                  例如:

                  商店:

                  • id
                  • 姓名

                  產品:

                  • id
                  • 姓名

                  product_shop:

                  • product_id
                  • shop_id
                  • field_1
                  • field_2
                  • field_3
                  • table_A_id

                  table_A:

                  • id
                  • 姓名

                  Shops 模型中的多對多關系是:

                  The relation Many-to-Many in the Shops Model is:

                  class Shops extends Model {
                      public function products()
                      {
                          return $this->belongsToMany('Products', 'product_shop', 'product_id', 'shop_id')->withPivot(
                              'field_1',
                              'field_3',
                              'field_3',
                              'table_A_id'
                              )
                              ->as('product_shop')
                              ->withTimestamps();
                      }
                  

                  }

                  檢索所有數據的查詢是:

                  and the query to retrieve all data is:

                  class GetData extends Model {
                       public static function getAll() {
                           $query = Shops::with(
                              'products'
                              )->get();
                       }
                  }
                  

                  這會返回product_shop.table_A_id,但我想擴展外鍵并檢索table_A.name;有辦法嗎?

                  This return the product_shop.table_A_id but I'd like to expand the foreign key and retrieve table_A.name; is there a way?

                  謝謝.

                  推薦答案

                  您可以使用樞軸模型:

                  class ProductShopPivot extends IlluminateDatabaseEloquentRelationsPivot
                  {
                      public function tableA()
                      {
                          return $this->belongsTo(TableA::class);
                      }
                  }
                  
                  class Shops extends Model
                  {
                      public function products()
                      {
                          return $this->belongsToMany('Products', 'product_shop', 'product_id', 'shop_id')
                              ->withPivot(
                                  'field_1',
                                  'field_3',
                                  'field_3',
                                  'table_A_id'
                              )
                              ->as('product_shop')
                              ->withTimestamps()
                              ->using(ProductShopPivot::class);
                      }
                  }
                  

                  然后像這樣訪問它:

                  $shop->product_shop->tableA->name
                  

                  不幸的是,沒有辦法預先加載 tableA 關系.

                  Unfortunately, there is no way to eager load the tableA relation.

                  這篇關于L5.6 - 數據透視表的關系的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  MySQLi prepared statement amp; foreach loop(MySQLi準備好的語句amp;foreach 循環)
                  Is mysqli_insert_id() gets record from whole server or from same user?(mysqli_insert_id() 是從整個服務器還是從同一用戶獲取記錄?)
                  PHP MySQLi doesn#39;t recognize login info(PHP MySQLi 無法識別登錄信息)
                  mysqli_select_db() expects exactly 2 parameters(mysqli_select_db() 需要 2 個參數)
                  Php mysql pdo query: fill up variable with query result(Php mysql pdo 查詢:用查詢結果填充變量)
                  MySQLI 28000/1045 Access denied for user #39;root#39;@#39;localhost#39;(MySQLI 28000/1045 用戶“root@“localhost的訪問被拒絕)

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

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

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

                            <tbody id='u5oGG'></tbody>

                          • 主站蜘蛛池模板: 日韩av网址在线观看 | 一级黄色片免费 | 欧美日韩一区在线播放 | 欧美在线一区二区三区 | 国产精品一区二区视频 | 亚洲电影免费 | 欧美13videosex性极品 | 精品久久久久久久久亚洲 | 精品免费国产一区二区三区四区介绍 | 久久久精品久久久 | 亚洲区一区二 | 日本手机在线 | 日韩精品视频在线 | 午夜久草 | 久久国产亚洲 | 国产成在线观看免费视频 | 久久久久99| 日韩欧美国产精品 | 欧日韩在线观看 | 亚洲综合中文字幕在线观看 | 国产最好的av国产大片 | 精品毛片视频 | 一级看片免费视频 | 激情伊人网 | 欧美日韩一区二区在线播放 | 午夜一区二区三区在线观看 | 日韩中文字幕一区二区三区 | 国产目拍亚洲精品99久久精品 | 成人黄色av网站 | 欧美精品在线播放 | 免费在线视频一区二区 | 在线一区视频 | 日韩在线| 日韩在线中文 | 成人国产精品入口免费视频 | 久久综合久色欧美综合狠狠 | 一区二区中文 | 97高清国语自产拍 | 久久精品视频在线观看 | 国产精品自拍视频 | 国产精品视频在线播放 |