I am trying to push an object to a user model.
The user model, has the below parameter:
User.posts.
Where posts is an array.
First I tried the below:
$user->posts()->save($Post);
This didn't add the new Post object to the user.posts (but it didn't return an error).
I also tried $user->posts()->push($Post);
and $user->posts = array_add($Post)...but this is requiring three parameters.
Sorry, I am new to laravel...How to push an object instance to the array (posts) of the user model?
Thanks,
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire