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)) {