wip import

This commit is contained in:
Cihan Şentürk 2023-06-16 17:23:56 +03:00 committed by GitHub
parent c9f0649a5b
commit 57dd721ad0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View File

@ -42,9 +42,9 @@ abstract class Import implements HasLocalePreference, ShouldQueue, SkipsEmptyRow
// 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_by'] = $this->getCreatedById($row);
}
$row['created_from'] = $this->getSourcePrefix() . 'import';
// Make enabled field integer

View File

@ -14,6 +14,7 @@ use App\Jobs\Common\CreateItem;
use App\Jobs\Setting\CreateCategory;
use App\Jobs\Setting\CreateCurrency;
use App\Jobs\Setting\CreateTax;
use App\Models\Auth\User;
use App\Models\Banking\Account;
use App\Models\Common\Contact;
use App\Models\Common\Item;
@ -110,6 +111,17 @@ trait Import
return $currency->code;
}
public function getCreatedById($row)
{
$user = User::where('email', $row['created_by'])->first();
if (! empty($user)) {
return $user->id;
}
return $this->user->id;
}
public function getDocumentId($row)
{
$id = isset($row['document_id']) ? $row['document_id'] : null;