I'm struggling with a polymorphic relation/hyperedge using NeoEloquent where a user mentions another user on a comment. it's like :
(u1:User)-[:Mentions]-(u2:User)-[:IN]-(c:Comment)
my goal is to find all comments that a given user has been mentioned and also those who mentioned this user.so My models are like these:
UxUser Model:
public function mentionFriend(NeoEloquent $comment=null) : HyperMorph
{
return $this->hyperMorph($comment, UxUser::class, 'Mentions', 'IN');
}
public function whoMentioned():BelongsToMany {
return $this->belongsToMany(UxUser::class, 'Mentions');
}
public function whichComment(){
return $this->morphMany(Comment::class,'IN');
}
and in Comment Model I have:
public function whoIsMentioned():MorphMany{
return $this->morphMany(UxUser::class,'IN');
}
by using lines below I can correctly get all users who have mentioned this user but the $comments collection only contains one of those many comments in which this user has been mentioned.
$user=Auth::user();
$who=$user->whoMentioned;
//dd($who);
$comment=$user->whichComment;
dd($comment);
any suggestion on this? thanks in advance