#2480 Sales Reports

This commit is contained in:
diashalabi 2021-09-30 15:36:07 +03:00
parent a6ca1a6eb1
commit d9f4a07b07
3 changed files with 46 additions and 0 deletions

View File

@ -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;
}
}

View File

@ -23,4 +23,6 @@ interface CategoryRepositoryInterface extends EntryRepositoryInterface
public function getDeletedCategories();
public function getMainAndSubCats();
public function noMetaReport();
}

View File

@ -0,0 +1,12 @@
<?php namespace Visiosoft\CatsModule\Http\Controller\Admin;
use Anomaly\Streams\Platform\Http\Controller\AdminController;
use Visiosoft\CatsModule\Category\Contract\CategoryRepositoryInterface;
class ReportController extends AdminController
{
public function category(CategoryRepositoryInterface $categoryRepository)
{
return $categoryRepository->noMetaReport();
}
}