0

我目前正在将 Hootlex Laravel-Friendship 用于网站,但似乎对我不起作用,让我解释一下:

我有一个模型(LF_Profile),它使用友谊供应商,一切正常,除了这个,我无法获取用户信息,我查看了这篇文章(Laravel 友谊获取用户信息),我关注了它,并且它返回

此集合实例上不存在属性 [sender]。

我正在尝试获取用户信息,但没有工作,可能是因为我没有像每个人那样使用用户模型?

这是一个代码,以获得所有友谊

/**
 * Get all friendships
 *
 * @param  int $id
 *
 * @return Response
 */
public function getAllFriendships($id){

  $lFProfile = $this->lFProfileRepository->findWithoutFail($id);

  if (empty($lFProfile)) {
    return $this->sendError('LfProfile not found');
  }

  $friendships=$lFProfile->getAllFriendships();
  return $this->sendResponse($friendships->toArray(), 'Get all friends');

}

getAllFrendships (来自供应商)的位置是:

public function getPendingFriendships($groupSlug = '')
{
    return $this->findFriendships(Status::PENDING, $groupSlug)->get();
}

它返回一个数组,如下所示:

{
"data": [
    {
        "id": 2,
        "sender_id": 1,
        "sender_type": "App\\Models\\LF_Profile",
        "recipient_id": 2,
        "recipient_type": "App\\Models\\LF_Profile",
        "status": 0,
        "created_at": "2017-08-24 10:45:30",
        "updated_at": "2017-08-24 10:45:30"
    }
]
}

实际上,它应该在数组中返回发件人/收件人信息。如果您想了解更多详细信息,请询问。一如既往地感谢你帮助我。

4

0 回答 0