mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-11 18:01:10 -06:00
#2480 Sales Reports
This commit is contained in:
parent
420a25f801
commit
e239937e5c
@ -592,4 +592,63 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getStockReport()
|
||||
{
|
||||
return $this->newQuery()
|
||||
->current()
|
||||
->select('stock', 'name', 'advs_advs.id', 'slug')
|
||||
->where('is_get_adv', true)
|
||||
->where('stock', '<=', 10)
|
||||
->leftJoin('advs_advs_translations as classified_trans', function ($join) {
|
||||
$join->on('advs_advs.id', '=', 'classified_trans.entry_id');
|
||||
$join->whereIn('locale', [config('app.locale'), setting_value('streams::default_locale'), 'en']);
|
||||
})
|
||||
->get();
|
||||
}
|
||||
|
||||
public function getAllClassifiedsCount()
|
||||
{
|
||||
return $this->newQuery()
|
||||
->count();
|
||||
}
|
||||
|
||||
public function getCurrentClassifiedsCount()
|
||||
{
|
||||
return $this->newQuery()
|
||||
->current()
|
||||
->count();
|
||||
}
|
||||
|
||||
public function getUnexplainedClassifiedsReport()
|
||||
{
|
||||
return $this->newQuery()
|
||||
->current()
|
||||
->select('name', 'advs_advs.id', 'slug')
|
||||
->where(function ($query) {
|
||||
$query->where('advs_desc', '=', '')
|
||||
->orWhereNull('advs_desc');
|
||||
})
|
||||
->leftJoin('advs_advs_translations as classified_trans', function ($join) {
|
||||
$join->on('advs_advs.id', '=', 'classified_trans.entry_id');
|
||||
$join->whereIn('locale', [config('app.locale'), setting_value('streams::default_locale'), 'en']);
|
||||
})
|
||||
->get();
|
||||
}
|
||||
|
||||
public function getNoImageClassifiedsReport()
|
||||
{
|
||||
return $this->newQuery()
|
||||
->current()
|
||||
->select('name', 'advs_advs.id', 'slug')
|
||||
->where(function ($query) {
|
||||
$query->where('cover_photo', '=', '')
|
||||
->orWhereNull('cover_photo');
|
||||
})
|
||||
->leftJoin('advs_advs_translations as classified_trans', function ($join) {
|
||||
$join->on('advs_advs.id', '=', 'classified_trans.entry_id');
|
||||
$join->whereIn('locale', [config('app.locale'), setting_value('streams::default_locale'), 'en']);
|
||||
})
|
||||
->get();
|
||||
}
|
||||
}
|
||||
|
||||
@ -60,4 +60,14 @@ interface AdvRepositoryInterface extends EntryRepositoryInterface
|
||||
public function findByCFJSON($key, $value);
|
||||
|
||||
public function uploadImage();
|
||||
|
||||
public function getStockReport();
|
||||
|
||||
public function getAllClassifiedsCount();
|
||||
|
||||
public function getCurrentClassifiedsCount();
|
||||
|
||||
public function getUnexplainedClassifiedsReport();
|
||||
|
||||
public function getNoImageClassifiedsReport();
|
||||
}
|
||||
|
||||
@ -0,0 +1,55 @@
|
||||
<?php namespace Visiosoft\AdvsModule\Http\Controller\Admin;
|
||||
|
||||
use Anomaly\Streams\Platform\Http\Controller\AdminController;
|
||||
use Visiosoft\AdvsModule\Adv\Contract\AdvRepositoryInterface;
|
||||
|
||||
class ReportController extends AdminController
|
||||
{
|
||||
protected $advRepository;
|
||||
|
||||
public function __construct(AdvRepositoryInterface $advRepository)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->advRepository = $advRepository;
|
||||
}
|
||||
|
||||
public function stock()
|
||||
{
|
||||
return [
|
||||
'data' => $this->advRepository->getStockReport()
|
||||
];
|
||||
}
|
||||
|
||||
public function status()
|
||||
{
|
||||
$all = $this->advRepository->getAllClassifiedsCount();
|
||||
$active = $this->advRepository->getCurrentClassifiedsCount();
|
||||
|
||||
return [
|
||||
'data' => [
|
||||
[
|
||||
'status' => 'Active',
|
||||
'count' => $active,
|
||||
],
|
||||
[
|
||||
'status' => 'Passive',
|
||||
'count' => $all - $active,
|
||||
],
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
public function unexplained()
|
||||
{
|
||||
return [
|
||||
'data' => $this->advRepository->getUnexplainedClassifiedsReport()
|
||||
];
|
||||
}
|
||||
|
||||
public function noImage()
|
||||
{
|
||||
return [
|
||||
'data' => $this->advRepository->getNoImageClassifiedsReport()
|
||||
];
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user