From cda232b847564a712dfe0b08e2d173768dd0417d Mon Sep 17 00:00:00 2001 From: David Bomba Date: Sun, 29 Jan 2023 16:43:26 +1100 Subject: [PATCH] Fixes for check data where all invitations have been archived, however a valid contact is present --- app/Console/Commands/CheckData.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Console/Commands/CheckData.php b/app/Console/Commands/CheckData.php index 39f9808cbec9..c273b87a597b 100644 --- a/app/Console/Commands/CheckData.php +++ b/app/Console/Commands/CheckData.php @@ -463,8 +463,8 @@ class CheckData extends Command $contact = $contact_class::where('company_id', $entity->company_id)->where($client_vendor_key,$entity->{$client_vendor_key})->first(); //double check if an archived invite exists - if($contact && $entity->invitations()->withTrashed()->where($contact_id, $contact->id)->count() != 0) { - $i = $entity->invitations()->withTrashed()->where($contact_id, $contact->id)->first(); + if($contact && $entity_obj::withTrashed()->where($entity_key, $entity->id)->where($contact_id, $contact->id)->count() != 0) { + $i = $entity_obj::withTrashed()->where($entity_key, $entity->id)->where($contact_id, $contact->id)->first(); $i->restore(); $this->logMessage("Found a valid contact and invitation restoring for {$entity_key} - {$entity->id}"); }