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]);
|
||||
}
|
||||
|
||||
@@ -58,4 +58,17 @@ class ConfigurationAdminController extends BaseApiController
|
||||
|
||||
return response()->json(['ok' => true]);
|
||||
}
|
||||
|
||||
public function getByKey(string $configKey): JsonResponse
|
||||
{
|
||||
$config = $this->service->getByKey($configKey);
|
||||
if (!$config) {
|
||||
return response()->json(['ok' => false, 'message' => 'Configuration not found.'], 404);
|
||||
}
|
||||
|
||||
return response()->json([
|
||||
'ok' => true,
|
||||
'config' => new ConfigurationResource($config->toArray()),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,7 +123,6 @@ class StudentController extends BaseApiController
|
||||
'parent_id',
|
||||
'registration_date',
|
||||
'tuition_paid',
|
||||
'rfid_tag',
|
||||
'semester',
|
||||
'year_of_registration',
|
||||
'school_year',
|
||||
|
||||
Reference in New Issue
Block a user