From b5807d8d9c638922478e5f23f5a994df48a19a96 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 13 Jan 2021 21:18:39 +1100 Subject: [PATCH] Fixes for document upload from company --- app/Utils/Traits/SavesDocuments.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/Utils/Traits/SavesDocuments.php b/app/Utils/Traits/SavesDocuments.php index ac2567c06a7e..8ac249650b37 100644 --- a/app/Utils/Traits/SavesDocuments.php +++ b/app/Utils/Traits/SavesDocuments.php @@ -22,9 +22,11 @@ trait SavesDocuments if ($entity instanceof Company) { $account = $entity->account; $company = $entity; + $user = auth()->user(); } else { $account = $entity->company->account; $company = $entity->company; + $user = $entity->user; } if (! $account->hasFeature(Account::FEATURE_DOCUMENTS)) { @@ -35,8 +37,8 @@ trait SavesDocuments $document = UploadFile::dispatchNow( $document, UploadFile::DOCUMENT, - $entity->user, - $entity->company, + $user, + $company, $entity, null, $is_public @@ -49,9 +51,11 @@ trait SavesDocuments if ($entity instanceof Company) { $account = $entity->account; $company = $entity; + $user = auth()->user(); } else { $account = $entity->company->account; $company = $entity->company; + $user = $entity->user; } if (! $account->hasFeature(Account::FEATURE_DOCUMENTS)) { @@ -61,8 +65,8 @@ trait SavesDocuments $document = UploadFile::dispatchNow( $document, UploadFile::DOCUMENT, - $entity->user, - $entity->company, + $user, + $company, $entity, null, $is_public