From 3e441a93d335f8e4638de436d3ef7adcd2c71823 Mon Sep 17 00:00:00 2001 From: Diatrex Date: Mon, 19 Apr 2021 15:27:09 +0300 Subject: [PATCH] =?UTF-8?q?TEXT=C4=B0LCY=20(=20=C4=B0LAN=20EKLEMEK=20?= =?UTF-8?q?=C4=B0STED=C4=B0=C4=9E=C4=B0NDE;=20S=C4=B0TE=20A=C3=87ILMIYOR)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/Category/CategoryModel.php | 38 +++++++++++++++++++ .../Category/Contract/CategoryInterface.php | 2 + 2 files changed, 40 insertions(+) diff --git a/addons/default/visiosoft/cats-module/src/Category/CategoryModel.php b/addons/default/visiosoft/cats-module/src/Category/CategoryModel.php index 47af1e1c1..f03f27f7e 100644 --- a/addons/default/visiosoft/cats-module/src/Category/CategoryModel.php +++ b/addons/default/visiosoft/cats-module/src/Category/CategoryModel.php @@ -5,6 +5,44 @@ use Anomaly\Streams\Platform\Model\Cats\CatsCategoryEntryModel; class CategoryModel extends CatsCategoryEntryModel implements CategoryInterface { + public function getParentCats($id, $type = null, $noMainCat = true) + { + $cat = $this->getCat($id); + $catNames = array(); + $cat_ids = array(); + $catNames[] = $cat->name; + $cat_ids[] = $cat->id; + $subCat = $cat->parent_category_id; + if ($subCat != null) { + for ($i = 0; $i < 10; $i++) { + $parCat = $this->getCat($subCat); + if (isset($parCat)) { + if ($parCat->parent_category_id == "") { + if ($type == "add_main") + $catNames[] = $parCat->name; + if ($noMainCat) { + break; + } + } + $catNames[] = $parCat->name; + $cat_ids[] = $parCat->id; + $subCat = $parCat->parent_category_id; + } + } + } + if ($type == 'category_ids') { + 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); + return $cat_ids[0]; + } + return $catNames; + } public function getMetaKeywords() { diff --git a/addons/default/visiosoft/cats-module/src/Category/Contract/CategoryInterface.php b/addons/default/visiosoft/cats-module/src/Category/Contract/CategoryInterface.php index a16e64ef0..269e82250 100644 --- a/addons/default/visiosoft/cats-module/src/Category/Contract/CategoryInterface.php +++ b/addons/default/visiosoft/cats-module/src/Category/Contract/CategoryInterface.php @@ -4,6 +4,8 @@ use Anomaly\Streams\Platform\Entry\Contract\EntryInterface; interface CategoryInterface extends EntryInterface { + public function getParentCats($id, $type = null, $noMainCat = true); + public function getMetaKeywords(); public function getMetaDescription();