Laravel“无效的日期时间格式:1366”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/48506716/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel "Invalid datetime format :1366"
提问by Everest
Actually I was making a blog with Laravel following a Youtube tutorial (Laravel 5.5). I was adding profile page there was "Name, Designation, Profile pic". I got error as "Invalid datetime format:1366".
实际上,我是按照 Youtube 教程(Laravel 5.5)用 Laravel 制作博客的。我正在添加个人资料页面,那里有“姓名,名称,个人资料图片”。我收到错误消息“无效的日期时间格式:1366”。
Illuminate \ Database \ QueryException (22007)
SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: '{"id":1,"name":"Sujan Nepal","email":"[email protected]","created_at":"2018-01-26 16:18:56","updated_at":"2018-01-26 16:18:56"}' for column 'user_id' at row 1 (SQL: insert intoprofiles
(user_id
,name
,designation
,profile_pic
,updated_at
,created_at
) values ({"id":1,"name":"Sujan Nepal","email":"[email protected]","created_at":"2018-01-26 16:18:56","updated_at":"2018-01-26 16:18:56"}, Sujan Nepal, Developer, http://localhost/myblog/public/uploads/IMG_0251.JPG, 2018-01-29 16:53:31, 2018-01-29 16:53:31))
Illuminate \ Database \ QueryException (22007)
SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: '{"id":1,"name":"Sujan尼泊尔","email":"[email protected]" ,"created_at":"2018-01-26 16:18:56","updated_at":"2018-01-26 16:18:56"}' 用于第 1 行的“user_id”列(SQL:插入profiles
(user_id
,name
,designation
,profile_pic
,updated_at
,created_at
) 值 ({"id":1,"name":"Sujan尼泊尔","email":"[email protected]","created_at":"2018-01-26 16:18: 56","updated_at":"2018-01-26 16:18:56"},Sujan尼泊尔,开发者,http://localhost/myblog/public/uploads/IMG_0251.JPG,2018-01-2916:53 :31,2018-01-29 16:53:31))
Actually I think it arise because of inserting image, but I could not solve it.
其实我认为它是由于插入图像而出现的,但我无法解决它。
Please suggest me how to solve this.
请建议我如何解决这个问题。
回答by jakeharris
Based on the code in your comments, you have this line:
根据您评论中的代码,您有这一行:
$profiles->user_id = Auth::user();
That should instead be:
那应该是:
$profiles->user_id = Auth::user()->id;
What's happening here is you're setting the user_id
attribute to the entire User
object returned from Auth::user()
. The object probably uses toString()
when it hits the database driver which looks like it serializes into a json string.
这里发生的事情是您将user_id
属性设置为User
从Auth::user()
. 该对象可能toString()
在遇到数据库驱动程序时使用,该驱动程序看起来像是序列化为 json 字符串。
回答by Mahe Karim
For New Comer Like Me , You have to Check
对于像我这样的新人,你必须检查
{{ $party->id }}
Party variable from Party Model. You have to pass the
派对模型中的派对变量。你必须通过
id
with this. CHeck sure in your blade. Just Pass The
有了这个。检查您的刀片。只是通过
id through variable.
id 通过变量。
Hope You! Got It.
希望你!知道了。