authorize('customerBelongsToService', $customer); $existingAnswerIds = $customer->getAnswers($service)->pluck('id'); $answersID = Answer::whereIn('id', $request->answers)->pluck('id'); $customer->answers()->attach($answersID->diff($existingAnswerIds)); return \response()->json(); } }