在NeoEloquent

时间:2016-07-29 12:30:06

标签: neo4j neoeloquent

我正在使用NeoEloquent与多态关系/ hyperedge斗争,其中用户在评论中提及另一个用户。它就像:

(u1:User)-[:Mentions]-(u2:User)-[:IN]-(c:Comment)

我的目标是查找已提及给定用户的所有评论以及提及此用户的所有评论。所以我的模型如下:

UxUser型号:

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');
}

评论模型我有:

public function whoIsMentioned():MorphMany{
        return $this->morphMany(UxUser::class,'IN');
    }

通过使用下面的行我可以正确地获得所有提及此用户的用户,但$ comments集合仅包含其中提到此用户的众多注释之一。

$user=Auth::user();
$who=$user->whoMentioned;
//dd($who);
$comment=$user->whichComment;
dd($comment);

对此有何建议?提前谢谢

0 个答案:

没有答案