Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

laravel follow and unfollow relationship

// users that are followed by this user
public function following() {
    return $this->belongsToMany(User::class, 'followers', 'follower_id', 'following_id');
}

// users that follow this user
public function followers() {
    return $this->belongsToMany(User::class, 'followers', 'following_id', 'follower_id');
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #laravel #follow #unfollow #relationship
ADD COMMENT
Topic
Name
6+4 =