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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,4 +46,12 @@ class ConfigurationService
|
||||
|
||||
return (bool) $config->delete();
|
||||
}
|
||||
|
||||
public function getByKey(string $key): ?Configuration
|
||||
{
|
||||
return Configuration::query()
|
||||
->where('config_key', $key)
|
||||
->orderByDesc('id')
|
||||
->first();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,7 +183,6 @@ class StudentDirectoryService
|
||||
'parent_id',
|
||||
'registration_date',
|
||||
'tuition_paid',
|
||||
'rfid_tag',
|
||||
'semester',
|
||||
'year_of_registration',
|
||||
'school_year',
|
||||
|
||||
Reference in New Issue
Block a user