hootlex / laravel-friendships

This package gives Eloquent models the ability to manage their friendships.
MIT License
706 stars 151 forks source link

can't send friend request #117

Closed bhdrnzl closed 5 years ago

bhdrnzl commented 5 years ago

Argument 1 passed to App\User::befriend() must be an instance of Illuminate\Database\Eloquent\Model, integer given, called in C:\xampp\htdocs\handicraft\app\Http\Controllers\UserController.php on line 185

line 185; public function friendRequest($nick) { $recipient = Auth::id(); $user = User::where('slug', $nick)->first(); $user->befriend($recipient); return back(); }

heidilux commented 5 years ago

$recipient is the authenticated user's id. You need to pass in the actual user. In your example, you could do, $user->befriend(Auth::user())

bhdrnzl commented 5 years ago

thanks heidilux, Yesterday I had never tried this way. Working now, I'm happy :)