diff --git a/addons/default/visiosoft/advs-module/resources/views/list/partials/breadcrumb.twig b/addons/default/visiosoft/advs-module/resources/views/list/partials/breadcrumb.twig
index abc2f4382..f5d339c3b 100644
--- a/addons/default/visiosoft/advs-module/resources/views/list/partials/breadcrumb.twig
+++ b/addons/default/visiosoft/advs-module/resources/views/list/partials/breadcrumb.twig
@@ -12,7 +12,7 @@
- {{ addBlock('ads-list/partials/breadcrumb',{'mainCats': mainCats, 'category': categoryId})|raw }}
+ {{ addBlock('ads-list/partials/breadcrumb',{'mainCats': mainCats, 'category': category})|raw }}
\ No newline at end of file
diff --git a/addons/default/visiosoft/advs-module/resources/views/list/partials/list-filter.twig b/addons/default/visiosoft/advs-module/resources/views/list/partials/list-filter.twig
index 4c51702b9..b2964b944 100644
--- a/addons/default/visiosoft/advs-module/resources/views/list/partials/list-filter.twig
+++ b/addons/default/visiosoft/advs-module/resources/views/list/partials/list-filter.twig
@@ -39,7 +39,7 @@
'neighborhoods':neighborhoods,
'villages':villages,
'param':param,
- 'categoryId':categoryId,
+ 'category':category,
'cityId':cityId,
'_ORDER_':['visiosoft.module.cats', 'visiosoft.module.location']
})|raw }}
diff --git a/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php b/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php
index 56c827728..b29c0f075 100644
--- a/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php
+++ b/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php
@@ -10,7 +10,7 @@ use Intervention\Image\Facades\Image;
use Visiosoft\AdvsModule\Adv\Contract\AdvRepositoryInterface;
use Anomaly\Streams\Platform\Entry\EntryRepository;
use Visiosoft\CatsModule\Category\CategoryModel;
-use Visiosoft\AdvsModule\Category\Contract\CategoryRepositoryInterface;
+use Visiosoft\CatsModule\Category\Contract\CategoryRepositoryInterface;
use Visiosoft\LocationModule\City\CityModel;
use Visiosoft\LocationModule\Country\CountryModel;
@@ -34,6 +34,9 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
*/
private $folderRepository;
+ public $categoryRepository;
+
+
/**
* Create a new AdvRepository instance.
*
@@ -43,13 +46,15 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
AdvModel $model,
SettingRepositoryInterface $settings,
FileRepositoryInterface $fileRepository,
- FolderRepositoryInterface $folderRepository
+ FolderRepositoryInterface $folderRepository,
+ CategoryRepositoryInterface $categoryRepository
)
{
$this->model = $model;
$this->settings = $settings;
$this->fileRepository = $fileRepository;
$this->folderRepository = $folderRepository;
+ $this->categoryRepository = $categoryRepository;
}
/**
@@ -112,16 +117,7 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
}
}
if ($category) {
- $cat = new CategoryModel();
- if ($category) {
- if ($category->parent_category_id == null) {
- $catLevel = 1;
- } else {
- $catLevel = $cat->getCatLevel($category->id);
- }
- $catLevel = "cat" . $catLevel;
- $query = $query->where($catLevel, $category->id);
- }
+ $query = $this->categoryRepository->setQuerySearchingAds($query, $category);
}
if (!empty($param['user'])) {
$query = $query->where('advs_advs.created_by_id', $param['user']);
@@ -265,20 +261,11 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
public function getCatNames($adv)
{
- $cat1 = CategoryModel::query()->where('cats_category.id', $adv->cat1)->first();
- $cat2 = CategoryModel::query()->where('cats_category.id', $adv->cat2)->first();
-
- if (!is_null($cat1))
- $adv->setAttribute('cat1_name', $cat1->name);
- else
- $adv->setAttribute('cat1_name', "");
-
- if (!is_null($cat2))
- $adv->setAttribute('cat2_name', $cat2->name);
-
- else
- $adv->setAttribute('cat2_name', "");
+ $cat1 = $this->categoryRepository->find($adv->cat1);
+ $cat2 = $this->categoryRepository->find($adv->cat2);
+ $adv->setAttribute('cat1_name', ($cat1) ? $cat1->name : "");
+ $adv->setAttribute('cat2_name', ($cat2) ? $cat2->name : "");
return $adv;
}
@@ -301,9 +288,9 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
public function addAttributes($advs)
{
- foreach ($advs as $adv) {
- $adv = $this->getLocationNames($adv);
- $adv = $this->getCatNames($adv);
+ foreach ($advs as $key => $adv) {
+ $advs[$key] = $this->getLocationNames($adv);
+ $advs[$key] = $this->getCatNames($adv);
}
return $advs;
diff --git a/addons/default/visiosoft/advs-module/src/Adv/Listener/CategoryDeleted.php b/addons/default/visiosoft/advs-module/src/Adv/Listener/CategoryDeleted.php
new file mode 100644
index 000000000..c759397ad
--- /dev/null
+++ b/addons/default/visiosoft/advs-module/src/Adv/Listener/CategoryDeleted.php
@@ -0,0 +1,32 @@
+advRepository = $advRepository;
+ }
+
+ public function handle(DeletedCategory $event)
+ {
+ $category = $event->getCategory();
+
+ $catLevelNum = ($category->parent_category_id) ? count($event->getParents()) : 1;
+
+ $catLevelText = "cat" . $catLevelNum;
+
+ $advs = $this->advRepository->newQuery()->where($catLevelText, $category->id)->get();
+ foreach ($advs as $adv) {
+ $nullableCats = array();
+ for ($i = $catLevelNum; $i <= 10; $i++) {
+ $nullableCats['cat' . $i] = null;
+ }
+ $adv->update($nullableCats);
+ }
+ }
+}
diff --git a/addons/default/visiosoft/advs-module/src/AdvsModuleServiceProvider.php b/addons/default/visiosoft/advs-module/src/AdvsModuleServiceProvider.php
index 12197ce1b..b7be7924b 100644
--- a/addons/default/visiosoft/advs-module/src/AdvsModuleServiceProvider.php
+++ b/addons/default/visiosoft/advs-module/src/AdvsModuleServiceProvider.php
@@ -10,11 +10,13 @@ use Visiosoft\AdvsModule\Adv\AdvRepository;
use Anomaly\Streams\Platform\Model\Advs\AdvsAdvsEntryModel;
use Visiosoft\AdvsModule\Adv\AdvModel;
use Visiosoft\AdvsModule\Adv\Form\AdvFormBuilder;
+use Visiosoft\AdvsModule\Adv\Listener\CategoryDeleted;
use Visiosoft\AdvsModule\Http\Middleware\redirectDiffrentLang;
use Visiosoft\AdvsModule\Http\Middleware\SetLang;
use Visiosoft\AdvsModule\Listener\AddAdvsSettingsScript;
use Visiosoft\AdvsModule\Option\Contract\OptionRepositoryInterface;
use Visiosoft\AdvsModule\Option\OptionRepository;
+use Visiosoft\CatsModule\Category\Events\DeletedCategory;
use Visiosoft\LocationModule\Village\Contract\VillageRepositoryInterface;
use Visiosoft\LocationModule\Village\VillageRepository;
use Visiosoft\LocationModule\Village\VillageModel;
@@ -178,6 +180,9 @@ class AdvsModuleServiceProvider extends AddonServiceProvider
TableIsQuerying::class => [
AddAdvsSettingsScript::class,
],
+ DeletedCategory::class => [
+ CategoryDeleted::class
+ ],
];
/**
diff --git a/addons/default/visiosoft/advs-module/src/Http/Controller/Admin/AdvsController.php b/addons/default/visiosoft/advs-module/src/Http/Controller/Admin/AdvsController.php
index 5fb965fe3..82149f2aa 100644
--- a/addons/default/visiosoft/advs-module/src/Http/Controller/Admin/AdvsController.php
+++ b/addons/default/visiosoft/advs-module/src/Http/Controller/Admin/AdvsController.php
@@ -19,6 +19,7 @@ use Visiosoft\AdvsModule\Adv\Table\AdvTableBuilder;
use Anomaly\Streams\Platform\Http\Controller\AdminController;
use Visiosoft\AdvsModule\Option\Contract\OptionRepositoryInterface;
use Visiosoft\CatsModule\Category\CategoryModel;
+use Visiosoft\CatsModule\Category\Contract\CategoryRepositoryInterface;
use Visiosoft\LocationModule\City\CityModel;
use Visiosoft\AlgoliaModule\Search\SearchModel;
@@ -134,9 +135,9 @@ class AdvsController extends AdminController
'value' => 'entry.created_by.name'
],
'category' => [
- 'value' => function (EntryInterface $entry, CategoryModel $categoryModel) {
- $category = $categoryModel->getCat($entry->cat1);
- if (!is_null($category))
+ 'value' => function (EntryInterface $entry, CategoryRepositoryInterface $categoryRepository) {
+ $category = $categoryRepository->find($entry->cat1);
+ if ($category)
return $category->name;
}
],
diff --git a/addons/default/visiosoft/advs-module/src/Http/Controller/AjaxController.php b/addons/default/visiosoft/advs-module/src/Http/Controller/AjaxController.php
index fbd872b14..85c8814b4 100644
--- a/addons/default/visiosoft/advs-module/src/Http/Controller/AjaxController.php
+++ b/addons/default/visiosoft/advs-module/src/Http/Controller/AjaxController.php
@@ -5,6 +5,7 @@ use Anomaly\UsersModule\User\UserModel;
use Visiosoft\AdvsModule\Adv\AdvModel;
use Illuminate\Http\Request;
use Visiosoft\AdvsModule\Adv\Contract\AdvRepositoryInterface;
+use Visiosoft\CatsModule\Category\Contract\CategoryRepositoryInterface;
use Visiosoft\LocationModule\City\CityModel;
use Visiosoft\LocationModule\District\DistrictModel;
use Visiosoft\LocationModule\Neighborhood\NeighborhoodModel;
@@ -50,12 +51,12 @@ class AjaxController extends PublicController
return response()->json($datas);
}
- public function keySearch(Request $request)
+ public function keySearch(Request $request, CategoryRepositoryInterface $categoryRepository)
{
- $datas = [];
- $catModel = new CategoryModel();
- $datas['category'] = $catModel->searchKeyword($request->q, $request->selected);
- return response()->json($datas);
+ $response = [
+ 'category' => $categoryRepository->searchKeyword($request->q, $request->selected)
+ ];
+ return response()->json($response);
}
public function viewed(AdvModel $advModel, $id)
@@ -75,7 +76,7 @@ class AjaxController extends PublicController
$my_advs = $my_advs->myAdvsByUser();
}
$my_advs = $my_advs->select(['id', 'cover_photo', 'slug', 'price', 'currency', 'city', 'country_id', 'cat1', 'cat2', 'status'])
- ->orderByDesc('id');
+ ->orderByDesc('id');
$my_advs = $advRepository->addAttributes($my_advs->get());
foreach ($my_advs as $index => $ad) {
diff --git a/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php b/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php
index 242880b3b..278628780 100644
--- a/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php
+++ b/addons/default/visiosoft/advs-module/src/Http/Controller/advsController.php
@@ -135,10 +135,9 @@ class AdvsController extends PublicController
$isActiveDopings = $this->adv_model->is_enabled('dopings');
// Search by category slug
- $categoryId = null;
if ($category) { // Slug
- $categoryId = $this->category_repository->findBy('slug', $category);
- if (!$categoryId) {
+ $category = $this->category_repository->findBy('slug', $category);
+ if (!$category) {
$this->messages->error(trans('visiosoft.module.advs::message.category_not_exist'));
return redirect('/');
}
@@ -146,20 +145,20 @@ class AdvsController extends PublicController
unset($param['cat']);
return redirect($this->fullLink(
$param,
- route('adv_list_seo', [$categoryId->slug]),
+ route('adv_list_seo', [$category->slug]),
array()
));
}
} elseif (isset($param['cat']) && !empty($param['cat'])) { // Only Param
- $categoryId = $this->category_repository->find($param['cat']);
- if (!$categoryId) {
+ $category = $this->category_repository->find($param['cat']);
+ if (!$category) {
$this->messages->error(trans('visiosoft.module.advs::message.category_not_exist'));
return redirect('/');
}
unset($param['cat']);
return redirect($this->fullLink(
$param,
- route('adv_list_seo', [$categoryId->slug]),
+ route('adv_list_seo', [$category->slug]),
array()
));
}
@@ -179,7 +178,7 @@ class AdvsController extends PublicController
unset($param['city']);
return redirect($this->fullLink(
$param,
- route('adv_list_seo', [$categoryId->slug, $cityId->slug]),
+ route('adv_list_seo', [$category->slug, $cityId->slug]),
array()
));
} elseif ($isOneCity) { // Param and slug
@@ -188,14 +187,14 @@ class AdvsController extends PublicController
unset($param['city']);
return redirect($this->fullLink(
$param,
- route('adv_list_seo', [$categoryId->slug, $cityId->slug]),
+ route('adv_list_seo', [$category->slug, $cityId->slug]),
array()
));
}
} elseif ($city && $isMultipleCity) { // Slug and multiple param cities
return redirect($this->fullLink(
$param,
- route('adv_list_seo', [$categoryId->slug]),
+ route('adv_list_seo', [$category->slug]),
array()
));
} elseif ($city) {
@@ -203,7 +202,7 @@ class AdvsController extends PublicController
unset($param['city']);
return redirect($this->fullLink(
$param,
- route('adv_list_seo', [$categoryId->slug]),
+ route('adv_list_seo', [$category->slug]),
array()
));
} else { // Only slug
@@ -213,7 +212,7 @@ class AdvsController extends PublicController
}
$isActiveCustomFields = $this->adv_model->is_enabled('customfields');
- $advs = $this->adv_repository->searchAdvs('list', $param, $customParameters, null, $categoryId, $cityId);
+ $advs = $this->adv_repository->searchAdvs('list', $param, $customParameters, null, $category, $cityId);
$advs = $this->adv_repository->addAttributes($advs);
if ($isActiveDopings and $param != null) {
@@ -233,27 +232,22 @@ class AdvsController extends PublicController
}
- if ($categoryId) {
- $seo_keywords = $this->category_model->getMeta_keywords($categoryId->id);
- $seo_description = $this->category_model->getMeta_description($categoryId->id);
- $seo_title = $this->category_model->getMeta_title($categoryId->id);
+ if ($category) {
+ $this->template->set('og_description', $category->seo_description);
+ $this->template->set('meta_description', $category->seo_description);
+ $this->template->set('meta_title', $category->name);
+ $this->template->set('meta_keywords', implode(', ', $category->seo_keyword));
- $this->template->set('og_description', $seo_description);
- $this->template->set('meta_description', $seo_description);
- $this->template->set('meta_title', $seo_title);
- $this->template->set('meta_keywords', implode(', ', $seo_keywords));
+ $mainCats = $this->category_repository->getParents($category->id);
- $mainCats = $this->category_model->getMains($categoryId->id);
- $current_cat = $this->category_model->getCat($categoryId->id);
- $mainCats[] = [
- 'id' => $current_cat->id,
- 'val' => $current_cat->name,
- 'slug' => $current_cat->slug,
- ];
- $subCats = $this->category_repository->getSubCatById($categoryId->id);
+ $subCats = $this->category_repository->getSubCategories($category->id);
} else {
- $mainCats = $this->category_repository->mainCats();
- $allCats = true;
+ $mainCats = $this->category_repository->getMainCategories();
+
+ $meta_title = $this->category_repository->getCategoryTextSeo($mainCats);
+
+ $this->template->set('showTitle', false);
+ $this->template->set('meta_title', $meta_title);
}
if ($isActiveCustomFields) {
@@ -271,21 +265,6 @@ class AdvsController extends PublicController
$viewType = $this->requestHttp->cookie('viewType');
- if (!isset($allCats)) {
- if (count($mainCats) == 1 || count($mainCats) == 2) {
- $catText = end($mainCats)['val'];
- } elseif (count($mainCats) > 2) {
- $catArray = array_slice($mainCats, 2);
- $catText = '';
- $loop = 0;
- foreach ($catArray as $cat) {
- $catText = !$loop ? $catText . $cat['val'] : $catText . ' ' . $cat['val'];
- $loop++;
- }
- }
- $this->template->set('showTitle', false);
- $this->template->set('meta_title', $catText);
- }
if (!empty($param['user'])) {
$user = $this->userRepository->find($param['user']);
@@ -295,7 +274,7 @@ class AdvsController extends PublicController
$compact = compact('advs', 'countries', 'mainCats', 'subCats', 'checkboxes', 'request', 'param',
'user', 'featured_advs', 'viewType', 'topfields', 'selectDropdown', 'selectRange', 'selectImage', 'ranges',
- 'seenList', 'searchedCountry', 'radio', 'categoryId', 'cityId', 'allCats', 'catText');
+ 'seenList', 'searchedCountry', 'radio', 'category', 'cityId', 'allCats', 'catText');
return $this->viewTypeBasedRedirect($viewType, $compact);
}
@@ -351,7 +330,7 @@ class AdvsController extends PublicController
for ($i = 1; $i <= 10; $i++) {
$cat = "cat" . $i;
if ($adv->$cat != null) {
- $item = $this->category_repository->getItem($adv->$cat);
+ $item = $this->category_repository->find($adv->$cat);
if (!is_null($item)) {
$categories['cat' . $i] = [
'name' => $item->name,
@@ -427,7 +406,7 @@ class AdvsController extends PublicController
for ($i = 1; $i <= 10; $i++) {
$cat = "cat" . $i;
if ($adv->$cat != null) {
- $item = $this->category_repository->getItem($adv->$cat);
+ $item = $this->category_repository->find($adv->$cat);
if (!is_null($item)) {
$categories['cat' . $i] = [
'name' => $item->name,
@@ -467,12 +446,18 @@ class AdvsController extends PublicController
return back();
}
+ public function getCats($id)
+ {
+ return $this->category_repository->getSubCatById($id);
+ }
+
public function getCatsForNewAd($id)
{
+
if ($this->adv_model->is_enabled('packages')) {
$cats = app('Visiosoft\PackagesModule\Http\Controller\PackageFEController')->AdLimitForCategorySelection($id);
} else {
- $cats = $this->category_repository->getSubCatById($id);
+ $cats = $this->getCats($id);
if (empty($cats->toArray())) {
$cats = trans('visiosoft.module.advs::message.create_ad_with_post_cat');
@@ -499,7 +484,7 @@ class AdvsController extends PublicController
for ($i = 0; $i < $end; $i++) {
$plus1 = $i + 1;
- $cat = $repository->getSingleCat($cats['cat' . $plus1]);
+ $cat = $repository->find($cats['cat' . $plus1]);
$cats_d['cat' . $plus1] = $cat->name;
}
if ($isActive->is_enabled('customfields')) {
@@ -619,7 +604,7 @@ class AdvsController extends PublicController
foreach ($cats as $para => $value) {
if (substr($para, 0, 3) === "cat") {
$id = $cats[$para];
- $cat = $this->category_repository->getSingleCat($id);
+ $cat = $categoryRepository->find($id);
if ($cat != null) {
$cats_d[$para] = $cat->name;
}
@@ -659,7 +644,7 @@ class AdvsController extends PublicController
for ($i = 1; $i <= 10; $i++) {
if ($adv[$cat . $i]) {
- $name = $this->category_repository->getSingleCat($adv[$cat . $i]);
+ $name = $this->category_repository->find($adv[$cat . $i]);
if ($name) {
$cats_d['cat' . $i] = $name->name;
$cats['cat' . $i] = $name->id;
@@ -740,7 +725,7 @@ class AdvsController extends PublicController
{
$mainCats = $this->category_repository->mainCats();
- return $this->view->make('visiosoft.module.advs::new-ad/post-cat', compact('mainCats'));
+ return $this->view->make('visiosoft.module.advs::new-ad/post-cat', compact('main_cats'));
}
public function editCategoryForAd($id)
diff --git a/addons/default/visiosoft/cats-module/migrations/2019_04_01_160927_visiosoft.module.cats__create_cats_fields.php b/addons/default/visiosoft/cats-module/migrations/2019_04_01_160927_visiosoft.module.cats__create_cats_fields.php
index 037f71187..7c3c1af20 100644
--- a/addons/default/visiosoft/cats-module/migrations/2019_04_01_160927_visiosoft.module.cats__create_cats_fields.php
+++ b/addons/default/visiosoft/cats-module/migrations/2019_04_01_160927_visiosoft.module.cats__create_cats_fields.php
@@ -37,7 +37,6 @@ class VisiosoftModuleCatsCreateCatsFields extends Migration
],
'seo_keyword' => 'anomaly.field_type.tags',
'seo_description' => 'anomaly.field_type.text',
-
];
}
diff --git a/addons/default/visiosoft/cats-module/migrations/2019_04_03_071244_visiosoft.module.cats__create_placeholderforsearch_stream.php b/addons/default/visiosoft/cats-module/migrations/2019_04_03_071244_visiosoft.module.cats__create_placeholderforsearch_stream.php
deleted file mode 100644
index 4b1911fba..000000000
--- a/addons/default/visiosoft/cats-module/migrations/2019_04_03_071244_visiosoft.module.cats__create_placeholderforsearch_stream.php
+++ /dev/null
@@ -1,35 +0,0 @@
- 'placeholderforsearch',
- 'title_column' => 'name',
- 'translatable' => true,
- 'versionable' => false,
- 'trashable' => false,
- 'searchable' => false,
- 'sortable' => false,
- ];
-
- /**
- * The stream assignments.
- *
- * @var array
- */
- protected $assignments = [
- 'name' => [
- 'translatable' => true,
- 'required' => true,
- ],
- ];
-
-}
diff --git a/addons/default/visiosoft/cats-module/resources/views/ads-list/partials/breadcrumb.twig b/addons/default/visiosoft/cats-module/resources/views/ads-list/partials/breadcrumb.twig
index 8b1bdad5c..1dc1afd4e 100644
--- a/addons/default/visiosoft/cats-module/resources/views/ads-list/partials/breadcrumb.twig
+++ b/addons/default/visiosoft/cats-module/resources/views/ads-list/partials/breadcrumb.twig
@@ -1,8 +1,8 @@
{% if params.category %}
{% for category_breadcrumbs in params.mainCats %}
- {{ category_breadcrumbs['val'] }}
+ {{ category_breadcrumbs.name }}
{% endfor %}
diff --git a/addons/default/visiosoft/cats-module/resources/views/ads-list/partials/list-filter.twig b/addons/default/visiosoft/cats-module/resources/views/ads-list/partials/list-filter.twig
index 2b2794f51..5affec358 100644
--- a/addons/default/visiosoft/cats-module/resources/views/ads-list/partials/list-filter.twig
+++ b/addons/default/visiosoft/cats-module/resources/views/ads-list/partials/list-filter.twig
@@ -10,45 +10,40 @@
diff --git a/addons/default/visiosoft/cats-module/resources/views/table/categories.twig b/addons/default/visiosoft/cats-module/resources/views/table/categories.twig
index ce728b2fd..dd1b2fd09 100644
--- a/addons/default/visiosoft/cats-module/resources/views/table/categories.twig
+++ b/addons/default/visiosoft/cats-module/resources/views/table/categories.twig
@@ -8,15 +8,15 @@
{{ asset_add("scripts.js", "streams::js/table/sortable.js") }}
{% endif %}
{% if app.request.get('cat') != null %}
- {% set parent = category_detail(app.request.get('cat')) %}
+ {% set parent = findCategory(app.request.get('cat')) %}
{% if parent.parent_category is null %}
{% set parent_url = url('admin/cats') %}
{% else %}
{% set parent_url = url('admin/cats?cat='~parent.parent_category_id) %}
{% endif %}
- {% for parnt in category_parents_name(app.request.get('cat'))|reverse %}
- - {{ parnt }}
+ {% for parent in getParents(app.request.get('cat'))|reverse %}
+ - {{ parent.name }}
{% endfor %}
diff --git a/addons/default/visiosoft/cats-module/src/Category/CategoryCriteria.php b/addons/default/visiosoft/cats-module/src/Category/CategoryCriteria.php
index 66c1390d1..96eff36c2 100644
--- a/addons/default/visiosoft/cats-module/src/Category/CategoryCriteria.php
+++ b/addons/default/visiosoft/cats-module/src/Category/CategoryCriteria.php
@@ -20,7 +20,7 @@ class CategoryCriteria extends EntryCriteria
}
public function getMainCats() {
- $mainCats = $this->categoryRepository->mainCats();
+ $mainCats = $this->categoryRepository->getMainCategories();
foreach ($mainCats as $cat) {
$subCount = $this->categoryRepository->newQuery()->where('parent_category_id', $cat->id)->count();
diff --git a/addons/default/visiosoft/cats-module/src/Category/CategoryModel.php b/addons/default/visiosoft/cats-module/src/Category/CategoryModel.php
index 3cc81a7d9..a58c68d96 100644
--- a/addons/default/visiosoft/cats-module/src/Category/CategoryModel.php
+++ b/addons/default/visiosoft/cats-module/src/Category/CategoryModel.php
@@ -1,191 +1,8 @@
where('cats_category.id', $id)
- ->whereRaw('deleted_at IS NULL')
- ->first();
- }
-
- public function getParentCats($id, $type = null)
- {
- $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;
- 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 getCatLevel($id)
- {
- //count parent and itself
- return count($this->getParentCats($id)) + 1;
- }
-
- public function getParentsCount($id)
- {
- $parentCats = array();
- $currentId = $id;
- do {
- $cat = $this->getCat($currentId);
- $catParent = $cat->parent_category_id;
- if ($catParent) {
- $currentId = $catParent;
- $parentCats[] = $catParent;
- }
- } while ($catParent);
- return count($parentCats);
- }
-
- public function getSubCategories($id, $get = null)
- {
- $sub_categories = $this->where('parent_category_id', $id)->get();
- if ($get == 'id') {
- $list_categories_id = array();
- foreach ($sub_categories as $item_category) {
- $list_categories_id[] = $item_category->id;
- }
- return $list_categories_id;
- }
- return $sub_categories;
- }
-
- public function getAllSubCategories($id)
- {
- $sub = $this->getSubCategories($id, 'id');
- for ($i = 0; $i <= count($sub) - 1; $i++) {
- $sub = array_merge($sub, $this->getSubCategories($sub[$i], 'id'));
- }
- return $sub;
- }
-
- public function deleteSubCategories($id)
- {
- $subCategories = $this->getAllSubCategories($id);
- if (count($subCategories)) {
- $this->newQuery()->whereIn('id', $subCategories)->delete();
- }
-
- return true;
- }
-
- public function searchKeyword($keyword, $selected = null)
- {
- $data = [];
- $cats = DB::table('cats_category');
- if ($selected != null) {
- if (strpos($selected, "-") !== false) {
- $selected = explode('-', $selected);
- $cats = $cats->whereNotIn('cats_category.id', $selected);
- } else {
- $cats = $cats->where('cats_category.id', '!=', $selected);
- }
- }
- $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');
- $join->whereIn('cats_category_translations.locale', [config('app.locale'), setting_value('streams::default_locale'),'en']);//active lang
- });
- $cats = $cats->select('cats_category.*', 'cats_category_translations.name as name');
- $cats = $cats->orderBy('id', 'DESC')
- ->groupBy(['cats_category.id'])
- ->get();
- foreach ($cats as $cat) {
- $link = '';
- $parents = $this->getParentCats($cat->id, null);
- krsort($parents);
- foreach ($parents as $key => $parent) {
- if ($key == 0) {
- $link .= $parent . '';
- } else {
- $link .= $parent . ' > ';
- }
- }
- $data[] = array(
- 'id' => $cat->id,
- 'name' => $cat->name,
- 'parents' => $link
- );
- }
- return $data;
- }
-
- public function getMainCategory()
- {
- return $this->where('parent_category_id', NULL)->get();
- }
-
- public function getMeta_keywords($cat_id)
- {
- return $this->find($cat_id)->seo_keyword;
- }
-
- public function getMeta_description($cat_id)
- {
- return $this->find($cat_id)->seo_description;
- }
-
- public function getMeta_title($cat_id)
- {
- return $this->find($cat_id)->name;
- }
-
- public function getMains($id)
- {
- $categories = array();
- $z = 1;
- for ($i = 1; $i <= $z; $i++) {
- $main = $this->newQuery()->where('id', $id)->first();
- $new = array();
- $new['id'] = $main->id;
- $new['val'] = $main->name;
- $new['slug'] = $main->slug;
- $categories[] = $new;
- if ($main->parent_category_id != null) {
- $id = $main->parent_category_id;
- $z++;
- }
- }
- $categories = array_reverse($categories);
- unset($categories[count($categories) - 1]);
- return $categories;
- }
}
diff --git a/addons/default/visiosoft/cats-module/src/Category/CategoryPresenter.php b/addons/default/visiosoft/cats-module/src/Category/CategoryPresenter.php
index 3d1791434..458a4021c 100644
--- a/addons/default/visiosoft/cats-module/src/Category/CategoryPresenter.php
+++ b/addons/default/visiosoft/cats-module/src/Category/CategoryPresenter.php
@@ -1,30 +1,8 @@
find($id);
- return $category->name;
- }
-
- public function getname($id)
- {
- $cat = CatsCategoryEntryModel::query()->find($id);
- return $cat->name;
- }
-
- public function getMains($id)
- {
- $category_model = new CategoryModel();
- return $category_model->getMains($id);
- }
}
diff --git a/addons/default/visiosoft/cats-module/src/Category/CategoryRepository.php b/addons/default/visiosoft/cats-module/src/Category/CategoryRepository.php
index 99f31ec11..81104f2b0 100644
--- a/addons/default/visiosoft/cats-module/src/Category/CategoryRepository.php
+++ b/addons/default/visiosoft/cats-module/src/Category/CategoryRepository.php
@@ -1,9 +1,9 @@
model = $model;
- $this->advRepository = $advRepository;
}
- public function findById($id)
+ public function deleteSubCategories($id)
{
- return $this->model->orderBy('created_at', 'DESC')->where('cats_category.id', $id)->first();
+ $sub = $this->getSubCategories($id);
+ for ($i = 0; $i <= count($sub) - 1; $i++) {
+ $sub = array_merge($sub, $this->getSubCategories($sub[$i]));
+ }
+
+ if (count($sub)) {
+ $this->newQuery()->whereIn('id', $sub)->delete();
+ }
+ return true;
}
- public function mainCats()
+ public function deleteCategories($id)
{
- return $this->newQuery()
- ->whereNull('parent_category_id')
- ->orderBy('sort_order')
+ if ($category = $this->find($id)) {
+ $category->delete();
+
+ event(new DeletedCategory($category, $this->getParents($id)));
+
+ $this->deleteSubCategories($id);
+ }
+ }
+
+ public function skipAndTake($take, $skip)
+ {
+ $this->newQuery()
+ ->skip($take * $skip)
+ ->take($take)
->get();
}
- public function getItem($cat)
+ public function getParents($id)
{
- return $this->model->where('cats_category.id', $cat)->first();
+ $category = $this->find($id);
+ $z = 1;
+ $categories = [$category];
+
+ for ($i = 0; $i < $z; $i++) {
+ if ($category = $this->find($category->parent_category_id)) {
+ $categories[] = $category;
+ if (!$category->parent_category_id) {
+ break;
+ }
+ $z++;
+ }
+ }
+ return $categories;
}
- public function getCatById($id)
+ public function getSubCategories($id)
{
- return $this->model->where('cats_category.id', $id)->where('deleted_at', null)->orderBy('sort_order')->get();
- }
-
- public function getSubCatById($id)
- {
- $cats = $this->model->newQuery()
+ $cats = $this->newQuery()
->where('parent_category_id', $id)
->get();
@@ -61,54 +86,67 @@ class CategoryRepository extends EntryRepository implements CategoryRepositoryIn
$subCount = $this->model->newQuery()->where('parent_category_id', $cat->id)->count();
$cat->hasChild = !!$subCount;
}
-
return $cats;
}
- public function getSingleCat($id)
+ public function getMainCategories()
{
- return CatsCategoryEntryModel::query()->where('cats_category.id', $id)->first();
+ return $this->newQuery()->whereNull('parent_category_id')->get();
}
- public function findBySlug($slug)
+ public function getCategoryTextSeo($categories)
{
- return $this->model->orderBy('created_at', 'DESC')->where('slug', $slug)->first();
- }
-
- public function getCategories()
- {
- return $this->model->orderBy('sort_order')->get();
- }
-
- public function removeCatFromAds($category)
- {
- $catLevelNum = 1;
- if (!is_null($category->parent_category_id)) {
- $catLevelNum = $this->model->getCatLevel($category->id);
- }
- $catLevelText = "cat" . $catLevelNum;
-
- $advs = $this->advRepository->newQuery()->where($catLevelText, $category->id)->get();
- foreach ($advs as $adv) {
- $nullableCats = array();
- for ($i = $catLevelNum; $i <= 10; $i++) {
- $nullableCats['cat' . $i] = null;
+ if (count($categories) == 1 || count($categories) == 2) {
+ $catText = end($mainCats)['name'];
+ } elseif (count($categories) > 2) {
+ $catArray = array_slice($categories->toArray(), 2);
+ $catText = '';
+ $loop = 0;
+ foreach ($catArray as $cat) {
+ $catText = !$loop ? $catText . $cat['name'] : $catText . ' ' . $cat['name'];
+ $loop++;
}
- $adv->update($nullableCats);
}
}
- public function DeleteCategories($id)
+ public function setQuerySearchingAds($query, $category)
{
- if (!is_null($category = $this->find($id))) {
- // Remove deleted category from ads
- $this->removeCatFromAds($category);
+ $catLevel = "cat" . (!$category->parent_category_id) ? 1 : count($this->getParents($category->id));
- // Delete the category
- $this->model->find($id)->delete();
+ return $query->where($catLevel, $category->id);
+ }
- // Delete the subcategories
- $this->model->deleteSubCategories($id);
+ public function searchKeyword($keyword, $selected = null)
+ {
+ $data = [];
+ $cats = $this->newQuery();
+
+ if ($selected) {
+ if (strpos($selected, "-") !== false) {
+ $cats = $cats->whereNotIn('id', explode('-', $selected));
+ } else {
+ $cats = $cats->where('id', '!=', $selected);
+ }
}
+
+ $cats = $cats->where('name', 'like', $keyword . '%')
+ ->orderBy('id', 'DESC')
+ ->get();
+
+ foreach ($cats as $cat) {
+ $link = '';
+ $parents = $this->getParents($cat->id);
+ krsort($parents);
+ foreach ($parents as $key => $parent) {
+ $link .= ($key == 0) ? $parent->name . '' : $parent->name . ' > ';
+ }
+
+ $data[] = array(
+ 'id' => $cat->id,
+ 'name' => $cat->name,
+ 'parents' => $link
+ );
+ }
+ return $data;
}
}
diff --git a/addons/default/visiosoft/cats-module/src/Category/Command/GetCategoryDetail.php b/addons/default/visiosoft/cats-module/src/Category/Command/GetCategoryDetail.php
deleted file mode 100644
index 351142df5..000000000
--- a/addons/default/visiosoft/cats-module/src/Category/Command/GetCategoryDetail.php
+++ /dev/null
@@ -1,38 +0,0 @@
-id = $id;
- }
-
-
- /**
- * @param CategoryRepositoryInterface $groups
- * @return |null
- */
- public function handle(CategoryRepositoryInterface $groups)
- {
- if ($this->id) {
- $category = $groups->find($this->id);
- if (!is_null($category))
- return $category;
- else
- return null;
- }
- return null;
- }
-}
diff --git a/addons/default/visiosoft/cats-module/src/Category/Command/GetCategoryName.php b/addons/default/visiosoft/cats-module/src/Category/Command/GetCategoryName.php
deleted file mode 100644
index ec999cfc9..000000000
--- a/addons/default/visiosoft/cats-module/src/Category/Command/GetCategoryName.php
+++ /dev/null
@@ -1,38 +0,0 @@
-id = $id;
- }
-
-
- /**
- * @param CategoryRepositoryInterface $groups
- * @return |null
- */
- public function handle(CategoryRepositoryInterface $groups)
- {
- if ($this->id) {
- $category = $groups->find($this->id);
- if (!is_null($category))
- return $category->name;
- else
- return null;
- }
- return null;
- }
-}
diff --git a/addons/default/visiosoft/cats-module/src/Category/Contract/CategoryRepositoryInterface.php b/addons/default/visiosoft/cats-module/src/Category/Contract/CategoryRepositoryInterface.php
index 38d128225..75b014a7b 100644
--- a/addons/default/visiosoft/cats-module/src/Category/Contract/CategoryRepositoryInterface.php
+++ b/addons/default/visiosoft/cats-module/src/Category/Contract/CategoryRepositoryInterface.php
@@ -4,21 +4,21 @@ use Anomaly\Streams\Platform\Entry\Contract\EntryRepositoryInterface;
interface CategoryRepositoryInterface extends EntryRepositoryInterface
{
- public function findById($id);
+ public function deleteSubCategories($id);
- public function mainCats();
+ public function deleteCategories($id);
- public function getItem($cat);
+ public function skipAndTake($take, $skip);
- public function getCatById($id);
+ public function getParents($id);
- public function getSubCatById($id);
+ public function getSubCategories($id);
- public function getSingleCat($id);
+ public function getMainCategories();
- public function findBySlug($slug);
+ public function getCategoryTextSeo($categories);
- public function getCategories();
+ public function setQuerySearchingAds($query, $category);
- public function DeleteCategories($id);
+ public function searchKeyword($keyword, $selected = null);
}
diff --git a/addons/default/visiosoft/cats-module/src/Category/Events/DeletedCategory.php b/addons/default/visiosoft/cats-module/src/Category/Events/DeletedCategory.php
new file mode 100644
index 000000000..6b3d70ee3
--- /dev/null
+++ b/addons/default/visiosoft/cats-module/src/Category/Events/DeletedCategory.php
@@ -0,0 +1,25 @@
+category = $category;
+ $this->parents = $parents;
+ }
+
+ public function getCategory()
+ {
+ return $this->category;
+ }
+
+ public function getParents()
+ {
+ $this->getParents();
+ }
+}
diff --git a/addons/default/visiosoft/cats-module/src/Category/Form/CategoryFormBuilder.php b/addons/default/visiosoft/cats-module/src/Category/Form/CategoryFormBuilder.php
index 35af085dd..d399a19a1 100644
--- a/addons/default/visiosoft/cats-module/src/Category/Form/CategoryFormBuilder.php
+++ b/addons/default/visiosoft/cats-module/src/Category/Form/CategoryFormBuilder.php
@@ -5,62 +5,4 @@ use Anomaly\Streams\Platform\Ui\Form\FormBuilder;
class CategoryFormBuilder extends FormBuilder
{
- /**
- * The form fields.
- *
- * @var array|string
- */
- protected $fields = [];
-
- /**
- * Additional validation rules.
- *
- * @var array|string
- */
- protected $rules = [];
-
- /**
- * Fields to skip.
- *
- * @var array|string
- */
- protected $skips = [];
-
- /**
- * The form actions.
- *
- * @var array|string
- */
- protected $actions = [];
-
- /**
- * The form buttons.
- *
- * @var array|string
- */
- protected $buttons = [
- 'cancel',
- ];
-
- /**
- * The form options.
- *
- * @var array
- */
- protected $options = [];
-
- /**
- * The form sections.
- *
- * @var array
- */
- protected $sections = [];
-
- /**
- * The form assets.
- *
- * @var array
- */
- protected $assets = [];
-
}
diff --git a/addons/default/visiosoft/cats-module/src/Category/Table/CategoryTableBuilder.php b/addons/default/visiosoft/cats-module/src/Category/Table/CategoryTableBuilder.php
index cb46970f3..019d2c9f9 100644
--- a/addons/default/visiosoft/cats-module/src/Category/Table/CategoryTableBuilder.php
+++ b/addons/default/visiosoft/cats-module/src/Category/Table/CategoryTableBuilder.php
@@ -19,15 +19,6 @@ class CategoryTableBuilder extends TableBuilder
],
];
- /**
- * The table filters.
- *
- * @var array|string
- */
- protected $filters = [
-
- ];
-
/**
* The table columns.
*
diff --git a/addons/default/visiosoft/cats-module/src/Category/Table/Handler/Delete.php b/addons/default/visiosoft/cats-module/src/Category/Table/Handler/Delete.php
index 0dea822bf..fd3b459a3 100644
--- a/addons/default/visiosoft/cats-module/src/Category/Table/Handler/Delete.php
+++ b/addons/default/visiosoft/cats-module/src/Category/Table/Handler/Delete.php
@@ -2,14 +2,10 @@
use Anomaly\Streams\Platform\Ui\Table\Component\Action\ActionHandler;
use Visiosoft\CatsModule\Category\Contract\CategoryRepositoryInterface;
-use Visiosoft\CatsModule\Category\Table\CategoryTableBuilder;
class Delete extends ActionHandler
{
- public function handle(
- CategoryTableBuilder $builder, array $selected,
- CategoryRepositoryInterface $categoryRepository
- )
+ public function handle(array $selected, CategoryRepositoryInterface $categoryRepository)
{
try {
foreach ($selected as $id) {
diff --git a/addons/default/visiosoft/cats-module/src/CatsModule.php b/addons/default/visiosoft/cats-module/src/CatsModule.php
index 58af83cd1..497cfa1e2 100644
--- a/addons/default/visiosoft/cats-module/src/CatsModule.php
+++ b/addons/default/visiosoft/cats-module/src/CatsModule.php
@@ -30,11 +30,6 @@ class CatsModule extends Module
'new_category',
],
],
- 'placeholderforsearch' => [
- 'buttons' => [
- 'new_placeholderforsearch',
- ],
- ],
];
}
diff --git a/addons/default/visiosoft/cats-module/src/CatsModulePlugin.php b/addons/default/visiosoft/cats-module/src/CatsModulePlugin.php
index 3b13f2a22..4f179d499 100644
--- a/addons/default/visiosoft/cats-module/src/CatsModulePlugin.php
+++ b/addons/default/visiosoft/cats-module/src/CatsModulePlugin.php
@@ -1,50 +1,32 @@
categoryRepository = $categoryRepository;
+ }
- /**
- * @return array
- */
public function getFunctions()
{
return [
new \Twig_SimpleFunction(
- 'category_name',
+ 'findCategory',
function ($id) {
-
- if (!$ad = $this->dispatch(new GetCategoryName($id))) {
+ if (!$category = $this->categoryRepository->find($id)) {
return null;
}
-
- return $ad;
+ return $category;
}
), new \Twig_SimpleFunction(
- 'category_detail',
+ 'getParents',
function ($id) {
-
- if (!$ad = $this->dispatch(new GetCategoryDetail($id))) {
- return null;
- }
-
- return $ad;
- }
- ), new \Twig_SimpleFunction(
- 'category_parents_name',
- function ($id) {
- $category_model = new CategoryModel();
- return $category_model->getParentCats($id,'add_main');
- }
- ), new \Twig_SimpleFunction(
- 'getParentsCount',
- function ($id) {
- $category_model = new CategoryModel();
- return $category_model->getParentsCount($id);
+ return $this->categoryRepository->getParents($id);
}
)
];
diff --git a/addons/default/visiosoft/cats-module/src/CatsModuleSeeder.php b/addons/default/visiosoft/cats-module/src/CatsModuleSeeder.php
index 671d997f4..e4675bffa 100644
--- a/addons/default/visiosoft/cats-module/src/CatsModuleSeeder.php
+++ b/addons/default/visiosoft/cats-module/src/CatsModuleSeeder.php
@@ -1,7 +1,6 @@
call(PlaceholderforsearchSeeder::class);
}
}
\ No newline at end of file
diff --git a/addons/default/visiosoft/cats-module/src/CatsModuleServiceProvider.php b/addons/default/visiosoft/cats-module/src/CatsModuleServiceProvider.php
index 9a7ecebf9..e083237e0 100644
--- a/addons/default/visiosoft/cats-module/src/CatsModuleServiceProvider.php
+++ b/addons/default/visiosoft/cats-module/src/CatsModuleServiceProvider.php
@@ -1,10 +1,6 @@
'Visiosoft\CatsModule\Http\Controller\Admin\CategoryController@cleanSubcats',
- 'admin/cats/placeholderforsearch' => 'Visiosoft\CatsModule\Http\Controller\Admin\PlaceholderforsearchController@index',
- 'admin/cats/placeholderforsearch/create' => 'Visiosoft\CatsModule\Http\Controller\Admin\PlaceholderforsearchController@create',
- 'admin/cats/placeholderforsearch/edit/{id}' => 'Visiosoft\CatsModule\Http\Controller\Admin\PlaceholderforsearchController@edit',
'admin/cats' => 'Visiosoft\CatsModule\Http\Controller\Admin\CategoryController@index',
'admin/cats/create' => 'Visiosoft\CatsModule\Http\Controller\Admin\CategoryController@create',
'admin/cats/edit/{id}' => 'Visiosoft\CatsModule\Http\Controller\Admin\CategoryController@edit',
@@ -117,7 +110,6 @@ class CatsModuleServiceProvider extends AddonServiceProvider
* @type array|null
*/
protected $bindings = [
- CatsPlaceholderforsearchEntryModel::class => PlaceholderforsearchModel::class,
CatsCategoryEntryModel::class => CategoryModel::class,
];
@@ -127,7 +119,6 @@ class CatsModuleServiceProvider extends AddonServiceProvider
* @type array|null
*/
protected $singletons = [
- PlaceholderforsearchRepositoryInterface::class => PlaceholderforsearchRepository::class,
CategoryRepositoryInterface::class => CategoryRepository::class,
];
@@ -203,11 +194,6 @@ class CatsModuleServiceProvider extends AddonServiceProvider
],
],
],
- 'placeholderforsearch' => [
- 'buttons' => [
- 'new_placeholderforsearch',
- ],
- ],
];
$this->addon->setSections($sections);
}
diff --git a/addons/default/visiosoft/cats-module/src/Http/Controller/Admin/CategoryController.php b/addons/default/visiosoft/cats-module/src/Http/Controller/Admin/CategoryController.php
index 50de9afc8..3553bb750 100644
--- a/addons/default/visiosoft/cats-module/src/Http/Controller/Admin/CategoryController.php
+++ b/addons/default/visiosoft/cats-module/src/Http/Controller/Admin/CategoryController.php
@@ -31,15 +31,8 @@ class CategoryController extends AdminController
public function index(CategoryTableBuilder $table, Request $request)
{
- if ($this->request->action == "delete") {
- $CategoriesModel = new CategoryModel();
- foreach ($this->request->id as $item) {
- $CategoriesModel->deleteSubCategories($item);
- }
- }
- if (!isset($request->cat) || $request->cat == "") {
- $categories = CategoryModel::query()->where('parent_category_id', '')->orWhereNull('parent_category_id')->get();
- $categories = $categories->where('deleted_at', null);
+ if ($request->cat || $request->cat == "") {
+ $categories = $this->categoryRepository->getMainCategories();
} else {
$categories = CategoryModel::query()->where('parent_category_id', $request->cat)->whereNull('deleted_at')->get();
}
diff --git a/addons/default/visiosoft/cats-module/src/Http/Controller/Admin/PlaceholderforsearchController.php b/addons/default/visiosoft/cats-module/src/Http/Controller/Admin/PlaceholderforsearchController.php
deleted file mode 100644
index dee51c2ec..000000000
--- a/addons/default/visiosoft/cats-module/src/Http/Controller/Admin/PlaceholderforsearchController.php
+++ /dev/null
@@ -1,43 +0,0 @@
-render();
- }
-
- /**
- * Create a new entry.
- *
- * @param PlaceholderforsearchFormBuilder $form
- * @return \Symfony\Component\HttpFoundation\Response
- */
- public function create(PlaceholderforsearchFormBuilder $form)
- {
- return $form->render();
- }
-
- /**
- * Edit an existing entry.
- *
- * @param PlaceholderforsearchFormBuilder $form
- * @param $id
- * @return \Symfony\Component\HttpFoundation\Response
- */
- public function edit(PlaceholderforsearchFormBuilder $form, $id)
- {
- return $form->render($id);
- }
-}
diff --git a/addons/default/visiosoft/cats-module/src/Http/Controller/SitemapController.php b/addons/default/visiosoft/cats-module/src/Http/Controller/SitemapController.php
index 77f25287b..42eaf2e50 100644
--- a/addons/default/visiosoft/cats-module/src/Http/Controller/SitemapController.php
+++ b/addons/default/visiosoft/cats-module/src/Http/Controller/SitemapController.php
@@ -7,77 +7,70 @@ use Visiosoft\LocationModule\City\Contract\CityRepositoryInterface;
class SitemapController extends PublicController
{
- private $categoryRepository;
- private $cityRepository;
+ private $category;
+ private $city;
public function __construct(
- CategoryRepositoryInterface $categoryRepository,
- CityRepositoryInterface $cityRepository
+ CategoryRepositoryInterface $category,
+ CityRepositoryInterface $city
)
{
parent::__construct();
- $this->categoryRepository = $categoryRepository;
- $this->cityRepository = $cityRepository;
+ $this->category = $category;
+ $this->city = $city;
}
public function index()
{
- $categoriesCount = $this->categoryRepository->count();
+ $categoriesCount = $this->category->count();
+ $include_cities_sitemap = setting_value('visiosoft.module.cats::include_cities_sitemap');
+ $sitemap_dividing_number = setting_value('visiosoft.module.cats::sitemap_dividing_number');
- if (setting_value('visiosoft.module.cats::include_cities_sitemap')) {
- $citiesCount = $this->cityRepository->count();
+ if ($include_cities_sitemap) {
+ $citiesCount = $this->city->count();
$pagesCount = $citiesCount ? $categoriesCount * $citiesCount : $categoriesCount;
} else {
$pagesCount = $categoriesCount;
}
- $pagesCount = ceil($pagesCount / setting_value('visiosoft.module.cats::sitemap_dividing_number'));
+ $pagesCount = ceil($pagesCount / $sitemap_dividing_number);
- return response()->view('visiosoft.module.cats::sitemap.index', [
- 'pagesCount' => $pagesCount,
- ])->header('Content-Type', 'text/xml');
+ return $this->response->view('visiosoft.module.cats::sitemap.index', compact('pagesCount'))
+ ->header('Content - Type', 'text / xml');
}
public function categories()
{
- $sitemapDividingNumber = setting_value('visiosoft.module.cats::sitemap_dividing_number');
$page = request()->page ?: 1;
$skip = $page - 1;
+ $sitemapLinks = array();
+ $sitemap_dividing_number = setting_value('visiosoft.module.cats::sitemap_dividing_number');
+ $include_cities_sitemap = setting_value('visiosoft.module.cats::include_cities_sitemap');
- if (setting_value('visiosoft.module.cats::include_cities_sitemap')
- && $citiesCount = $this->cityRepository->count()) {
- $categoriesCount = $this->categoryRepository->count();
- $takeCategories = $categoriesCount / ($categoriesCount * $citiesCount / $sitemapDividingNumber);
+ if ($citiesCount = $this->city->count() && $include_cities_sitemap) {
+ $categoriesCount = $this->category->count();
- $categories = $this->categoryRepository
- ->newQuery()
- ->skip($takeCategories * $skip)
- ->take($takeCategories)
- ->get();
+ $take = $categoriesCount / ($categoriesCount * $citiesCount / $sitemap_dividing_number);
+
+ $categories = $this->category->skipAndTake($take, $skip);
+
+ $cities = $this->city->all();
- $sitemapLinks = array();
- $cities = $this->cityRepository->all();
foreach ($categories as $category) {
foreach ($cities as $city) {
$sitemapLinks[] = route('adv_list_seo', [$category->slug, $city->slug]);
}
}
} else {
- $categories = $this->categoryRepository
- ->newQuery()
- ->skip($sitemapDividingNumber * $skip)
- ->take($sitemapDividingNumber)
- ->get();
+ $categories = $this->category->skipAndTake($sitemap_dividing_number, $skip);
- $sitemapLinks = array();
foreach ($categories as $category) {
$sitemapLinks[] = route('adv_list_seo', [$category->slug]);
}
}
- return response()->view('visiosoft.module.cats::sitemap.categories', [
- 'sitemapLinks' => $sitemapLinks,
- ])->header('Content-Type', 'text/xml');
+ return response()->view('visiosoft.module.cats::sitemap.categories', compact('sitemapLinks'))
+ ->header('Content - Type', 'text / xml');
}
}
diff --git a/addons/default/visiosoft/cats-module/src/Placeholderforsearch/Contract/PlaceholderforsearchInterface.php b/addons/default/visiosoft/cats-module/src/Placeholderforsearch/Contract/PlaceholderforsearchInterface.php
deleted file mode 100644
index b6c652c90..000000000
--- a/addons/default/visiosoft/cats-module/src/Placeholderforsearch/Contract/PlaceholderforsearchInterface.php
+++ /dev/null
@@ -1,8 +0,0 @@
-model = $model;
- }
-}
diff --git a/addons/default/visiosoft/cats-module/src/Placeholderforsearch/PlaceholderforsearchRouter.php b/addons/default/visiosoft/cats-module/src/Placeholderforsearch/PlaceholderforsearchRouter.php
deleted file mode 100644
index 5eb70879d..000000000
--- a/addons/default/visiosoft/cats-module/src/Placeholderforsearch/PlaceholderforsearchRouter.php
+++ /dev/null
@@ -1,8 +0,0 @@
-truncate();
- DB::table('cats_placeholderforsearch_translations')->truncate();
- PlaceholderforsearchModel::create([
- 'en' => [
- 'name' => 'Chevrolet Camaro'
- ],
- 'tr' => [
- 'name' => 'Chevrolet Camaro'
- ]
- ]);
- PlaceholderforsearchModel::create([
- 'en' => [
- 'name' => 'Xiaomi Black Shark 128 GB'
- ],
- 'tr' => [
- 'name' => 'Xiaomi Black Shark 128 GB'
- ]
- ]);
- PlaceholderforsearchModel::create([
- 'en' => [
- 'name' => 'Apple MacBook Pro'
- ],
- 'tr' => [
- 'name' => 'Apple MacBook Pro'
- ]
- ]);
- PlaceholderforsearchModel::create([
- 'en' => [
- 'name' => 'Make your search now'
- ],
- 'tr' => [
- 'name' => 'Make your search now'
- ]
- ]);
- }
-}
diff --git a/addons/default/visiosoft/cats-module/src/Placeholderforsearch/Table/PlaceholderforsearchTableBuilder.php b/addons/default/visiosoft/cats-module/src/Placeholderforsearch/Table/PlaceholderforsearchTableBuilder.php
deleted file mode 100644
index 0391b56a7..000000000
--- a/addons/default/visiosoft/cats-module/src/Placeholderforsearch/Table/PlaceholderforsearchTableBuilder.php
+++ /dev/null
@@ -1,61 +0,0 @@
-