From 0fa3bf4ab1a8368e84f18e43c8a565504dbb383d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cihan=20=C5=9Eent=C3=BCrk?= <53110792+CihanSenturk@users.noreply.github.com> Date: Fri, 3 Nov 2023 11:58:02 +0300 Subject: [PATCH] Fixed import created_by issue --- app/Abstracts/Import.php | 4 +--- app/Traits/Import.php | 4 ++++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/Abstracts/Import.php b/app/Abstracts/Import.php index 4ccae7fc6..084ea2f9a 100644 --- a/app/Abstracts/Import.php +++ b/app/Abstracts/Import.php @@ -49,9 +49,7 @@ abstract class Import implements HasLocalePreference, ShouldQueue, SkipsEmptyRow $row['company_id'] = company_id(); // created_by is equal to the owner id. Therefore, the value in export is owner email. - if (isset($row['created_by'])) { - $row['created_by'] = $this->getCreatedById($row); - } + $row['created_by'] = $this->getCreatedById($row); $row['created_from'] = $this->getSourcePrefix() . 'import'; diff --git a/app/Traits/Import.php b/app/Traits/Import.php index d360ca121..9fcecf1f9 100644 --- a/app/Traits/Import.php +++ b/app/Traits/Import.php @@ -113,6 +113,10 @@ trait Import public function getCreatedById($row) { + if (empty($row['created_by'])) { + return $this->user->id; + } + $user = user_model_class()::where('email', $row['created_by'])->first(); if (! empty($user)) {