Skip to content

Commit

Permalink
Fixed duplicated issue when importing items
Browse files Browse the repository at this point in the history
  • Loading branch information
CihanSenturk committed Sep 30, 2021
1 parent 5ade223 commit 1cb66c3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/Imports/Common/Sheets/ItemTaxes.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Abstracts\Import;
use App\Http\Requests\Common\ItemTax as Request;
use App\Models\Common\Item;
use App\Models\Common\ItemTax as Model;

class ItemTaxes extends Import
Expand All @@ -17,7 +18,12 @@ public function map($row): array
{
$row = parent::map($row);

$row['item_id'] = $this->getItemIdFromName($row);
$row['item_id'] = (int) Item::where('name', $row['item_name'])->value('id');

if ($this->isEmpty($row, 'item_id')) {
return [];
}

$row['tax_id'] = $this->getTaxId($row);

return $row;
Expand Down

0 comments on commit 1cb66c3

Please sign in to comment.