From 478d5740019853c9d20f6c34cfd855dbdbf9b7b8 Mon Sep 17 00:00:00 2001 From: Mazarin Date: Sun, 30 Oct 2022 10:37:40 -0400 Subject: [PATCH] fix: fix family summary (monicahq/chandler#265) --- .../ViewHelpers/ModuleFamilySummaryViewHelper.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/domains/Contact/ManageRelationships/Web/ViewHelpers/ModuleFamilySummaryViewHelper.php b/domains/Contact/ManageRelationships/Web/ViewHelpers/ModuleFamilySummaryViewHelper.php index 79cda0697b1..4c7c11849c2 100644 --- a/domains/Contact/ManageRelationships/Web/ViewHelpers/ModuleFamilySummaryViewHelper.php +++ b/domains/Contact/ManageRelationships/Web/ViewHelpers/ModuleFamilySummaryViewHelper.php @@ -31,7 +31,7 @@ public static function data(Contact $contact, User $user): array ->where('type', RelationshipType::TYPE_LOVE) ->get(); - $loveRelationshipsCollection = self::getRelations($loveRelationships, $contact, $user); + $loveRelationshipsCollection = self::getRelations($loveRelationships, $contact); $familyRelationshipType = $contact->vault->account->relationshipGroupTypes() ->where('type', RelationshipGroupType::TYPE_FAMILY) @@ -41,7 +41,7 @@ public static function data(Contact $contact, User $user): array ->where('type', RelationshipType::TYPE_CHILD) ->get(); - $familyRelationshipsCollection = self::getRelations($familyRelationships, $contact, $user); + $familyRelationshipsCollection = self::getRelations($familyRelationships, $contact); return [ 'family_relationships' => $familyRelationshipsCollection, @@ -49,7 +49,7 @@ public static function data(Contact $contact, User $user): array ]; } - private static function getRelations(EloquentCollection $collection, Contact $contact, User $user): Collection + private static function getRelations(EloquentCollection $collection, Contact $contact): Collection { $relationshipsCollection = collect(); $counter = 0; @@ -70,12 +70,12 @@ private static function getRelations(EloquentCollection $collection, Contact $co } foreach ($relations as $relation) { - if ($relation->contact_id !== $contact->id) { - continue; + if ($relation->contact_id === $contact->id) { + $relatedContact = Contact::find($relation->related_contact_id); + } else { + $relatedContact = Contact::find($relation->contact_id); } - $relatedContact = Contact::find($relation->related_contact_id); - $relationshipsCollection->push([ 'id' => $counter, 'contact' => self::getContact($relatedContact),