From e1fb015c67c95b97dd5c828a378f87e16f830473 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cihan=20=C5=9Eent=C3=BCrk?= <53110792+CihanSenturk@users.noreply.github.com> Date: Mon, 14 Aug 2023 14:04:04 +0300 Subject: [PATCH] fixed import tax unique type issue --- app/Imports/Settings/Taxes.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/app/Imports/Settings/Taxes.php b/app/Imports/Settings/Taxes.php index f7ffb8738..e6c9da0e2 100644 --- a/app/Imports/Settings/Taxes.php +++ b/app/Imports/Settings/Taxes.php @@ -12,6 +12,31 @@ class Taxes extends Import public function model(array $row) { + if (empty($row)) { + return; + } + return new Model($row); } + + public function map($row): array + { + $row = parent::map($row); + + if ($row['type'] == 'compound') { + $compound_tax = Model::where('type', 'compound')->first(); + + if ($compound_tax) { + $this->request_class = null; + + // TODO: Add exception error + // throw new \Exception('Compound tax already exists.'); + + return []; + } + } + + return $row; + } + }