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

保存模型時 Laravel 模型尾隨數據

Laravel model Trailing Data when save the model(保存模型時 Laravel 模型尾隨數據)
本文介紹了保存模型時 Laravel 模型尾隨數據的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我有一些這樣的代碼

    $editStuState = StuAtt::where('studentId' , '=' , $id)->first();
    $editStuState -> leave +=1;
    $editStuState -> present = $editStuState -> present-1;
    $editStuState->update();
                            //OR
    $editStuState->save();
    return 'this is good';

我無法保存或更新我的數據,當我刪除更新和保存相關行時,它可以打印文本.

I can't save or Update my data, when I remove Update and Save related line it can print text.

這是dd($editStuState)數據

StuAtt {#382 ▼
  #table: "stu_attendance"
  #connection: "mysql"
  #primaryKey: "id"
  #keyType: "int"
  +incrementing: true
  #with: []
  #withCount: []
  #perPage: 15
  +exists: true
  +wasRecentlyCreated: false
  #attributes: array:7 [▼
    "id" => "7"
    "studentId" => "1"
    "present" => "2"
    "absent" => "1"
    "leave" => "10"
    "created_at" => "2018-04-16 11:17:41.176898"
    "updated_at" => "2018-04-16 06:47:41.000000"
  ]
  #original: array:7 [▼
    "id" => "7"
    "studentId" => "1"
    "present" => "2"
    "absent" => "1"
    "leave" => "10"
    "created_at" => "2018-04-16 11:17:41.176898"
    "updated_at" => "2018-04-16 06:47:41.000000"
  ]
  #changes: []
  #casts: []
  #dates: []
  #dateFormat: null
  #appends: []
  #dispatchesEvents: []
  #observables: []
  #relations: []
  #touches: []
  +timestamps: true
  #hidden: []
  #visible: []
  #fillable: []
  #guarded: array:1 [?]
}

我也從 laravel 5.6 得到這個錯誤

I also got this error form laravel 5.6 it

InvalidArgumentException
Trailing data

推薦答案

如果您使用 Postgres,則必須向模型添加一些行.這是因為 Postgres 中的 TIME WITH TIMEZONE.

If you are using Postgres you have to add some lines to your Model(s). It happens because of TIME WITH TIMEZONE in Postgres.

另請閱讀 Date Mutators 因為 Laravel 已經支持此功能,只需在您的模型中放置以下行以覆蓋該模型的默認日期格式:https://laravel.com/docs/5.7/eloquent-mutators#date-mutators

Please also read Date Mutators as Laravel already has support for this baked in, simply put below line in your Model to override the default dateFormat for that model: https://laravel.com/docs/5.7/eloquent-mutators#date-mutators

轉到您的應用程序/模型(在 app 文件夾下,exp. User,SomeModel)添加以下行:

Go to your App/Model (under app folder, exp. User, SomeModel) add below line:

protected $dateFormat = 'Y-m-d H:i:sO';

最佳

這篇關于保存模型時 Laravel 模型尾隨數據的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Magento products by categories(按類別劃分的 Magento 產品)
Resource interpreted as image but transferred with MIME type text/html - Magento(資源被解釋為圖像但使用 MIME 類型 text/html 傳輸 - Magento)
Is there an event for customer account registration in Magento?(Magento 中是否有客戶帳戶注冊事件?)
Magento addFieldToFilter: Two fields, match as OR, not AND(Magento addFieldToFilter:兩個字段,匹配為 OR,而不是 AND)
quot;Error 404 Not Foundquot; in Magento Admin Login Page(“未找到錯誤 404在 Magento 管理員登錄頁面)
Get Order Increment Id in Magento(在 Magento 中獲取訂單增量 ID)
主站蜘蛛池模板: 自拍偷拍中文字幕 | 国产高清一区二区三区 | 亚洲国产视频一区二区 | 精品一区二区久久久久久久网站 | 欧美第一区 | 亚洲小视频在线观看 | 天天操夜夜拍 | 午夜一区 | 色婷婷精品国产一区二区三区 | 久久伊人影院 | 精品亚洲一区二区 | 久久久资源 | 欧美无乱码久久久免费午夜一区 | 久久99深爱久久99精品 | 国产欧美精品一区二区 | 亚洲精品一区二区三区丝袜 | 日本淫视频 | 久久伊人精品 | 欧美五月婷婷 | 精品一级 | 91成人影院 | 久久精品国产一区二区三区 | 成人午夜视频在线观看 | h小视频| 国产一区二区视频在线 | 国产综合一区二区 | 国产高清免费 | 精品中文字幕一区二区三区 | 欧美a级网站 | 久久精品免费一区二区三 | 中文字幕亚洲欧美 | 天天操夜夜爽 | 国产精品久久久久久久久 | 国产一区二区三区亚洲 | 一区免费 | 久久高清国产视频 | 精品不卡| 日韩a在线 | 久久久久亚洲国产| 成人影音| 国产在线视频一区 |