create( $this->contactMapper->toModelAttributes($contact), ); return $this->contactMapper->fromModel($contact); } public function update(Contact $contact): ?Contact { $existingContact = \App\Models\Contact::query()->findOrFail($contact->uuid->toString()); $result = $existingContact->update($this->contactMapper->toModelAttributes($contact)); if ($result === false) { return null; } return $this->contactMapper->fromModel($existingContact); } public function delete(UuidInterface $uuid): bool { $contact = \App\Models\Contact::query()->findOrFail($uuid->toString()); return (bool) $contact->delete(); } /** * @param array $intents */ public function batchCreate(array $intents): int { return \App\Models\Contact::query()->insertOrIgnore( array_map(function (Contact $intent): array { return $this->contactMapper->toModelAttributes($intent); }, $intents) ); } /** * @return LengthAwarePaginator */ public function fetchPaginatedAll(int $paginate): LengthAwarePaginator { return \App\Models\Contact::query() ->orderBy('id') ->paginate($paginate); } public function fetchByUuid(UuidInterface $uuid): ?\App\Models\Contact { return \App\Models\Contact::query()->find($uuid->toString()); } }