Tables are
User Table:
id
name
email
etc.
Profile Table:
user_id
role
address
city
state
etc.
On tinker i do:
$user = $this->$user->with('Profile')->find(3);
Output is:
App\User {#756
id: 3,
name: "Alejandra Kerluke Jr.",
email: "balistreri.laurel@example.com",
deleted_at: null,
created_at: "2016-06-23 05:12:03",
updated_at: "2016-06-29 11:05:45",
Profile: App\Profile {#768
user_id: 3,
role: "",
address: """
50111 Wendy Row Apt. 732\n
Kingburgh, OR 42164-7189
""",
city: "Manteland",
state: "Vermont",
country: "Belgium",
phone: "1-226-766-4182 x5574",
fax: "1-507-985-3523 x708",
zip: 48446,
status: 0,
deleted_at: null,
created_at: "2016-06-23 05:12:03",
updated_at: "2016-06-23 05:12:03",
},
}
Now i did:
>>> $user->name="YYYYYY"
>>> $user->email='abc@example.com'
>>> $user->profile->role = 'XXXXX'
>>> $user->push();
This throws the error:
Illuminate\Database\QueryException with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'id' in 'where clause' (SQL: update `profiles` set `role` = inspector, `update
d_at= 2016-06-29 11:29:30 where
id` is null)'
I don't know what's wrong with this peace of code. I am new to Laravel and any kind of help will be appreciated.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/29489hA
via IFTTT
Aucun commentaire:
Enregistrer un commentaire