I'm currently using Hootlex Laravel-Friendship for a website, but something seems not to work with me, let me explain:
I've got a model (LF_Profile), which is using Friendship vendor, everything work, except on this, I can't get the user information, I looked at this post (Laravel friendship get user information), I followed it, and it returns
Property [sender] does not exist on this collection instance.
I'm trying to get the user information, but not working, maybe because I'm not using User model as everybody does?
Here is one code, to get ALl friendships
/**
* 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');
}
Where getAllFrendships (comes from the vendor), is this:
public function getPendingFriendships($groupSlug = '')
{
return $this->findFriendships(Status::PENDING, $groupSlug)->get();
}
It returns an array as this:
{
"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"
}
]
}
In fact, it should return in the array the sender / recipient information. If you want more details, just ask. As always thanks for helping me.