Recently I am working on a project 'facebook-clone' using Laravel and vue.js. I have been using unit test for the first time. After performing the test I found this error,
Error: "ErrorException: Trying to get property 'id' of non-object"
For sending a friend request I wrote this
test.a_user_can_send_a_friend_request
I am using many to many relationships in User Model.
many to many relationships within users model
this is the pivot table friends
Api route:
api.php
The Controller used:
FriendRequestController
The resource used:
Friend
The problem is solved, I made a mistake in FriendRequestController where I should have passed an argument in Friendesource, instead I passed an array by mistake.
With error:
after fixing error: