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

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

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

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

        Eloquent 多對多對多 - 如何輕松加載遠距離關系

        Eloquent many-to-many-to-many - how to load distant relation easily(Eloquent 多對多對多 - 如何輕松加載遠距離關系)

            <legend id='AN8Om'><style id='AN8Om'><dir id='AN8Om'><q id='AN8Om'></q></dir></style></legend>
              <tbody id='AN8Om'></tbody>

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

            1. <tfoot id='AN8Om'></tfoot>
                <bdo id='AN8Om'></bdo><ul id='AN8Om'></ul>
              • <i id='AN8Om'><tr id='AN8Om'><dt id='AN8Om'><q id='AN8Om'><span id='AN8Om'><b id='AN8Om'><form id='AN8Om'><ins id='AN8Om'></ins><ul id='AN8Om'></ul><sub id='AN8Om'></sub></form><legend id='AN8Om'></legend><bdo id='AN8Om'><pre id='AN8Om'><center id='AN8Om'></center></pre></bdo></b><th id='AN8Om'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='AN8Om'><tfoot id='AN8Om'></tfoot><dl id='AN8Om'><fieldset id='AN8Om'></fieldset></dl></div>
                  本文介紹了Eloquent 多對多對多 - 如何輕松加載遠距離關系的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我有 3 張桌子;用戶、組和權限

                  I have 3 tables; users, groups and permissions

                  在模型中,我將關系設置為belongsToMany在用戶模型中:

                  In models I have the relationships set as belongsToMany in user model:

                  public function groups() {
                      return $this->belongsToMany('Group');
                  }
                  

                  在組模型中:

                  public function users() {
                      return $this->belongsToMany('User');
                  }
                  
                  public function permissions() {
                      return $this->belongsToMany('Permission');
                  }
                  

                  在權限模型中:

                  public function groups() {
                      return $this->belongsToMany('Group', 'id');
                  }
                  

                  許多用戶 - 到 - 許多組許多組-對-許多權限

                  many users - to - many groups many groups - to - many permissions

                  我正在嘗試獲取用戶擁有的所有權限,但不知道它的代碼應該是什么樣子.有人可以幫忙嗎?

                  I'm trying to get all the permissions a user has, and have no clue what the code for it should look like. Can anyone help?

                  推薦答案

                  您可以這樣做:

                  User::where('id', $id)->with(['groups.permissions' => function ($q) use (&$permissions) {
                       $permissions = $q->get()->unique();
                  }])->first();
                  
                  // then
                  $permissions; // collection of unique permissions of the user with id = $id
                  

                  這篇關于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='8fFlc'></tfoot>
                  <legend id='8fFlc'><style id='8fFlc'><dir id='8fFlc'><q id='8fFlc'></q></dir></style></legend>

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

                          <small id='8fFlc'></small><noframes id='8fFlc'>

                            <bdo id='8fFlc'></bdo><ul id='8fFlc'></ul>
                              <tbody id='8fFlc'></tbody>

                            主站蜘蛛池模板: 国产专区在线 | 国产精品1区2区3区 男女啪啪高潮无遮挡免费动态 | 色吧久久 | 午夜不卡福利视频 | 福利精品| 久久剧场 | 99视频网| 狠狠操狠狠搞 | a级毛片毛片免费观看久潮喷 | 高清一区二区 | 中文一区二区视频 | 国产免费让你躁在线视频 | 九九精品在线 | 99reav| 一区二区三区小视频 | 欧美黑人又粗大 | 色婷婷亚洲一区二区三区 | 精品欧美激情精品一区 | 日韩亚洲视频 | 日韩在线国产 | 国产成人麻豆免费观看 | 欧美激情一区二区 | 久久久久国产一区二区三区四区 | 一级欧美日韩 | 羞羞网站免费 | 亚洲欧洲精品成人久久奇米网 | 麻豆av在线| 成人国产精品久久久 | 日韩视频专区 | 久久精品国产一区二区电影 | ww亚洲ww亚在线观看 | 操皮视频| 亚洲欧美成人在线 | 亚洲人成人一区二区在线观看 | 成人av资源在线 | 一区福利视频 | 亚洲精品在线播放 | 国产成人精品免费视频大全最热 | 天堂av免费观看 | www.色午夜.com | 久久久久久av |