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

I have a similar example to that in the docs.. a comment and post scenario.

I want notifications when comments are added, but I want the post to handle the notifications for it and its children.

If I have the comment touch the post by setting it in the 'touches' model variable, can I get the new comment with a call like this? :

$new_comment = $post->comments()->where('created_at', $post->updated_at)->first();

I imagine it will almost always have the same timestamp, but how could I do this in a way that will always match?

Last updated 3 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

thedamon thedamon Joined 2 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.