diff --git a/app/Repositories/ClientContactRepository.php b/app/Repositories/ClientContactRepository.php index eedab840d3de..2bc644f8ba4d 100644 --- a/app/Repositories/ClientContactRepository.php +++ b/app/Repositories/ClientContactRepository.php @@ -80,10 +80,10 @@ class ClientContactRepository extends BaseRepository }); //need to reload here to shake off stale contacts - $client->load('contacts'); + $client->fresh(); //always made sure we have one blank contact to maintain state - if ($client->contacts->count() == 0) { + if ($client->contacts()->count() == 0) { $new_contact = ClientContactFactory::create($client->company_id, $client->user_id); $new_contact->client_id = $client->id; $new_contact->contact_key = Str::random(40); diff --git a/app/Transformers/InvoiceHistoryTransformer.php b/app/Transformers/InvoiceHistoryTransformer.php index f8b31f415656..6b9ad6af8427 100644 --- a/app/Transformers/InvoiceHistoryTransformer.php +++ b/app/Transformers/InvoiceHistoryTransformer.php @@ -29,8 +29,19 @@ class InvoiceHistoryTransformer extends EntityTransformer public function transform(?Backup $backup) { - if(!$backup) - return null; + if(!$backup){ + + return [ + 'id' => '', + 'activity_id' => '', + 'json_backup' => (string) '', + 'html_backup' => (string) '', + 'amount' => (float) 0, + 'created_at' => (int) 0, + 'updated_at' => (int) 0, + ]; + + } return [ 'id' => $this->encodePrimaryKey($backup->id),