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

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

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

        一次創建新的記錄和關系

        Creating new record and relationships in one go(一次創建新的記錄和關系)
          <tbody id='MKcA8'></tbody>
            <tfoot id='MKcA8'></tfoot>

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

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

            <i id='MKcA8'><tr id='MKcA8'><dt id='MKcA8'><q id='MKcA8'><span id='MKcA8'><b id='MKcA8'><form id='MKcA8'><ins id='MKcA8'></ins><ul id='MKcA8'></ul><sub id='MKcA8'></sub></form><legend id='MKcA8'></legend><bdo id='MKcA8'><pre id='MKcA8'><center id='MKcA8'></center></pre></bdo></b><th id='MKcA8'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='MKcA8'><tfoot id='MKcA8'></tfoot><dl id='MKcA8'><fieldset id='MKcA8'></fieldset></dl></div>
            • <bdo id='MKcA8'></bdo><ul id='MKcA8'></ul>
                1. 本文介紹了一次創建新的記錄和關系的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我有以下基本架構:

                  玩家

                  id
                  name
                  

                  個人資料

                  id
                  player_id
                  email
                  

                  子集

                  id
                  profile_id
                  alias
                  

                  我的印象是在創建新記錄時可以進行以下操作:

                  I was under the impression the following operation was possible when creating a new record:

                  Player::create([
                      'name' => 'Player 1',
                      'profile.email' => 'player1@email.com',
                      'profile.subset.alias' => 'Player 1 alias'
                  ]);
                  

                  既然這段代碼好像不行,那么有沒有辦法把關系記錄和create方法一起保存?

                  Since this code doesn't seem to work, is there anyway to save relationships records together with the create method?

                  推薦答案

                  基本上,您不能像看起來那么容易做到這一點.

                  Basically, you can't do this as easy as it looks.

                  在文檔中,所有相關模型都是在創建基礎模型之后創建的

                  In the docs, all related models are created after the base model is created

                  $profile = new Profile(array('email' => 'player1@email.com','alias'=>'Player 1 alias'));
                  
                  $player = new Player(array('name'=>'Player 1'));
                  
                  $player = $post->profile()->save($profile);
                  

                  但是,如果你真的想一口氣搞定,你可以覆蓋Player模型中的save()方法:

                  However , if you really want to do it in one go, you can overwrite the save() method in the Player model :

                  public function save(){
                          Database::transaction(function() {
                                      $profileModel = new Profile($this->profile);
                  
                                      parent::save();
                  
                                      $this->profile()->insert($profileModel);
                  
                                  });
                  }
                  

                  然后您將數組傳遞給 Player 方法,例如:

                  You will then pass the array to the Player method like :

                  array(
                  name='Player name',
                  profile=>array(
                           email=>'player1@email.com',
                           subset=>array(
                             alias=>'Player 1 alias'
                            )
                  );
                  

                  雖然這不是推薦的操作.

                  Although this is not a recommended action.

                  請閱讀有關如何保存 Eloquent 模型和關系的更多信息:

                  Please read more about how to save the Eloquent models and relationships :

                  教程 1教程 2

                  任何地方都建議先創建基礎模型,再創建相關模型.

                  Everywhere is suggested to create the base model first, then the related models.

                  這篇關于一次創建新的記錄和關系的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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的訪問被拒絕)
                2. <i id='MNE3p'><tr id='MNE3p'><dt id='MNE3p'><q id='MNE3p'><span id='MNE3p'><b id='MNE3p'><form id='MNE3p'><ins id='MNE3p'></ins><ul id='MNE3p'></ul><sub id='MNE3p'></sub></form><legend id='MNE3p'></legend><bdo id='MNE3p'><pre id='MNE3p'><center id='MNE3p'></center></pre></bdo></b><th id='MNE3p'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='MNE3p'><tfoot id='MNE3p'></tfoot><dl id='MNE3p'><fieldset id='MNE3p'></fieldset></dl></div>
                  1. <tfoot id='MNE3p'></tfoot>
                        <tbody id='MNE3p'></tbody>

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

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

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

                            主站蜘蛛池模板: 中文字幕 国产精品 | 午夜影院在线观看版 | 亚洲香蕉在线视频 | 日韩中文字幕一区二区 | 91精品国产综合久久久亚洲 | 欧美精品在线观看 | 亚洲成人日韩 | 高清视频一区二区三区 | 久草日韩 | 国产婷婷色综合av蜜臀av | 激情毛片 | 中文字幕不卡在线观看 | 国产在线麻豆精品入口 | 亚洲一区电影 | 国产精品成人国产乱一区 | 成av人电影在线 | av网站免费看 | 自拍视频国产 | 久优草 | 国产精品乱码一区二区三区 | 免费午夜视频 | 亚洲激精日韩激精欧美精品 | 日韩一区二区三区在线观看 | 91av在线电影| 高清久久久 | 欧美淫片 | 国产91在线播放精品91 | 免费麻豆视频 | 精品一区二区久久久久久久网站 | 狠狠热视频 | 人人草人人干 | 黄色免费网站在线看 | 亚洲国产精久久久久久久 | 日韩一区二区三区在线 | 欧美精品一区二区三区在线播放 | 国产精品视频一区二区三区四区国 | 国产高清美女一级a毛片久久w | 91精品国产91久久久久久最新 | 午夜视频一区二区 | a在线视频 | 国产乱码精品一品二品 |