mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-24 22:11:01 -06:00
added bestseller twig function
This commit is contained in:
parent
c03b75ad56
commit
1610a31cc3
@ -391,6 +391,17 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
|
|||||||
return $ads;
|
return $ads;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function bestsellerAds($catId = null, $limit = 10)
|
||||||
|
{
|
||||||
|
return $this->model->orderBy('total_sales', 'desc')
|
||||||
|
->where(function ($query) use ($catId) {
|
||||||
|
if ($catId) {
|
||||||
|
$query->where('cat1', $catId);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
->limit($limit)->get();
|
||||||
|
}
|
||||||
|
|
||||||
public function getByCat($catID, $level = 1, $limit = 20)
|
public function getByCat($catID, $level = 1, $limit = 20)
|
||||||
{
|
{
|
||||||
$advs = $this->model
|
$advs = $this->model
|
||||||
|
|||||||
@ -35,6 +35,8 @@ interface AdvRepositoryInterface extends EntryRepositoryInterface
|
|||||||
|
|
||||||
public function latestAds();
|
public function latestAds();
|
||||||
|
|
||||||
|
public function bestsellerAds($catId= null, $limit = 10);
|
||||||
|
|
||||||
public function getByCat($catID, $level = 1, $limit = 20);
|
public function getByCat($catID, $level = 1, $limit = 20);
|
||||||
|
|
||||||
public function getAdsCountByCategory($catID, $level = 1);
|
public function getAdsCountByCategory($catID, $level = 1);
|
||||||
|
|||||||
@ -9,6 +9,7 @@ use Visiosoft\AdvsModule\Adv\Command\getPopular;
|
|||||||
use Visiosoft\AdvsModule\Adv\Command\GetUserAds;
|
use Visiosoft\AdvsModule\Adv\Command\GetUserAds;
|
||||||
use Visiosoft\AdvsModule\Adv\Command\isActive;
|
use Visiosoft\AdvsModule\Adv\Command\isActive;
|
||||||
use Visiosoft\AdvsModule\Adv\Command\LatestAds;
|
use Visiosoft\AdvsModule\Adv\Command\LatestAds;
|
||||||
|
use Visiosoft\AdvsModule\Adv\Contract\AdvRepositoryInterface;
|
||||||
use Visiosoft\AdvsModule\Support\Command\Currency;
|
use Visiosoft\AdvsModule\Support\Command\Currency;
|
||||||
|
|
||||||
class AdvsModulePlugin extends Plugin
|
class AdvsModulePlugin extends Plugin
|
||||||
@ -51,15 +52,8 @@ class AdvsModulePlugin extends Plugin
|
|||||||
),
|
),
|
||||||
new \Twig_SimpleFunction(
|
new \Twig_SimpleFunction(
|
||||||
'bestsellerAds',
|
'bestsellerAds',
|
||||||
function ($catId = null) {
|
function ($catId = null, $limit = 10) {
|
||||||
return AdvModel::query()
|
return app(AdvRepositoryInterface::class)->bestsellerAds($catId, $limit);
|
||||||
->orderBy('total_sales', 'desc')
|
|
||||||
->where(function ($query) use ($catId) {
|
|
||||||
if ($catId) {
|
|
||||||
$query->where('cat1', $catId);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
->limit(10)->get();
|
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
new \Twig_SimpleFunction(
|
new \Twig_SimpleFunction(
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user