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

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

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

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

        <i id='Px9Kb'><tr id='Px9Kb'><dt id='Px9Kb'><q id='Px9Kb'><span id='Px9Kb'><b id='Px9Kb'><form id='Px9Kb'><ins id='Px9Kb'></ins><ul id='Px9Kb'></ul><sub id='Px9Kb'></sub></form><legend id='Px9Kb'></legend><bdo id='Px9Kb'><pre id='Px9Kb'><center id='Px9Kb'></center></pre></bdo></b><th id='Px9Kb'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='Px9Kb'><tfoot id='Px9Kb'></tfoot><dl id='Px9Kb'><fieldset id='Px9Kb'></fieldset></dl></div>
      1. 兩個外鍵,如何用laravel eloquent映射

        two foreign keys, how to map with laravel eloquent(兩個外鍵,如何用laravel eloquent映射)
        • <bdo id='00T6j'></bdo><ul id='00T6j'></ul>
          <legend id='00T6j'><style id='00T6j'><dir id='00T6j'><q id='00T6j'></q></dir></style></legend>

            <tbody id='00T6j'></tbody>
        • <small id='00T6j'></small><noframes id='00T6j'>

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

                  <tfoot id='00T6j'></tfoot>
                  本文介紹了兩個外鍵,如何用laravel eloquent映射的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我在 MySQL 中有兩個表,其中第一個稱為用戶,第二個稱為游戲.表結構如下.

                  I have two tables in MySQL, where the first one is called users and the second one is called games. The table structure is as follows.

                  用戶

                  • id(主要)
                  • 電子郵件
                  • 密碼
                  • 真實姓名

                  游戲

                  • id(主要)
                  • user_one_id(國外)
                  • user_one_score
                  • user_two_id(國外)
                  • user_two_score

                  我的游戲桌有兩個對外關系,兩個用戶.

                  My games table is holding two foreign relations to two users.

                  我的問題是如何為這個表結構建立模型關系??- 根據 laravel 文檔,我應該在模型內部創建一個函數并將其與其關系綁定

                  My question is how do I make the model relations for this table structure?? - According to the laravel documentation, I should make a function inside the model and bind it with its relations

                  例如

                  public function users()
                  {
                      $this->belongsTo('game');
                  }
                  

                  但是我似乎無法在文檔中找到任何告訴我如何處理兩個外鍵的內容.就像我上面的表格結構一樣.

                  however I can't seem to find anything in the documentation telling me how to deal with two foreign keys. like in my table structure above.

                  我希望你能幫助我一路走來.

                  I hope you can help me along the way here.

                  謝謝

                  推薦答案

                  遷移:

                  $table->integer('player1')->unsigned();
                  $table->foreign('player1')->references('id')->on('users')->onDelete('cascade');
                  $table->integer('player2')->unsigned();
                  $table->foreign('player2')->references('id')->on('users')->onDelete('cascade');
                  

                  還有一個模型:

                  public function player1()
                  {
                      $this->belongsTo('Game', 'player1');
                  }
                  public function player2()
                  {
                      $this->belongsTo('Game', 'player2');
                  }
                  

                  編輯按照用戶 deczo 的建議將游戲"更改為游戲".

                  EDIT changed 'game' to 'Game' as user deczo suggested.

                  這篇關于兩個外鍵,如何用laravel 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 找不到驅動程序)
                  <legend id='NeeU0'><style id='NeeU0'><dir id='NeeU0'><q id='NeeU0'></q></dir></style></legend>
                  • <tfoot id='NeeU0'></tfoot>
                      <tbody id='NeeU0'></tbody>
                      <bdo id='NeeU0'></bdo><ul id='NeeU0'></ul>

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

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

                            主站蜘蛛池模板: 在线视频成人 | 欧美精品乱码99久久影院 | 亚洲一区二区三区视频免费观看 | 久久国产精品色av免费观看 | 欧美涩涩网 | 99在线免费观看 | 拍戏被cao翻了h承欢 | 91亚洲国产成人久久精品网站 | av网站免费观看 | 免费看黄色视屏 | 亚洲国产一区二区三区 | 国产精品免费在线 | 91精品国产麻豆 | 免费日韩av| 欧美日韩一区在线播放 | 国产99久久| 午夜影视免费片在线观看 | 这里有精品| 天天摸天天干 | 欧美男人亚洲天堂 | 国产福利资源在线 | 日韩成人在线免费观看 | 国产精品久久久久久久粉嫩 | 午夜手机在线视频 | 国产在线对白 | 成人免费看片 | 欧美精品91爱爱 | 日韩欧美精品在线 | 精品视频一区二区三区四区 | 午夜网站视频 | av在线免费观看不卡 | 人成精品| 毛片免费视频 | 国产成人精品一区二区三区网站观看 | 天天拍夜夜爽 | 男女网站在线观看 | 成人在线观看免费视频 | 狠狠入ady亚洲精品经典电影 | 成人午夜激情 | 天堂资源 | 婷婷色婷婷 |