Level 7
Activity::with('subject')->whereSubjectType('<comment class>')->get();
That should work fine.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I followed @JeffreyWay tutorial for activity feed https://laracasts.com/lessons/build-an-activity-feed-in-laravel
Everything works, but I wanted to eager load some relations, so I did this
Activity::with('subject')->get();
which is giving me all thing mixed with Post, Comment all in one result. I wanted to loaded only Post or Comment. like
Activity::with('post')->get();
Activity::with('comment')->get();
How could we do it. should i use where clause to limit the activity by App\Post, or there any other way
Please or to participate in this conversation.