mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-11 18:01:10 -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;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
$advs = $this->model
|
||||
|
||||
@ -35,6 +35,8 @@ interface AdvRepositoryInterface extends EntryRepositoryInterface
|
||||
|
||||
public function latestAds();
|
||||
|
||||
public function bestsellerAds($catId= null, $limit = 10);
|
||||
|
||||
public function getByCat($catID, $level = 1, $limit = 20);
|
||||
|
||||
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\isActive;
|
||||
use Visiosoft\AdvsModule\Adv\Command\LatestAds;
|
||||
use Visiosoft\AdvsModule\Adv\Contract\AdvRepositoryInterface;
|
||||
use Visiosoft\AdvsModule\Support\Command\Currency;
|
||||
|
||||
class AdvsModulePlugin extends Plugin
|
||||
@ -51,15 +52,8 @@ class AdvsModulePlugin extends Plugin
|
||||
),
|
||||
new \Twig_SimpleFunction(
|
||||
'bestsellerAds',
|
||||
function ($catId = null) {
|
||||
return AdvModel::query()
|
||||
->orderBy('total_sales', 'desc')
|
||||
->where(function ($query) use ($catId) {
|
||||
if ($catId) {
|
||||
$query->where('cat1', $catId);
|
||||
}
|
||||
})
|
||||
->limit(10)->get();
|
||||
function ($catId = null, $limit = 10) {
|
||||
return app(AdvRepositoryInterface::class)->bestsellerAds($catId, $limit);
|
||||
}
|
||||
),
|
||||
new \Twig_SimpleFunction(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user