How wherePivot() actually works internally in laravel 5 ?
For Example I was practicing by watching a tutorial and the teacher was using wherePivot() for construing relationship:
public function friendsOfMine(){
return $this->belongsToMany('Chatty\Models\User','friends','user_id','friend_id');
}
public function friendOf(){
return $this->belongsToMany('Chatty\Models\User','friends','friend_id','user_id');
}
public function friends(){
return $this->friendsOfMine()->wherePivot('accepted',true)->get()->merge($this->friendOf()->wherePivot('accepted',true)->get());
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire