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

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

    <tfoot id='D0zu5'></tfoot>

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

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

        laravel 的 updateOrCreate 方法

        laravel updateOrCreate method(laravel 的 updateOrCreate 方法)
        <tfoot id='i5OkX'></tfoot>
          <tbody id='i5OkX'></tbody>
          <bdo id='i5OkX'></bdo><ul id='i5OkX'></ul>

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

            2. <legend id='i5OkX'><style id='i5OkX'><dir id='i5OkX'><q id='i5OkX'></q></dir></style></legend>

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

                  本文介紹了laravel 的 updateOrCreate 方法的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我的方法中有以下代碼,我通過ajax發送到控制器方法:

                  I have the following code in my method which I am sending via ajax to the controller method :

                      $newUser = AppUserInfo::updateOrCreate([
                          'user_id'   => Auth::user()->id,
                          'about'     => $request->get('about'),
                          'sec_email' => $request->get('sec_email'),
                          'gender'    => $request->get("gender"),
                          'country'   => $request->get('country'),
                          'dob'       => $request->get('dob'),
                          'address'   => $request->get('address'),
                          'mobile'    => $request->get('cell_no')
                      ]);
                  

                  dd($request->all()) 給了我:

                  array:8 [
                    "_token" => "fHeEPfTvgMD3FpIBmmc6DmKXFaiuWKZEiOhg6twQ"
                    "about" => "Some about me."
                    "sec_email" => "example@gmail.com"
                    "country" => "Priority highest"
                    "gender" => "male"
                    "dob" => "12/12/1990"
                    "address" => "Some address"
                    "cell_no" => "234234234"
                  ]
                  

                  這是完美的.

                  Jquery 代碼:

                  $('#submit-editProfile-form').on('click', function() {
                      var profileEditForm = $("#edit-user-profile");
                      var formData = $('#edit-user-profile').serialize();
                      profileEditForm.on('submit', function(e){
                          e.preventDefault();
                          $.ajaxSetup({
                              headers: {
                                  'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                              }
                          });
                          $.ajax({
                              url:'/freelance/edit-userProfile-info',
                              type:'POST',
                              data:formData,
                              error: function (data) {
                                 console.log('Error');
                              }
                          });
                      }).submit();
                  });
                  

                  現在的問題是我的表中有一條記錄,但上面的代碼創建了另一個記錄,第二個是它在每次單擊按鈕(請求)時創建乘以兩條記錄.

                  推薦答案

                  在您的用例中,您應該指定第二個參數.第一個表示匹配的條件,第二個用于指定要更新的字段.

                  In your use case, you should specify a second parameter. The first indicates the conditions for a match and second is used to specify which fields to update.

                  $newUser = AppUserInfo::updateOrCreate([
                      //Add unique field combo to match here
                      //For example, perhaps you only want one entry per user:
                      'user_id'   => Auth::user()->id,
                  ],[
                      'about'     => $request->get('about'),
                      'sec_email' => $request->get('sec_email'),
                      'gender'    => $request->get("gender"),
                      'country'   => $request->get('country'),
                      'dob'       => $request->get('dob'),
                      'address'   => $request->get('address'),
                      'mobile'    => $request->get('cell_no')
                  ]);
                  

                  以下是文檔中的示例:https://laravel.com/docs/5.4/eloquent

                  // If there's a flight from Oakland to San Diego, set the price to $99.
                  // If no matching model exists, create one.
                  $flight = AppFlight::updateOrCreate(
                      ['departure' => 'Oakland', 'destination' => 'San Diego'],
                      ['price' => 99]
                  );
                  

                  這篇關于laravel 的 updateOrCreate 方法的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 找不到驅動程序)

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

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

                          • <legend id='wwwdI'><style id='wwwdI'><dir id='wwwdI'><q id='wwwdI'></q></dir></style></legend>
                            主站蜘蛛池模板: 国产精品一区二区av | 精品欧美一区二区三区久久久 | 97操操| 亚洲乱码国产乱码精品精98午夜 | 久久久免费电影 | 亚洲一区中文字幕 | av在线免费播放 | 欧美精品一区二区三区在线四季 | 日韩中文字幕一区 | 在线一区视频 | 日韩有码一区 | 伦理片97 | 成人在线看片 | 在线黄 | 欧美日韩国产精品一区二区 | 欧美老妇交乱视频 | 日本久久一区二区三区 | www,黄色,com| 成人国产精品久久 | 男女污污动态图 | 亚洲 日本 欧美 中文幕 | 亚洲精品一区二区三区蜜桃久 | 狠狠色香婷婷久久亚洲精品 | 国产乱码精品一区二区三区五月婷 | 欧美午夜一区二区三区免费大片 | 一本岛道一二三不卡区 | 91精品国产综合久久精品图片 | 国产精品久久久久久婷婷天堂 | 欧美成人免费在线视频 | 国产精品视频在线观看 | 欧美精品一区二区三区在线播放 | 91成人在线 | 日韩一级黄色毛片 | 欧美黄色大片在线观看 | 国产一区二区不卡 | 一区精品国产欧美在线 | 狠狠操电影| 国产视频在线观看一区二区三区 | 午夜视频网站 | 亚洲区中文字幕 | 91精品国产91久久久久久 |