In database i have following structure
id | following_id | followed_id 1 | 3 | 1 2 | 2 | 1
I have user model and it looks like this public function userFollows() { return $this->belongsToMany('Diskourse\Models\User','followers','following_id','followed_id');
}
public function userIsFollowed()
{
return $this->belongsToMany('Diskourse\Models\User','followers','followed_id','following_id');
}
public function followers()
{
return $this->userIsFollowed->merge($this->userFollows);
}
And at last view looks like this
<h4>Followers</h4>
@if(!$user->followers()->count())
<p>No followers</p>
@endif
@foreach($user->followers() as $follower)
@include('user/partials/userblock')
@endforeach
</div>
</div>
If its working it should display user 3 and 2 as a follower of 1. Instead current user profile block is displaying twice. Please Help !!!!
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire