2021-08-10 12:09:49 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Api\V2;
|
|
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
2021-08-11 17:25:24 +02:00
|
|
|
use App\Http\Requests\Api\V2\StoreCustomerAnswers;
|
|
|
|
|
use App\Models\Customer;
|
|
|
|
|
use Illuminate\Http\JsonResponse;
|
2021-08-10 12:09:49 +02:00
|
|
|
|
|
|
|
|
class AnswerController extends Controller
|
|
|
|
|
{
|
2021-08-11 17:25:24 +02:00
|
|
|
/**
|
2023-09-06 17:24:53 +02:00
|
|
|
* Store the customer answers.
|
2021-08-11 17:25:24 +02:00
|
|
|
*
|
2023-06-23 17:18:59 +02:00
|
|
|
* @param \App\Http\Requests\Api\V2\StoreCustomerAnswers $request
|
|
|
|
|
* @param \App\Models\Customer $customer
|
|
|
|
|
* @return \Illuminate\Http\JsonResponse
|
2021-08-11 17:25:24 +02:00
|
|
|
*/
|
2021-08-23 20:00:44 +02:00
|
|
|
public function storeCustomerAnswers(
|
|
|
|
|
StoreCustomerAnswers $request,
|
|
|
|
|
Customer $customer
|
|
|
|
|
): JsonResponse {
|
2021-12-19 15:57:24 +01:00
|
|
|
// * Make sure we are accessing a customer that belongs to our service.
|
2021-08-11 17:25:24 +02:00
|
|
|
$this->authorize('customerBelongsToService', $customer);
|
2021-12-19 15:57:24 +01:00
|
|
|
|
2024-08-05 12:43:26 +02:00
|
|
|
$customer->answers()->sync($request->validated('answers'));
|
2021-12-19 15:57:24 +01:00
|
|
|
return response()->json();
|
2021-08-11 17:25:24 +02:00
|
|
|
}
|
2021-08-10 12:09:49 +02:00
|
|
|
}
|