update emergency contact student controller
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Http\Controllers\Api\Administrator;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Http\Requests\EmergencyContacts\EmergencyContactParentRequest;
|
||||
use App\Http\Requests\EmergencyContacts\EmergencyContactUpdateRequest;
|
||||
use App\Http\Resources\EmergencyContacts\EmergencyContactGroupResource;
|
||||
use App\Http\Resources\EmergencyContacts\EmergencyContactResource;
|
||||
@@ -28,9 +29,10 @@ class EmergencyContactController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(EmergencyContactUpdateRequest $request, int $contactId): JsonResponse
|
||||
public function show(EmergencyContactParentRequest $request, int $contactId): JsonResponse
|
||||
{
|
||||
$contact = $this->crudService->update($contactId, $request->validated());
|
||||
$parentId = (int) $request->validated()['parent_id'];
|
||||
$contact = $this->crudService->findForParent($contactId, $parentId);
|
||||
|
||||
return response()->json([
|
||||
'ok' => true,
|
||||
@@ -38,9 +40,21 @@ class EmergencyContactController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function destroy(int $contactId): JsonResponse
|
||||
public function update(EmergencyContactUpdateRequest $request, int $contactId): JsonResponse
|
||||
{
|
||||
$this->crudService->delete($contactId);
|
||||
$payload = $request->validated();
|
||||
$contact = $this->crudService->update($contactId, (int) $payload['parent_id'], $payload);
|
||||
|
||||
return response()->json([
|
||||
'ok' => true,
|
||||
'contact' => new EmergencyContactResource($contact),
|
||||
]);
|
||||
}
|
||||
|
||||
public function destroy(EmergencyContactParentRequest $request, int $contactId): JsonResponse
|
||||
{
|
||||
$parentId = (int) $request->validated()['parent_id'];
|
||||
$this->crudService->delete($contactId, $parentId);
|
||||
|
||||
return response()->json(['ok' => true]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user