Basic question regarding relationships in a resource
I have a Post resource, that has a user_id column, and in my form method I have this array:
How can I automatically save the current authenticated user in the user_id? I have searched the documentation and tried it on the CreatePost class with the mutateFormDataBeforeCreate method but sill doesn't work.
4 Replies
Hi mate, try this one inside your related model create this function
Let me know if you found any issues
Cheers!
You also can try by using Laravel Events and insert it to your related model.
Hey thanks for your help, I have tried that but did not work
thanks I went with this