add more controller

This commit is contained in:
root
2026-03-10 00:48:32 -04:00
parent 5eeaec0257
commit 20ee70d153
151 changed files with 9481 additions and 8407 deletions
@@ -0,0 +1,34 @@
<?php
namespace App\Services\EmergencyContacts;
use App\Models\EmergencyContact;
use App\Services\PhoneFormatterService;
class EmergencyContactCrudService
{
public function __construct(
private PhoneFormatterService $phoneFormatter
) {
}
public function update(int $contactId, array $payload): array
{
$contact = EmergencyContact::query()->findOrFail($contactId);
$contact->update([
'emergency_contact_name' => $payload['name'],
'cellphone' => $this->phoneFormatter->formatPhoneNumber($payload['cellphone']),
'email' => $payload['email'] ?? null,
'relation' => $payload['relation'] ?? null,
]);
return $contact->toArray();
}
public function delete(int $contactId): void
{
$contact = EmergencyContact::query()->findOrFail($contactId);
$contact->delete();
}
}