From 44f604e4e6bd52cb7a9e568c3fd59745c5eac435 Mon Sep 17 00:00:00 2001 From: amirghasempoor Date: Tue, 11 Mar 2025 13:31:46 +0330 Subject: [PATCH] add update api for safetyAndPrivacy --- .../Dashboard/SafetyAndPrivacyController.php | 15 ++++++++++ .../V3/SafetyAndPrivacy/UpdateRequest.php | 28 +++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 app/Http/Requests/V3/SafetyAndPrivacy/UpdateRequest.php diff --git a/app/Http/Controllers/V3/Dashboard/SafetyAndPrivacyController.php b/app/Http/Controllers/V3/Dashboard/SafetyAndPrivacyController.php index a36842d3..33c23e27 100644 --- a/app/Http/Controllers/V3/Dashboard/SafetyAndPrivacyController.php +++ b/app/Http/Controllers/V3/Dashboard/SafetyAndPrivacyController.php @@ -9,6 +9,7 @@ use App\Http\Controllers\Controller; use App\Http\Requests\V3\SafetyAndPrivacy\FirstStepStoreRequest; use App\Http\Requests\V3\SafetyAndPrivacy\SecondStepStoreRequest; use App\Http\Requests\V3\SafetyAndPrivacy\ThirdStepStoreRequest; +use App\Http\Requests\V3\SafetyAndPrivacy\UpdateRequest; use App\Http\Traits\ApiResponse; use App\Models\InfoItem; use App\Models\SafetyAndPrivacy; @@ -148,6 +149,20 @@ class SafetyAndPrivacyController extends Controller return $this->successResponse(); } + public function update(SafetyAndPrivacy $safetyAndPrivacy, UpdateRequest $request): JsonResponse + { + DB::transaction(function () use ($request, $safetyAndPrivacy) { + $safetyAndPrivacy->update([ + 'axis_type_id' => $request->axis_type_id, + 'axis_type_name' => AxisTypes::name($request->axis_type_id), + ]); + + auth()->user()->addActivityComplete(); + }); + + return $this->successResponse(); + } + public function show(SafetyAndPrivacy $safetyAndPrivacy): JsonResponse { return $this->successResponse($safetyAndPrivacy); diff --git a/app/Http/Requests/V3/SafetyAndPrivacy/UpdateRequest.php b/app/Http/Requests/V3/SafetyAndPrivacy/UpdateRequest.php new file mode 100644 index 00000000..c0dab333 --- /dev/null +++ b/app/Http/Requests/V3/SafetyAndPrivacy/UpdateRequest.php @@ -0,0 +1,28 @@ +|string> + */ + public function rules(): array + { + return [ + 'axis_type_id' => 'required|integer|exists:axis_types,id', + ]; + } +}