mirror of
https://github.com/openclassify/openclassify.git
synced 2026-02-13 00:36:04 -06:00
added bestseller twig function (fixed comment)
This commit is contained in:
parent
f987be6bc2
commit
8b320f93fc
@ -415,6 +415,13 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface
|
||||
}
|
||||
}
|
||||
|
||||
public function currentAds() {
|
||||
return $this->whereDate('finish_at', '>=', date("Y-m-d H:i:s"))
|
||||
->where('status', '=', 'approved')
|
||||
->where('slug', '!=', '')
|
||||
->orderBy('publish_at', 'desc');
|
||||
}
|
||||
|
||||
public function inStock()
|
||||
{
|
||||
return $this->is_get_adv && $this->stock;
|
||||
|
||||
@ -379,21 +379,15 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
|
||||
*/
|
||||
public function latestAds()
|
||||
{
|
||||
$latest_advs = $this->model
|
||||
->whereDate('finish_at', '>=', date("Y-m-d H:i:s"))
|
||||
->where('status', '=', 'approved')
|
||||
->where('slug', '!=', '')
|
||||
->orderBy('publish_at', 'desc')
|
||||
->limit(setting_value('visiosoft.module.advs::latest-limit'))->get();
|
||||
|
||||
$ads = $this->model->getLocationNames($latest_advs);
|
||||
|
||||
return $ads;
|
||||
$latest_advs = $this->model->currentAds()
|
||||
->limit(setting_value('visiosoft.module.advs::latest-limit'))
|
||||
->get();
|
||||
return $this->model->getLocationNames($latest_advs);
|
||||
}
|
||||
|
||||
public function bestsellerAds($catId = null, $limit = 10)
|
||||
{
|
||||
return $this->model->orderBy('total_sales', 'desc')
|
||||
return $this->model->currentAds()->orderBy('total_sales', 'desc')
|
||||
->where(function ($query) use ($catId) {
|
||||
if ($catId) {
|
||||
$query->where('cat1', $catId);
|
||||
|
||||
@ -1,20 +1,22 @@
|
||||
<?php namespace Visiosoft\AdvsModule\OptionHandler;
|
||||
|
||||
use Anomaly\CheckboxesFieldType\CheckboxesFieldType;
|
||||
use Visiosoft\AdvsModule\Adv\AdvModel;
|
||||
use Visiosoft\AdvsModule\Adv\Contract\AdvRepositoryInterface;
|
||||
use Visiosoft\MultipleFieldType\MultipleFieldType;
|
||||
|
||||
class AdvsOptions
|
||||
{
|
||||
private $advRepository;
|
||||
private $advModel;
|
||||
|
||||
public function __construct(AdvRepositoryInterface $advRepository)
|
||||
public function __construct(AdvModel $advModel)
|
||||
{
|
||||
$this->advRepository = $advRepository;
|
||||
$this->advModel = $advModel;
|
||||
}
|
||||
|
||||
public function handle(CheckboxesFieldType $fieldType)
|
||||
{
|
||||
$categories = $this->advRepository->all();
|
||||
$categories = $this->advModel->currentAds()->get();
|
||||
$options = $categories->pluck('name', 'id')->all();
|
||||
$fieldType->setOptions($options);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user