From d9f4a07b072981a9775c592701b6567b60af0e69 Mon Sep 17 00:00:00 2001 From: diashalabi Date: Thu, 30 Sep 2021 15:36:07 +0300 Subject: [PATCH] #2480 Sales Reports --- .../src/Category/CategoryRepository.php | 32 +++++++++++++++++++ .../Contract/CategoryRepositoryInterface.php | 2 ++ .../Controller/Admin/ReportController.php | 12 +++++++ 3 files changed, 46 insertions(+) create mode 100644 addons/default/visiosoft/cats-module/src/Http/Controller/Admin/ReportController.php diff --git a/addons/default/visiosoft/cats-module/src/Category/CategoryRepository.php b/addons/default/visiosoft/cats-module/src/Category/CategoryRepository.php index ec4ea850d..30060fde0 100644 --- a/addons/default/visiosoft/cats-module/src/Category/CategoryRepository.php +++ b/addons/default/visiosoft/cats-module/src/Category/CategoryRepository.php @@ -184,4 +184,36 @@ class CategoryRepository extends EntryRepository implements CategoryRepositoryIn $cats->maincats = $catsDB->unique('id'); return $cats; } + + public function noMetaReport() + { + $categories = $this->newQuery() + ->select('name as category', 'cats_category.id') + ->where(function ($q) { + $q->whereNull('seo_keyword') + ->orWhereNull('seo_description'); + }) + ->leftJoin('cats_category_translations as cats_trans', function ($join) { + $join->on('cats_category.id', '=', 'cats_trans.entry_id'); + $join->whereIn('locale', [config('app.locale'), setting_value('streams::default_locale'), 'en']); + }); + + if ($search = request('search.value')) { + $categories = $categories->where('name', 'LIKE', "%$search%"); + } + + if ($orderDir = request('order.0.dir')) { + $categories = $categories->orderBy('category', $orderDir); + } + + $start = request('start'); + $limit = request('length') ?: 10; + $page = $start ? $start / $limit + 1 : 1; + + $categories = $categories->paginate($limit, ['*'], 'page', $page); + $categories->recordsTotal = $categories->total(); + $categories->recordsFiltered = $categories->total(); + + return $categories; + } } 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 750acb5ef..875c3ea80 100644 --- a/addons/default/visiosoft/cats-module/src/Category/Contract/CategoryRepositoryInterface.php +++ b/addons/default/visiosoft/cats-module/src/Category/Contract/CategoryRepositoryInterface.php @@ -23,4 +23,6 @@ interface CategoryRepositoryInterface extends EntryRepositoryInterface public function getDeletedCategories(); public function getMainAndSubCats(); + + public function noMetaReport(); } diff --git a/addons/default/visiosoft/cats-module/src/Http/Controller/Admin/ReportController.php b/addons/default/visiosoft/cats-module/src/Http/Controller/Admin/ReportController.php new file mode 100644 index 000000000..353891d93 --- /dev/null +++ b/addons/default/visiosoft/cats-module/src/Http/Controller/Admin/ReportController.php @@ -0,0 +1,12 @@ +noMetaReport(); + } +}