diff --git a/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php b/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php index 3c70af43b..8aac69737 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php +++ b/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php @@ -740,4 +740,21 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface ->orderBy('distance') ->get(); } + + public function getClassifiedsByCatsIDsAndLevels($categories, $limit = 10) + { + if (is_array($categories) && count($categories)) { + return $this->getModel() + ->currentAds() + ->where(function ($query) use ($categories) { + foreach ($categories as $level => $categoryID) { + $query->orWhereIn("cat$level", $categoryID); + } + }) + ->limit($limit) + ->get(); + } + + return []; + } } 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 81d5c20ff..83700b33f 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/Contract/AdvRepositoryInterface.php +++ b/addons/default/visiosoft/advs-module/src/Adv/Contract/AdvRepositoryInterface.php @@ -76,4 +76,6 @@ interface AdvRepositoryInterface extends EntryRepositoryInterface public function getNoImageClassifiedsReport(); public function getClassifiedsByCoordinates($lat, $lng, $distance = 50); + + public function getClassifiedsByCatsIDsAndLevels($categories, $limit = 10); }