hootlex / laravel-friendships

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

can't send friend request #117

Closed bhdrnzl closed 6 years ago

bhdrnzl commented 6 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 6 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 6 years ago

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