add popular ads limit && added Theme Settings Link For Settings

This commit is contained in:
vedatakd 2020-09-17 16:37:33 +03:00
parent 1010be1bfd
commit 46c0f63193
9 changed files with 80 additions and 12 deletions

View File

@ -21,6 +21,7 @@ return [
'title' => 'visiosoft.module.advs::section.ads',
'fields' => [
'latest-limit',
'popular_ads_limit',
'default_view_type',
'hide_zero_price',
'auto_approve',

View File

@ -248,4 +248,11 @@ return [
'default_value' => false,
]
],
'popular_ads_limit' => [
'type' => 'anomaly.field_type.integer',
'config' => [
'default_value' => 15,
],
],
];

View File

@ -44,4 +44,7 @@ return [
'options' => [
'title' => 'Options',
],
'theme_settings' => [
'name' => 'Theme Settings'
],
];

View File

@ -155,4 +155,7 @@ return [
'tcmb_exchange_url' => [
'name' => 'TCMB Exchange URL',
],
'popular_ads_limit' => [
'name' => 'Popular Ads Limit',
],
];

View File

@ -477,4 +477,14 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
->where('advs_advs.status', 'approved')
->where('advs_advs.finish_at', '>', date('Y-m-d H:i:s'));
}
public function getPopular()
{
return $this->newQuery()
->whereDate('finish_at', '>=', date("Y-m-d H:i:s"))
->where('status', '=', 'approved')
->where('slug', '!=', '')
->orderBy('count_show_ad', 'desc')
->paginate(setting_value('visiosoft.module.advs::popular_ads_limit', setting_value('streams::per_page')));
}
}

View File

@ -0,0 +1,20 @@
<?php namespace Visiosoft\AdvsModule\Adv\Command;
use Visiosoft\AdvsModule\Adv\Contract\AdvRepositoryInterface;
class getPopular
{
public function handle(AdvRepositoryInterface $repository)
{
$ads = $repository->getPopular();
$ads = $repository->getModel()->getLocationNames($ads);
foreach ($ads as $index => $ad) {
$ads[$index]->detail_url = $repository->getModel()->getAdvDetailLinkByModel($ad, 'list');
$ads[$index] = $repository->getModel()->AddAdsDefaultCoverImage($ad);
}
return $ads;
}
}

View File

@ -39,4 +39,6 @@ interface AdvRepositoryInterface extends EntryRepositoryInterface
public function extendAds($allAds, $isAdmin = false);
public function getByUsersIDs($usersIDs);
public function getPopular();
}

View File

@ -6,13 +6,21 @@ use Visiosoft\AdvsModule\Adv\AdvModel;
use Visiosoft\AdvsModule\Adv\Command\appendRequestURL;
use Visiosoft\AdvsModule\Adv\Command\GetAd;
use Visiosoft\AdvsModule\Adv\Command\getExchange;
use Visiosoft\AdvsModule\Adv\Command\getPopular;
use Visiosoft\AdvsModule\Adv\Command\isActive;
use Visiosoft\AdvsModule\Adv\Command\LatestAds;
use Visiosoft\AdvsModule\Adv\Contract\AdvRepositoryInterface;
use Visiosoft\AdvsModule\Currency\Currency;
use Visiosoft\AdvsModule\Currency\CurrencyFormat;
class AdvsModulePlugin extends Plugin
{
public $repository;
public function __construct(AdvRepositoryInterface $repository)
{
$this->repository = $repository;
}
/**
* @return array
@ -109,7 +117,15 @@ class AdvsModulePlugin extends Plugin
}
return $exchange;
}
)
), new \Twig_SimpleFunction(
'getPopular',
function () {
if (!$popular = $this->dispatch(new getPopular())) {
return null;
}
return $popular;
}
),
];
}
}

View File

@ -365,18 +365,24 @@ class AdvsModuleServiceProvider extends AddonServiceProvider
{
// Run extra post-boot registration logic here.
// Use method injection or commands to bring in services.
$slug = 'general_settings';
$section = [
'title' => 'visiosoft.module.advs::button.general_settings',
'href' => '/admin/settings/modules/visiosoft.module.advs',
$settings_url = [
'general_settings' => [
'title' => 'visiosoft.module.advs::button.general_settings',
'href' => '/admin/settings/modules/visiosoft.module.advs',
],
'theme_settings' => [
'title' => 'visiosoft.module.advs::section.theme_settings.name',
'href' => url('admin/settings/themes/' . setting_value('streams::standard_theme')),
],
'assets_clear' => [
'title' => 'visiosoft.module.advs::section.assets_clear.name',
'href' => '/admin/assets/clear',
],
];
$slug2 = 'assets_clear';
$section2 = [
'title' => 'visiosoft.module.advs::section.assets_clear.name',
'href' => '/admin/assets/clear',
];
$addonCollection->get('anomaly.module.settings')->addSection($slug, $section);
$addonCollection->get('anomaly.module.settings')->addSection($slug2, $section2);
foreach ($settings_url as $key => $value) {
$addonCollection->get('anomaly.module.settings')->addSection($key, $value);
}
// Disable file versioning
$fileModel->disableVersioning();