From b619ffbb856fdc59ee2a0a8b07717d9ee99d86b1 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, 21 Nov 2022 12:17:58 +0300 Subject: [PATCH] Type issue in category import --- app/Imports/Settings/Categories.php | 9 +++++++++ app/Traits/Import.php | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/app/Imports/Settings/Categories.php b/app/Imports/Settings/Categories.php index 7443c09d3..b9ae957c9 100644 --- a/app/Imports/Settings/Categories.php +++ b/app/Imports/Settings/Categories.php @@ -13,6 +13,15 @@ class Categories extends Import return new Model($row); } + public function map($row): array + { + $row = parent::map($row); + + $row['type'] = $this->getCategoryType($row['type']); + + return $row; + } + public function rules(): array { return (new Request())->rules(); diff --git a/app/Traits/Import.php b/app/Traits/Import.php index 0a5c06167..42a0d9725 100644 --- a/app/Traits/Import.php +++ b/app/Traits/Import.php @@ -60,6 +60,11 @@ trait Import return is_null($id) ? $id : (int) $id; } + public function getCategoryType($type) + { + return array_key_exists($type, config('type.category')) ? $type : 'other'; + } + public function getContactId($row, $type = null) { $id = isset($row['contact_id']) ? $row['contact_id'] : null;