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