Support the ongoing development of Laravel.io →
posted 10 years ago
Eloquent

If I use $post->comments()->save($comment) to add a new comment to a post, why does $post->comments not automatically get updated to include that new post? I only see the post in $post->comments if I either re-load $post from the database, or if I call $post->load('comments').

Shouldn't the save() function automatically update $post->comments? Am I doing something wrong, or is this the way it is supposed to work?

Last updated 2 years ago.
0

It's the way it works.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

orrd orrd Joined 3 Feb 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.