From b988c962d63684ef925dd486ea2a1a99ec2bdd91 Mon Sep 17 00:00:00 2001 From: vedatakd Date: Thu, 5 Dec 2019 18:26:50 +0300 Subject: [PATCH] fixed deleted sub category name error --- .../cats-module/src/Category/CategoryModel.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/addons/default/visiosoft/cats-module/src/Category/CategoryModel.php b/addons/default/visiosoft/cats-module/src/Category/CategoryModel.php index ae8053411..4077ee784 100644 --- a/addons/default/visiosoft/cats-module/src/Category/CategoryModel.php +++ b/addons/default/visiosoft/cats-module/src/Category/CategoryModel.php @@ -9,7 +9,10 @@ class CategoryModel extends CatsCategoryEntryModel implements CategoryInterface public function getCat($id) { - return CategoryModel::query()->where('cats_category.id', $id)->first(); + return CategoryModel::query() + ->where('cats_category.id', $id) + ->whereRaw('deleted_at IS NULL') + ->first(); } public function getParentCats($id, $type = null) @@ -34,7 +37,11 @@ class CategoryModel extends CatsCategoryEntryModel implements CategoryInterface } } if ($type == 'category_ids') { - return CategoryModel::query()->whereIn('cats_category.id', $cat_ids)->orderBy('cats_category.id', 'asc')->get(); + return CategoryModel::query() + ->whereIn('cats_category.id', $cat_ids) + ->whereRaw('deleted_at IS NULL') + ->orderBy('cats_category.id', 'asc') + ->get(); } if ($type == "parent_id") { $cat_ids = array_reverse($cat_ids); @@ -92,7 +99,8 @@ class CategoryModel extends CatsCategoryEntryModel implements CategoryInterface $cats = $cats->where('cats_category.id', '!=', $selected); } } - $cats = $cats->where('name', 'like', $keyword . '%'); + $cats = $cats->where('name', 'like', $keyword . '%') + ->whereRaw('deleted_at IS NULL'); $cats = $cats->leftJoin('cats_category_translations', function ($join) { $join->on('cats_category.id', '=', 'cats_category_translations.entry_id');