storeCustomerAnswers Mise à jour sans supprimer les anciennes questions
This commit is contained in:
parent
4527bc01f6
commit
f8a61d0e4c
1 changed files with 3 additions and 2 deletions
|
|
@ -23,8 +23,9 @@ class AnswerController extends Controller
|
|||
public function storeCustomerAnswers(StoreCustomerAnswers $request, Service $service, Customer $customer): JsonResponse
|
||||
{
|
||||
$this->authorize('customerBelongsToService', $customer);
|
||||
$answersID = Answer::whereIn('id', $request->answers)->pluck('id')->toArray();
|
||||
$customer->answers()->sync($answersID);
|
||||
$existingAnswerIds = $customer->getAnswers($service)->pluck('id');
|
||||
$answersID = Answer::whereIn('id', $request->answers)->pluck('id');
|
||||
$customer->answers()->attach($answersID->diff($existingAnswerIds));
|
||||
return \response()->json();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue