diff --git a/addons/default/visiosoft/advs-module/src/Adv/AdvCriteria.php b/addons/default/visiosoft/advs-module/src/Adv/AdvCriteria.php
index bbbee4203..b6808eb48 100644
--- a/addons/default/visiosoft/advs-module/src/Adv/AdvCriteria.php
+++ b/addons/default/visiosoft/advs-module/src/Adv/AdvCriteria.php
@@ -5,6 +5,7 @@ use Anomaly\Streams\Platform\Addon\AddonCollection;
use Anomaly\Streams\Platform\Entry\EntryCriteria;
use Anomaly\Streams\Platform\Image\Image;
use Illuminate\Support\Facades\Auth;
+use Visiosoft\AdvsModule\Adv\Contract\AdvRepositoryInterface;
use Visiosoft\RecentlyviewedadsModule\Recently\RecentlyModel;
use Visiosoft\SubscriptionsModule\User\UserModel;
@@ -12,11 +13,17 @@ class AdvCriteria extends EntryCriteria
{
private $image;
+ private $advRepository;
- public function __construct(SettingRepositoryInterface $repository, Image $image)
+ public function __construct(
+ SettingRepositoryInterface $repository,
+ Image $image,
+ AdvRepositoryInterface $advRepository
+ )
{
$this->settings = $repository;
$this->image = $image;
+ $this->advRepository = $advRepository;
}
public function getAdvsModel()
@@ -79,20 +86,7 @@ class AdvCriteria extends EntryCriteria
public function findAdsByCategoryId($catId, $level = 1)
{
- $advModel = new AdvModel();
- $advs = AdvModel::query()
- ->whereDate('finish_at', '>=', date("Y-m-d H:i:s"))
- ->where('status', '=', 'approved')
- ->where('slug', '!=', '')
- ->where('cat' . $level, $catId)
- ->get();
-
- $ads = $advModel->getLocationNames($advs);
- foreach ($ads as $index => $ad) {
- $ads[$index]->detail_url = $advModel->getAdvDetailLinkByModel($ad, 'list');
- $ads[$index] = $advModel->AddAdsDefaultCoverImage($ad);
- }
- return $ads;
+ return $this->advRepository->getByCat($catId, $level);
}
public function getCurrentLocale()
diff --git a/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php b/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php
index c1a714f3e..dd8fcdf8e 100644
--- a/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php
+++ b/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php
@@ -405,6 +405,26 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
return $ads;
}
+ public function getByCat($catID, $level = 1)
+ {
+ $advs = $this->model
+ ->whereDate('finish_at', '>=', date("Y-m-d H:i:s"))
+ ->where('status', 'approved')
+ ->where('slug', '!=', '')
+ ->where('cat' . $level, $catID)
+ ->limit(20)
+ ->get();
+
+ $ads = $this->model->getLocationNames($advs);
+
+ foreach ($ads as $index => $ad) {
+ $ads[$index]->detail_url = $this->model->getAdvDetailLinkByModel($ad, 'list');
+ $ads[$index] = $this->model->AddAdsDefaultCoverImage($ad);
+ }
+
+ return $ads;
+ }
+
public function getCategoriesWithAdID($id)
{
$adv = $this->model->find($id);
diff --git a/addons/default/visiosoft/advs-module/src/Adv/Contract/AdvRepositoryInterface.php b/addons/default/visiosoft/advs-module/src/Adv/Contract/AdvRepositoryInterface.php
index 33b95c869..be75176c9 100644
--- a/addons/default/visiosoft/advs-module/src/Adv/Contract/AdvRepositoryInterface.php
+++ b/addons/default/visiosoft/advs-module/src/Adv/Contract/AdvRepositoryInterface.php
@@ -32,6 +32,8 @@ interface AdvRepositoryInterface extends EntryRepositoryInterface
public function latestAds();
+ public function getByCat($catID, $level = 1);
+
public function getCategoriesWithAdID($id);
public function extendAds($allAds, $isAdmin = false);
diff --git a/addons/default/visiosoft/advs-module/src/AdvsModuleServiceProvider.php b/addons/default/visiosoft/advs-module/src/AdvsModuleServiceProvider.php
index a9ca7f186..c65e13b7e 100644
--- a/addons/default/visiosoft/advs-module/src/AdvsModuleServiceProvider.php
+++ b/addons/default/visiosoft/advs-module/src/AdvsModuleServiceProvider.php
@@ -216,6 +216,10 @@ class AdvsModuleServiceProvider extends AddonServiceProvider
'as' => 'ajax::getAds',
'uses' => 'Visiosoft\AdvsModule\Http\Controller\AjaxController@getMyAds'
],
+ 'ajax/get-advs-by-category/{categoryID}' => [
+ 'as' => 'ajax::getAds',
+ 'uses' => 'Visiosoft\AdvsModule\Http\Controller\AjaxController@getAdvsByCat'
+ ],
'advs/extendAll/{isAdmin?}' => [
'as' => 'advs::extendAll',
'uses' => 'Visiosoft\AdvsModule\Http\Controller\AdvsController@extendAll',
diff --git a/addons/default/visiosoft/advs-module/src/Http/Controller/AjaxController.php b/addons/default/visiosoft/advs-module/src/Http/Controller/AjaxController.php
index 33d54e4cb..7f88318b2 100644
--- a/addons/default/visiosoft/advs-module/src/Http/Controller/AjaxController.php
+++ b/addons/default/visiosoft/advs-module/src/Http/Controller/AjaxController.php
@@ -85,4 +85,9 @@ class AjaxController extends PublicController
return response()->json(['success' => true, 'content' => $my_advs, 'title' => $page_title]);
}
+
+ public function getAdvsByCat($categoryID, AdvRepositoryInterface $advRepository)
+ {
+ return $advRepository->getByCat($categoryID);
+ }
}
\ No newline at end of file
diff --git a/addons/default/visiosoft/base-theme/resources/views/partials/ogdata.twig b/addons/default/visiosoft/base-theme/resources/views/partials/ogdata.twig
index 810cb9fcd..5915bd553 100644
--- a/addons/default/visiosoft/base-theme/resources/views/partials/ogdata.twig
+++ b/addons/default/visiosoft/base-theme/resources/views/partials/ogdata.twig
@@ -1,7 +1,7 @@
{% block ogdata %}
-
+
@@ -11,6 +11,6 @@
-
+
{% endblock %}
\ No newline at end of file