Everest
Everest

Reputation: 23

Laravel "Invalid datetime format :1366"

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".

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 into profiles (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))

Actually I think it arise because of inserting image, but I could not solve it.

Please suggest me how to solve this.

Screenshot of error

Upvotes: 1

Views: 7348

Answers (2)

Mahe Karim
Mahe Karim

Reputation: 47

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.

Hope You! Got It.

Upvotes: 0

jahsome
jahsome

Reputation: 1481

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.

Upvotes: 1

Related Questions