Activity feed tutorial way to eager-load relationship by type

Posted 3 years ago by saqueib

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 sign in or create an account to participate in this conversation.