Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

a0e's avatar
Level 4

Inserting into a table with alias

in one of my tables "courses" i have a value "Teacher_id" which is a foreign key that references "id" on "users" table. when i try to do mass assignment for the request as follows: auth()->users()->courses()->create($request->course)

it throws an error because it cant find users_id, I solved this by assigning each value separately but im looking to make life easier and do it with "mass assignment" . Any suggestions?

0 likes
2 replies
a0e's avatar
Level 4

ohhhh i totally forgot aboutt that thank you so much!!^_^

Please or to participate in this conversation.