Fixed import created_by issue

This commit is contained in:
Cihan Şentürk 2023-11-03 11:58:02 +03:00 committed by GitHub
parent 0d0e8820e4
commit 0fa3bf4ab1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -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';

View File

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