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

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

      <tfoot id='ab8Kh'></tfoot>

    1. <small id='ab8Kh'></small><noframes id='ab8Kh'>

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

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

        調用未定義的方法 IlluminateDatabaseQueryBuilder::asso

        Call to undefined method IlluminateDatabaseQueryBuilder::associate()(調用未定義的方法 IlluminateDatabaseQueryBuilder::associate())

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

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

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

                1. <tfoot id='d3dRR'></tfoot>

                    <tbody id='d3dRR'></tbody>
                  本文介紹了調用未定義的方法 IlluminateDatabaseQueryBuilder::associate()的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  參考:如何更新Laravel 4 中現有的 Eloquent 關系?

                  $userinfo = Userinfo::find($id);
                  User::find($id)->userinfo()->associate($userinfo)->save();
                  

                  我收到錯誤:Call to undefined method IlluminateDatabaseQueryBuilder::associate()

                  這里是整個方法:

                  public function saveUser($id)
                  {
                      $user = User::find($id);
                  
                      $userdata = Input::all();
                  
                      $rules = array(
                          'email' => 'required|email',
                          'state' => 'size:2',
                          'zip'   => 'size:5',
                          'phone' => array('regex:/^(?([0-9]{3}))?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$/')
                      );
                  
                      $validator = Validator::make($userdata, $rules);
                  
                      if ($validator->passes())
                      {
                          if ($userdata['email'] !== $user->email)
                          {
                              $rules = array('email' => 'unique:users');
                              $validator = Validator::make($userdata, $rules);
                              if ($validator->fails()) return Redirect::route('admin.user.edit', array('user' => $user))
                                  ->with('error', 'Specified email already exists.');
                          }
                  
                          $user->email                = $userdata['email'];
                          $user->firstname            = $userdata['firstname'];
                          $user->lastname             = $userdata['lastname'];
                  
                          $userinfoArray = array(
                              'address'   => $userdata['address'],
                              'city'      => $userdata['city'],
                              'state'     => $userdata['state'],
                              'zip'       => $userdata['zip'],
                              'phone'     => preg_replace('/[^0-9]/', '', $userdata['phone'])
                          );
                  
                          $user->save();
                  
                          if (!$user->userinfo)
                          {
                              $userinfo = new Userinfo($userinfoArray);
                              $userinfo = $user->userinfo()->save($userinfo);
                          }
                          else
                          {
                              $userinfo = Userinfo::find($id);
                              User::find($id)->userinfo()->associate($userinfo)->save();
                              //$user->userinfo()->update($userinfoArray);
                          }
                  
                          return Redirect::route('admin.user.detail', array('id' => $id))
                              ->with('success', 'User updated.');
                      }
                  
                      return Redirect::route('admin.user.edit', array('id' => $id))
                          ->withInput()
                          ->withErrors($validator);
                  }
                  

                  推薦答案

                  associate() 是belongsTo 關系的一個方法,但從上面看來,您試圖通過hasOne 關系調用它.

                  associate() is a method of the belongsTo relationship, but it looks like from the above you are trying to call it via the hasOne relationship.

                  我只是猜測,因為您沒有提供您雄辯的模型類代碼,所以無法看到您是如何準確設置關系的,但如果您有:

                  I am just guessing as you have not provided your eloquent model class code so can't see how you have set the relationships exactly, but if you have:

                  class User extends Eloquent {
                      public function userinfo()
                      {
                          return $this->hasOne('Userinfo');
                      }
                  }
                  
                  class Userinfo extends Eloquent {
                  
                      public function user() {
                          return $this->belongsTo('User');
                      }
                  }
                  

                  然后需要針對 Userinfo 調用關聯,因為它具有關聯 () 方法附加到的belongsTo 關系.

                  Then associate needs to be called against Userinfo as this has the belongsTo relationship to which the associate() method is attached.

                  例如

                  $user = User::find(4);      
                  $userinfo = UserInfo::find(1);
                  
                  $userinfo->user()->associate($user);
                  $userinfo->save();
                  

                  將user_info表中的外鍵user_id設置為$user對象的id.

                  Will set the foreign key user_id in the user_info table to the id of the $user object.

                  看看你上面的代碼,這似乎不是你真正想要做的,

                  Looking at your above code it doesn't appear that this is what you are actually trying to do and that the

                  $user->userinfo()->update($userinfoArray);
                  

                  您注釋掉的調用實際上會執行您似乎想要實現的目標,即更新與當前用戶相關的用戶信息(如果該用戶已存在).

                  call which you have commented out will in fact do what you seem to be trying to achieve, which is to update the userinfo that is related to the current user if that user already exists.

                  希望這會有所幫助.

                  格倫

                  這篇關于調用未定義的方法 IlluminateDatabaseQueryBuilder::associate()的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 找不到驅動程序)
                    <bdo id='NS4l0'></bdo><ul id='NS4l0'></ul>
                      <tbody id='NS4l0'></tbody>

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

                      <tfoot id='NS4l0'></tfoot>

                          • <legend id='NS4l0'><style id='NS4l0'><dir id='NS4l0'><q id='NS4l0'></q></dir></style></legend>
                          • <i id='NS4l0'><tr id='NS4l0'><dt id='NS4l0'><q id='NS4l0'><span id='NS4l0'><b id='NS4l0'><form id='NS4l0'><ins id='NS4l0'></ins><ul id='NS4l0'></ul><sub id='NS4l0'></sub></form><legend id='NS4l0'></legend><bdo id='NS4l0'><pre id='NS4l0'><center id='NS4l0'></center></pre></bdo></b><th id='NS4l0'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='NS4l0'><tfoot id='NS4l0'></tfoot><dl id='NS4l0'><fieldset id='NS4l0'></fieldset></dl></div>
                          • 主站蜘蛛池模板: 精品视频在线免费观看 | 久久久久久久久精 | 日韩欧美国产精品 | 人人干视频在线 | 日韩欧美综合在线视频 | 国产精品一区一区三区 | 成人在线观看亚洲 | 99视频在线 | 精品久久一区 | 亚洲精品福利视频 | 日韩在线播放第一页 | 国产免费一区二区 | 久久久国产一区 | 亚洲二区在线观看 | 一区二区三区韩国 | 亚洲一区网站 | 成人毛片一区二区三区 | 国产精品久久久久无码av | 8x国产精品视频一区二区 | 久久精片 | 久草网站| 中文字幕在线精品 | 91久久精品一区二区三区 | 久久久精彩视频 | 天天色天天射天天干 | www.亚洲视频| 久久新 | 99热99| 国产精品一区二区无线 | 一区二区三区视频在线免费观看 | 欧美成人精品一区二区三区 | 久久久久亚洲精品 | 欧美一区二区三区在线看 | xx性欧美肥妇精品久久久久久 | 亚洲国产成人av好男人在线观看 | 国产精品电影网 | 中文字幕一区二区不卡 | 色资源在线| 黄色精品| 国产一级片免费在线观看 | 久久一区二区精品 |