pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

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

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

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

      1. <i id='QvxS9'><tr id='QvxS9'><dt id='QvxS9'><q id='QvxS9'><span id='QvxS9'><b id='QvxS9'><form id='QvxS9'><ins id='QvxS9'></ins><ul id='QvxS9'></ul><sub id='QvxS9'></sub></form><legend id='QvxS9'></legend><bdo id='QvxS9'><pre id='QvxS9'><center id='QvxS9'></center></pre></bdo></b><th id='QvxS9'></th></span></q></dt></tr></i><div class="fpypl7h" id='QvxS9'><tfoot id='QvxS9'></tfoot><dl id='QvxS9'><fieldset id='QvxS9'></fieldset></dl></div>
        <legend id='QvxS9'><style id='QvxS9'><dir id='QvxS9'><q id='QvxS9'></q></dir></style></legend>
      2. Laravel - 數據透視表上的附加關系

        Laravel - Additional relationship on a pivot table(Laravel - 數據透視表上的附加關系)
        <i id='BxWQo'><tr id='BxWQo'><dt id='BxWQo'><q id='BxWQo'><span id='BxWQo'><b id='BxWQo'><form id='BxWQo'><ins id='BxWQo'></ins><ul id='BxWQo'></ul><sub id='BxWQo'></sub></form><legend id='BxWQo'></legend><bdo id='BxWQo'><pre id='BxWQo'><center id='BxWQo'></center></pre></bdo></b><th id='BxWQo'></th></span></q></dt></tr></i><div class="mehg8j2" id='BxWQo'><tfoot id='BxWQo'></tfoot><dl id='BxWQo'><fieldset id='BxWQo'></fieldset></dl></div>
      3. <small id='BxWQo'></small><noframes id='BxWQo'>

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

              <tbody id='BxWQo'></tbody>

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

                  問題描述

                  我有一個帶有 2 個鍵的常規數據透視表.但是,我還有第三列,我想在其中存儲具有一對多關系的不同鍵.這可能嗎?

                  I have a regular pivot table with 2 keys. However, I also have a 3rd column where I want to store a different key with a one to many relationship. Is this possible to have?

                  示例:

                  數據透視表:
                  組織 1 |組織 2 |關系類型
                  1 |2 |1
                  1 |3 |2

                  Pivot table:
                  Organization 1 | Organization 2 | Relation type
                  1 | 2 | 1
                  1 | 3 | 2

                  在這種情況下,組織編號 1 與組織編號 2 存在關系,關系類型為編號 1.組織編號 1 也與組織編號 3 存在關系,關系類型為 2.

                  In this case organization number 1 has a relation with organization number 2 with the relation type being number 1. Organization number 1 also has a relation with organization number 3 with relation type 2.

                  現在是我的問題,如何在數據透視表上設置額外的一對多關系?

                  Now is my question, how do I set up that additional one to many relationship on the pivot table?

                  推薦答案

                  這里是三元關系.您是說組織 A 與組織 B 和關系類型相關.這是一個非常罕見的用例,因為在絕大多數情況下,三元關系可以簡化為二元關系.您需要對您的數據模型進行非常深入的檢查,以確定您的案例是否可以簡化,但假設不能,這是我的建議.

                  What you have here is a ternary relationship. You are saying that an organisation A relates with an organisation B and a relationship type. This is a very uncommon use case because in the vast majority of cases ternary relationships can be simplified to binary ones. You need a very deep inspection of your data model to determine whether your case can be simplified, but assuming that it can't here's my suggestions.

                  值得檢查雄辯的文檔,特別是在為此定義自定義中間表模型.請注意,這需要 Laravel 5.4+ 才能工作.

                  It's worth checking the eloquent docs in particular under Defining Custom Intermediate Table Models for this. Note that this requires Laravel 5.4+ to work.

                  以下應該有效:

                  class OrganisationOrganisationLink extends Pivot {
                      public relationType() {
                            return $this->belongsTo(RelationType::class); //You need to specify the foreign key correctly as a 2nd parameter
                      }
                  }
                  

                  然后在您的原始模型中:

                  Then in your original model:

                  class Organisation extends Model {
                      public relatedOrganisation() {
                          return $this->belongsToMany(self::class)->using(OrganisationOrganisationLink::class); 
                      }
                  }
                  

                  然后在實際使用它時,您可以例如做:

                  Then when making practical use of this you can e.g. do:

                  $organisation = Organisation::with('relatedOrganisation')->first();
                  echo "Got ".$organisation->name." which relates to "
                       .$organisation->relatedOrganisation->first()->name 
                       ." with relationship type "       
                       $organisation->relatedOrganisation->first()->pivot->relationshipType()->value('name'); 
                  

                  當然,我假設的領域可能不存在,但希望你能明白.

                  Of course the fields I've assumed may not exist but hopefully you get the idea.

                  這篇關于Laravel - 數據透視表上的附加關系的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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的訪問被拒絕)

                    <bdo id='9tGR1'></bdo><ul id='9tGR1'></ul>

                            <tbody id='9tGR1'></tbody>

                          <small id='9tGR1'></small><noframes id='9tGR1'>

                            <tfoot id='9tGR1'></tfoot>
                          • <legend id='9tGR1'><style id='9tGR1'><dir id='9tGR1'><q id='9tGR1'></q></dir></style></legend>
                            <i id='9tGR1'><tr id='9tGR1'><dt id='9tGR1'><q id='9tGR1'><span id='9tGR1'><b id='9tGR1'><form id='9tGR1'><ins id='9tGR1'></ins><ul id='9tGR1'></ul><sub id='9tGR1'></sub></form><legend id='9tGR1'></legend><bdo id='9tGR1'><pre id='9tGR1'><center id='9tGR1'></center></pre></bdo></b><th id='9tGR1'></th></span></q></dt></tr></i><div class="ohoidfn" id='9tGR1'><tfoot id='9tGR1'></tfoot><dl id='9tGR1'><fieldset id='9tGR1'></fieldset></dl></div>
                            主站蜘蛛池模板: 电子万能试验机_液压拉力试验机_冲击疲劳试验机_材料试验机厂家-济南众标仪器设备有限公司 | 台湾Apex减速机_APEX行星减速机_台湾精锐减速机厂家代理【现货】-杭州摩森机电 | 窖井盖锯圆机_锯圆机金刚石锯片-无锡茂达金刚石有限公司 | 12cr1mov无缝钢管切割-15crmog无缝钢管切割-40cr无缝钢管切割-42crmo无缝钢管切割-Q345B无缝钢管切割-45#无缝钢管切割 - 聊城宽达钢管有限公司 | 清洁设备_洗地机/扫地机厂家_全自动洗地机_橙犀清洁设备官网 | 我爱古诗词_古诗词名句赏析学习平台 | 爱德华真空泵油/罗茨泵维修,爱发科-比其尔产品供应东莞/杭州/上海等全国各地 | 锂电混合机-新能源混合机-正极材料混料机-高镍,三元材料混料机-负极,包覆混合机-贝尔专业混合混料搅拌机械系统设备厂家 | 上海logo设计| 防渗膜厂家|养殖防渗膜|水产养殖防渗膜-泰安佳路通工程材料有限公司 | 扬州汇丰仪表有限公司| 整合营销推广|营销网络推广公司|石家庄网站优化推广公司|智营销 好物生环保网、环保论坛 - 环保人的学习交流平台 | YJLV22铝芯铠装电缆-MYPTJ矿用高压橡套电缆-天津市电缆总厂 | 同学聚会纪念册制作_毕业相册制作-成都顺时针宣传画册设计公司 | 银川美容培训-美睫美甲培训-彩妆纹绣培训-新娘化妆-学化妆-宁夏倍莱妮职业技能培训学校有限公司 临时厕所租赁_玻璃钢厕所租赁_蹲式|坐式厕所出租-北京慧海通 | 全国国际学校排名_国际学校招生入学及学费-学校大全网 | 标准光源箱|对色灯箱|色差仪|光泽度仪|涂层测厚仪_HRC大品牌生产厂家 | 电缆隧道在线监测-智慧配电站房-升压站在线监测-江苏久创电气科技有限公司 | 下水道疏通_管道疏通_马桶疏通_附近疏通电话- 立刻通 | 精密五金加工厂-CNC数控车床加工_冲压件|蜗杆|螺杆加工「新锦泰」 | 编织人生 - 权威手工编织网站,编织爱好者学习毛衣编织的门户网站,织毛衣就上编织人生网-编织人生 | 电梯乘运质量测试仪_电梯安全评估测试仪-武汉懿之刻 | 量子管通环-自清洗过滤器-全自动反冲洗过滤器-北京罗伦过滤技术集团有限公司 | 优宝-汽车润滑脂-轴承润滑脂-高温齿轮润滑油脂厂家 | 全自动固相萃取仪_高通量真空平行浓缩仪-勤业永为 | 合肥卓创建筑装饰,专业办公室装饰、商业空间装修与设计。 | 12cr1mov无缝钢管切割-15crmog无缝钢管切割-40cr无缝钢管切割-42crmo无缝钢管切割-Q345B无缝钢管切割-45#无缝钢管切割 - 聊城宽达钢管有限公司 | 精密钢管,冷拔精密无缝钢管,精密钢管厂,精密钢管制造厂家,精密钢管生产厂家,山东精密钢管厂家 | 真空粉体取样阀,电动楔式闸阀,电动针型阀-耐苛尔(上海)自动化仪表有限公司 | 篮球架_乒乓球台_足球门_校园_竞技体育器材_厂家_价格-沧州浩然体育器材有限公司 | 硫化罐-胶管硫化罐-山东鑫泰鑫智能装备有限公司 | 北京百度网站优化|北京网站建设公司-百谷网络科技 | 防爆型气象站_农业气象站_校园气象站_农业四情监测系统「山东万象环境科技有限公司」 | MVR蒸发器厂家-多效蒸发器-工业废水蒸发器厂家-康景辉集团官网 | 纯水电导率测定仪-万用气体检测仪-低钠测定仪-米沃奇科技(北京)有限公司www.milwaukeeinst.cn 锂辉石检测仪器,水泥成分快速分析仪-湘潭宇科分析仪器有限公司 手术室净化装修-手术室净化工程公司-华锐手术室净化厂家 | 大米加工设备|大米加工机械|碾米成套设备|大米加工成套设备-河南成立粮油机械有限公司 | 精密五金冲压件_深圳五金冲压厂_钣金加工厂_五金模具加工-诚瑞丰科技股份有限公司 | 高空重型升降平台_高空液压举升平台_高空作业平台_移动式升降机-河南华鹰机械设备有限公司 | 山东臭氧发生器,臭氧发生器厂家-山东瑞华环保设备 | 接地电阻测试仪[厂家直销]_电缆故障测试仪[精准定位]_耐压测试仪-武汉南电至诚电力设备 | 派克防爆伺服电机品牌|国产防爆伺服电机|高低温伺服电机|杭州摩森机电科技有限公司 |