Merge branch 'feature/SafetyAndPrivacyUpdate' into 'develop'
add update api for safetyAndPrivacy See merge request witelgroup/rms_v2!92
This commit is contained in:
@@ -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);
|
||||
|
||||
28
app/Http/Requests/V3/SafetyAndPrivacy/UpdateRequest.php
Normal file
28
app/Http/Requests/V3/SafetyAndPrivacy/UpdateRequest.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests\V3\SafetyAndPrivacy;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
class UpdateRequest extends FormRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
|
||||
*/
|
||||
public function rules(): array
|
||||
{
|
||||
return [
|
||||
'axis_type_id' => 'required|integer|exists:axis_types,id',
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user