added created_by field to import

This commit is contained in:
Cihan Şentürk 2023-06-16 17:16:27 +03:00 committed by GitHub
parent d9bca73382
commit c9f0649a5b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -39,7 +39,12 @@ abstract class Import implements HasLocalePreference, ShouldQueue, SkipsEmptyRow
public function map($row): array
{
$row['company_id'] = company_id();
$row['created_by'] = $this->user->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'] = User::where('email', $row['created_by'])->first()?->id ?? $this->user->id;
}
$row['created_from'] = $this->getSourcePrefix() . 'import';
// Make enabled field integer