spoon

A simple activity feed

Posted 3 years ago by spoon

Hello.

I'm basically trying to create a simple activity feed, but I couldn't figure out how to list only friends' updates in a feed.

I have two tables.

user_status

status_id
status
user_id (foreign key from users table)
status_date
friendship
friendship_id
friend_one (FK from users table)
friend_two (FK from users table)

friend_one is our logged in user, friend_two is his friend. Since one user can have many friends, friendship is a junction table.

User model

    public function friends() {
        return $this->belongsToMany('App\Models\User', 'friendship', 'friend_one', 'friend_two');
    }

UserStatus model

    public function status() {
        return $this->belongsTo('\App\Models\User','user_id');
    }

Is there a tutorial or something that can help me to build my feed? Even a hint would help me a lot.

Thanks!

Please sign in or create an account to participate in this conversation.