Answers for "laravel follow and unfollow relationship"

PHP
0

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');
}
Posted by: Guest on October-15-2020

Code answers related to "laravel follow and unfollow relationship"

Browse Popular Code Answers by Language