As per the title, my Users model extends Authenticatable not Model.
I got $user->befriend($id) and $user->getPendingFriendship() to work by calling $user = \Auth::user(); but the same does not work for $user->acceptFriendRequest():
Type error: Argument 1 passed to App\User::acceptFriendRequest() must be an instance of Illuminate\Database\Eloquent\Model, string given, called in /home/vagrant/code/neighbor/app/Http/Controllers/FriendController.php on line 29
I assume this is because of my model extending the wrong thing, but I dont think I can change it to extend Model without rewriting a large portion of my app?
Can I just change my model to extend Model and then implement all the auth?
UPDATE:
I guess I figured that original problem out. I was passing just the user ID and not the model. Changed code as follows. Now I get Method Illuminate\Database\Eloquent\Collection::acceptFriendRequest does not exist.
public function acceptRequest($id)
{
$user = User::find(auth()->user());
$requestee = User::find($id)->first();
return $user->acceptFriendRequest($requestee);
}
UPDATE AGAIN:
Got it!
needed to set $user (above) as \Auth::user()
As per the title, my Users model extends Authenticatable not Model.
I got $user->befriend($id) and $user->getPendingFriendship() to work by calling $user = \Auth::user(); but the same does not work for $user->acceptFriendRequest():
Type error: Argument 1 passed to App\User::acceptFriendRequest() must be an instance of Illuminate\Database\Eloquent\Model, string given, called in /home/vagrant/code/neighbor/app/Http/Controllers/FriendController.php on line 29
I assume this is because of my model extending the wrong thing, but I dont think I can change it to extend Model without rewriting a large portion of my app? Can I just change my model to extend Model and then
implement
all the auth?UPDATE: I guess I figured that original problem out. I was passing just the user ID and not the model. Changed code as follows. Now I get
Method Illuminate\Database\Eloquent\Collection::acceptFriendRequest does not exist.
UPDATE AGAIN: Got it! needed to set $user (above) as \Auth::user()
Thank you.