update emergency contact student controller
This commit is contained in:
@@ -12,9 +12,22 @@ class EmergencyContactCrudService
|
||||
) {
|
||||
}
|
||||
|
||||
public function update(int $contactId, array $payload): array
|
||||
public function findForParent(int $contactId, int $parentId): array
|
||||
{
|
||||
$contact = EmergencyContact::query()->findOrFail($contactId);
|
||||
$contact = EmergencyContact::query()
|
||||
->where('id', $contactId)
|
||||
->where('parent_id', $parentId)
|
||||
->firstOrFail();
|
||||
|
||||
return $contact->toArray();
|
||||
}
|
||||
|
||||
public function update(int $contactId, int $parentId, array $payload): array
|
||||
{
|
||||
$contact = EmergencyContact::query()
|
||||
->where('id', $contactId)
|
||||
->where('parent_id', $parentId)
|
||||
->firstOrFail();
|
||||
|
||||
$contact->update([
|
||||
'emergency_contact_name' => $payload['name'],
|
||||
@@ -26,9 +39,13 @@ class EmergencyContactCrudService
|
||||
return $contact->toArray();
|
||||
}
|
||||
|
||||
public function delete(int $contactId): void
|
||||
public function delete(int $contactId, int $parentId): void
|
||||
{
|
||||
$contact = EmergencyContact::query()->findOrFail($contactId);
|
||||
$contact = EmergencyContact::query()
|
||||
->where('id', $contactId)
|
||||
->where('parent_id', $parentId)
|
||||
->firstOrFail();
|
||||
|
||||
$contact->delete();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user