id()) ->where('followee_id', $user->id) ->first(); if ($existing) { $existing->delete(); return response()->json(['following' => false]); } Followee::create([ 'user_id' => auth()->id(), 'followee_id' => $user->id, ]); Notification::create([ 'user_id' => $user->id, 'title' => 'New follower', 'body' => auth()->user()->name . ' is now following you.', 'is_achievement' => false, 'url' => '/u/'. auth()->user()->name, ]); return response()->json(['following' => true]); } }