Marcus Lee
Marcus Lee

Reputation: 51

A stream method for all activities

I'm using stream-laravel to add the stream in but I see that it configured to use user. So how could I go about using the method to read every single activity on the site?

Upvotes: 3

Views: 179

Answers (1)

Dwight Gunning
Dwight Gunning

Reputation: 2525

It's fairly common and easy to make use of a separate global feed alongside all the unique topic or user feeds in an app.

When adding activities to a feed, there is an optional parameter to instruct Stream that the activity should also be copied to one or more other feeds. See "Targeting Using the "TO" Field" in the docs.

The stream-laraval library supports this via a hook on the Eloquent parent model: ActivityTrait.activityNotify(). Just return a single-time array containing the name of your global feed.

class MyActivity extends Eloquent {
  use GetStream\StreamLaravel\Eloquent\ActivityTrait;

public function activityNotify()
{
  return array('global_feed');
}

If you're looking for other examples, there is also section on "notifications" in the README.md. In that case there are individual notification feeds for each user and they're obtained via FeedManager.getNotificationFeed(). So you've got some flexibility there.

Upvotes: 2

Related Questions