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

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

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

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

    1. <legend id='kRPZn'><style id='kRPZn'><dir id='kRPZn'><q id='kRPZn'></q></dir></style></legend>
    2. <tfoot id='kRPZn'></tfoot>

      更新 Laravel 5.3 中的一對多關系

      Updating One to many relation in laravel 5.3(更新 Laravel 5.3 中的一對多關系)
              <bdo id='tOsTA'></bdo><ul id='tOsTA'></ul>

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

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

                <tfoot id='tOsTA'></tfoot>
                本文介紹了更新 Laravel 5.3 中的一對多關系的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我想更新一對多關系.例如,我有一個名為 Product

                I want to update a one to many relationship. For example I have a model called Product

                class Product extends Model
                {
                    protected $primaryKey = 'product_id';
                    public $timestamps = FALSE;
                
                    public function Size(){
                        return $this->hasMany('AppSize');
                    }
                
                }
                

                和一個名為 Size

                class Size extends Model
                {
                    public $timestamps = FALSE;
                    protected $fillable = ['product_id','size'];
                
                    public function Product(){
                        return $this->belongsTo('AppProduct');
                    }
                

                這是我的控制器:

                public function update(Request $request){
                    for($i = 1; $i <= $sizeCounter; $i++){
                        $selectedSize = "size_$i";
                
                        if($request->$selectedSize){
                            $array = ['size'=> $request->$selectedSize];
                        }
                    }
                
                    $Size = Size::where('product_id' , $request->id)->update($array);
                }
                

                但是它正在做什么用選定的產品 id 更新所有尺寸記錄到最后一個輸入者尺寸.我想用選定的不同尺寸而不是最后選擇的尺寸更新所有尺寸

                But what it is doing updating all the records of size with the selectedd product id to the last enterder size. I want to update all the sizes with the slected diffrent sizes not the last selected sizes

                如何更新特定產品的尺寸.像多對多關系的同步方法一樣,有什么方法可以更新記錄.

                How to update the sizes of a particular product. Like many to many relations' sync method is there any way to update the records.

                推薦答案

                你在循環中覆蓋你的$array.在 for 循環之后,$array 可能是最后一個大小.

                You override your $array in the loop. After the for loop, $array has possibly the last size.

                總的來說,您的查詢是正確的,但它與執行的位置有關.它應該如下所示:

                In general, your query is correct, but it's about the place of execute. It should be like below:

                if (isset($request->$selectedSize)) { // or is_int() ?
                    $Size = Size::where('product_id', $request->id)->update(['size'=> $request->$selectedSize]);
                }
                

                這篇關于更新 Laravel 5.3 中的一對多關系的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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的訪問被拒絕)
              • <legend id='LqvD9'><style id='LqvD9'><dir id='LqvD9'><q id='LqvD9'></q></dir></style></legend>
                  <bdo id='LqvD9'></bdo><ul id='LqvD9'></ul>

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

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

                    <tbody id='LqvD9'></tbody>
                • <tfoot id='LqvD9'></tfoot>

                        1. 主站蜘蛛池模板: 久久99国产精一区二区三区 | 久久精品视频一区二区三区 | 欧美日一区二区 | 久久婷婷国产香蕉 | 在线日韩欧美 | 国产精品99久久久精品免费观看 | 国产激情视频在线 | 国产精品一区二区三区99 | 亚洲午夜av久久乱码 | 国产视频91在线 | 亚洲一区二区三区四区五区午夜 | 久久99精品国产自在现线小黄鸭 | 免费午夜视频 | 亚洲日本中文 | 成人国产精品一级毛片视频毛片 | 一区二区三区中文字幕 | 在线国产欧美 | 欧美一区二区在线播放 | 国产网站在线免费观看 | 欧美精品一区久久 | 久久99精品国产麻豆婷婷 | 久久精品久久久久久 | 婷婷色国产偷v国产偷v小说 | 久久久久国产一区二区三区四区 | 亚洲乱码一区二区三区在线观看 | 久久久久成人精品免费播放动漫 | 成人免费视屏 | 国产一区二区三区在线看 | 999久久| 久久高清 | 一区二区中文字幕 | 日本精品在线一区 | 99re热精品视频国产免费 | 中文字幕 在线观看 | 国产精品视频一区二区三区不卡 | 精品日韩一区二区 | 久久久2o19精品 | 亚州精品天堂中文字幕 | 婷婷在线网站 | 91中文字幕在线 | 9色网站|