Hi,
A couple of weeks ago a wrote about an example app that showed how to build activity feeds and news feeds with Laravel and get-stream/stream-php.
From that experience I decided to build a Laravel package; the package allows to keep in sync model instances with user feeds (by just using a trait) and comes with some Laravel niceties (eg. a base view structure; a FeedManager facade).
Hi! I'm trying to implement this package but I have trouble trying to use it with Laravel. I'm creating an app which organizes student events and I have a class that is called StudentEvent. Each time a user creates an event I want it to be tracked as an activity. How might I implement get-stream to do this for me?
The user which has created the event is not a relationship. But only stored as an id in the student_event table in a column named "created_by". E.g. created_by = 1.
Hi guys,
I fixed the links, did not notice the issue with Markdown parsing :/
@cederman I think the easiest way to do this is use the Activity trait in the StudentEvent
class StudentEvent extends Eloquent {
use GetStream\StreamLaravel\Eloquent\ActivityTrait;
public function activityActor()
{
return $this->created_by;
}
}
With this in place, every time a StudentEvent is created, an activity will be pushed to the feed of the user that created it (and its follower feeds).
The activityActor method tells the ActivityTrait what the value for the actor field will be; is there any particular reason for you not to have a relationship defined on created_by? Feel free to contact me on my personal email if you need more details about this (tommaso@getstream.io)
Thanks for the fast reply @tbarbugli!
I implemented your edits but I can't confirm it is working just yet. I add a new StudentEvent but I can't confirm from the dashboard on getstream.io if It actually registers the event being created.
I tried with the following code snippet to see if I get any output (correct me if I misunderstood something):
@tbarbugli Is there a way to configure some options to filter the activities when reading them from feeds? Say, only get activities with certain attributes from the feed?