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

  • <small id='WdwPA'></small><noframes id='WdwPA'>

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

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

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

        無法讓 Laravel 助理工作

        Can#39;t get Laravel associate to work(無法讓 Laravel 助理工作)
        <tfoot id='ZzAy7'></tfoot>

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

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

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

              1. <legend id='ZzAy7'><style id='ZzAy7'><dir id='ZzAy7'><q id='ZzAy7'></q></dir></style></legend>
                  本文介紹了無法讓 Laravel 助理工作的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我不太確定我是否理解 associate 方法在 Laravel 中.我理解這個想法,但我似乎無法讓它發揮作用.

                  I'm not quite sure if I understand the associate method in Laravel. I understand the idea, but I can't seem to get it to work.

                  使用這個(蒸餾)代碼:

                  With this (distilled) code:

                  class User
                  {
                  
                      public function customer()
                      {
                          return $this->hasOne('Customer');
                      }
                  
                  }
                  
                  class Customer
                  {
                  
                      public function user()
                      {
                          return $this->belongsTo('User');
                      }
                  
                  }
                  
                  $user = new User($data);
                  $customer = new Customer($customerData);
                  
                  $user->customer()->associate($customer);
                  

                  當我嘗試運行它時,我收到一個 Call to undefined method IlluminateDatabaseQueryBuilder::associate().

                  I get a Call to undefined method IlluminateDatabaseQueryBuilder::associate() when I try to run this.

                  據我所知,我完全按照文檔中的說明進行操作.

                  From what I can read, I do it exactly as is stated in the docs.

                  我做錯了什么?

                  推薦答案

                  我不得不承認,當我第一次開始使用 Laravel 時,我必須始終如一地參考文檔的部分關系,甚至在某些情況下我不太對勁.

                  I have to admit that when I first started using Laravel the relationships where the part that I had to consistently refer back to the docs for and even then in some cases I didn't quite get it right.

                  為了幫助您,associate() 用于更新 belongsTo() 關系.查看您的代碼,從 $user->customer() 返回的類是一個 hasOne 關系類,上面沒有關聯方法.

                  To help you along, associate() is used to update a belongsTo() relationship. Looking at your code, the returned class from $user->customer() is a hasOne relationship class and will not have the associate method on it.

                  如果你反過來做.

                  $user = new User($data);
                  $customer = new Customer($customerData);
                  
                  $customer->user()->associate($user);
                  $customer->save();
                  

                  它會像 $customer->user()belongsTo 關系一樣工作.

                  It would work as $customer->user() is a belongsTo relationship.

                  反過來,您需要先保存用戶模型,然后將客戶模型保存到其中,例如:

                  To do this the other way round you would first save the user model and then save the customer model to it like:

                  $user = new User($data);
                  $user->save();
                  
                  $customer = new Customer($customerData);
                  $user->customer()->save($customer);
                  

                  可能沒有必要先保存用戶模型,但我總是這樣做,不知道為什么.

                  It may not be necessary to save the user model first but I've just always done that, not sure why.

                  這篇關于無法讓 Laravel 助理工作的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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='i7sVE'></tfoot>
                  <legend id='i7sVE'><style id='i7sVE'><dir id='i7sVE'><q id='i7sVE'></q></dir></style></legend>
                    <bdo id='i7sVE'></bdo><ul id='i7sVE'></ul>
                    1. <small id='i7sVE'></small><noframes id='i7sVE'>

                        <tbody id='i7sVE'></tbody>

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

                          • 主站蜘蛛池模板: Copeland/谷轮压缩机,谷轮半封闭压缩机,谷轮涡旋压缩机,型号规格,技术参数,尺寸图片,价格经销商 CTP磁天平|小电容测量仪|阴阳极极化_双液系沸点测定仪|dsj电渗实验装置-南京桑力电子设备厂 | 纯化水设备-纯水设备-超纯水设备-[大鹏水处理]纯水设备一站式服务商-东莞市大鹏水处理科技有限公司 | 在线浊度仪_悬浮物污泥浓度计_超声波泥位计_污泥界面仪_泥水界面仪-无锡蓝拓仪表科技有限公司 | 深圳美安可自动化设备有限公司,喷码机,定制喷码机,二维码喷码机,深圳喷码机,纸箱喷码机,东莞喷码机 UV喷码机,日期喷码机,鸡蛋喷码机,管芯喷码机,管内壁喷码机,喷码机厂家 | 灰板纸、灰底白、硬纸板等纸品生产商-金泊纸业 | 讲师宝经纪-专业培训机构师资供应商_培训机构找讲师、培训师、讲师经纪就上讲师宝经纪 | 无线遥控更衣吊篮_IC卡更衣吊篮_电动更衣吊篮配件_煤矿更衣吊篮-力得电子 | 济南玻璃安装_济南玻璃门_济南感应门_济南玻璃隔断_济南玻璃门维修_济南镜片安装_济南肯德基门_济南高隔间-济南凯轩鹏宇玻璃有限公司 | 防水套管|柔性防水套管|伸缩器|伸缩接头|传力接头-河南伟创管道 防水套管_柔性防水套管_刚性防水套管-巩义市润达管道设备制造有限公司 | 变色龙PPT-国内原创PPT模板交易平台 - PPT贰零 - 西安聚讯网络科技有限公司 | 超声波清洗机_细胞破碎仪_实验室超声仪器_恒温水浴-广东洁盟深那仪器 | 济南网站建设|济南建网站|济南网站建设公司【济南腾飞网络】【荐】 | 美国PARKER齿轮泵,美国PARKER柱塞泵,美国PARKER叶片泵,美国PARKER电磁阀,美国PARKER比例阀-上海维特锐实业发展有限公司二部 | 卡诺亚轻高定官网_卧室系统_整家定制_定制家居_高端定制_全屋定制加盟_定制家具加盟_定制衣柜加盟 | 深圳宣传片制作-企业宣传视频制作-产品视频拍摄-产品动画制作-短视频拍摄制作公司 | 压力控制器,差压控制器,温度控制器,防爆压力控制器,防爆温度控制器,防爆差压控制器-常州天利智能控制股份有限公司 | 网优资讯-为循环资源、大宗商品、工业服务提供资讯与行情分析的数据服务平台 | 河南mpp电力管_mpp电力管生产厂家_mpp电力电缆保护管价格 - 河南晨翀实业 | 便民信息网_家电维修,家电清洗,开锁换锁,本地家政公司 | 铝箔袋,铝箔袋厂家,东莞铝箔袋,防静电铝箔袋,防静电屏蔽袋,防静电真空袋,真空袋-东莞铭晋让您的产品与众不同 | 天津货架厂_穿梭车货架_重型仓储货架_阁楼货架定制-天津钢力仓储货架生产厂家_天津钢力智能仓储装备 | 润滑脂-高温润滑脂-轴承润滑脂-食品级润滑油-索科润滑油脂厂家 | 皮带式输送机械|链板式输送机|不锈钢输送机|网带输送机械设备——青岛鸿儒机械有限公司 | 岸电电源-60HZ变频电源-大功率变频电源-济南诚雅电子科技有限公司 | 单级/双级旋片式真空泵厂家,2xz旋片真空泵-浙江台州求精真空泵有限公司 | 硅PU球场、篮球场地面施工「水性、环保、弹性」硅PU材料生产厂家-广东中星体育公司 | 304不锈钢无缝管_不锈钢管厂家 - 隆达钢业集团有限公司 | 粉末包装机,拆包机厂家,价格-上海强牛包装机械设备有限公司 | 真空冷冻干燥机_国产冻干机_冷冻干燥机_北京四环冻干 | 移动厕所租赁|移动卫生间|上海移动厕所租赁-家瑞租赁 | 高温链条油|高温润滑脂|轴承润滑脂|机器人保养用油|干膜润滑剂-东莞卓越化学 | 美能达分光测色仪_爱色丽分光测色仪-苏州方特电子科技有限公司 | 灰板纸、灰底白、硬纸板等纸品生产商-金泊纸业 | 焊锡丝|焊锡条|无铅锡条|无铅锡丝|无铅焊锡线|低温锡膏-深圳市川崎锡业科技有限公司 | 阳光1号桔柚_无核沃柑_柑橘新品种枝条苗木批发 - 苧金网 | 福州时代广告制作装饰有限公司-福州广告公司广告牌制作,福州展厅文化墙广告设计, | 骁龙云呼电销防封号系统-axb电销平台-外呼稳定『免费试用』 | 北京燃气公司 用户服务中心| ERP企业管理系统永久免费版_在线ERP系统_OA办公_云版软件官网 | 双段式高压鼓风机-雕刻机用真空泵-绍兴天晨机械有限公司 | 安全,主动,被动,柔性,山体滑坡,sns,钢丝绳,边坡,防护网,护栏网,围栏,栏杆,栅栏,厂家 - 护栏网防护网生产厂家 |