From 82028cb8d47d54b8e8b17dee9b04d761210d6e9d Mon Sep 17 00:00:00 2001 From: Muammer Top Date: Wed, 27 Oct 2021 17:11:29 +0300 Subject: [PATCH] #4798 emlak24.com need --- .../advs-module/src/Adv/AdvModel.php | 4 +++ .../advs-module/src/Adv/AdvRepository.php | 29 +++++++++++++++---- .../Adv/Contract/AdvRepositoryInterface.php | 2 ++ 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/addons/default/visiosoft/advs-module/src/Adv/AdvModel.php b/addons/default/visiosoft/advs-module/src/Adv/AdvModel.php index e49bc7e4a..6ebbbf82b 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/AdvModel.php +++ b/addons/default/visiosoft/advs-module/src/Adv/AdvModel.php @@ -289,6 +289,7 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface foreach ($advs as $adv) { $country = CountryModel::query()->where('location_countries.id', $adv->country_id)->first(); $city = CityModel::query()->where('location_cities.id', $adv->city)->first(); + $district = DistrictModel::query()->where('location_districts.id', $adv->district)->first(); if ($country != null) { $adv->setAttribute('country_name', $country->name); @@ -297,6 +298,9 @@ class AdvModel extends AdvsAdvsEntryModel implements AdvInterface if ($city != null) { $adv->setAttribute('city_name', $city->name); } + if ($district != null) { + $adv->setAttribute('district_name', $district->name); + } } return $advs; } diff --git a/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php b/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php index 77fe83b9b..c276543b6 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php +++ b/addons/default/visiosoft/advs-module/src/Adv/AdvRepository.php @@ -398,6 +398,13 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface return $this->model->orderBy('created_at', 'DESC')->whereIn('advs_advs.id', $ids)->get(); } + public function hideAdsWithoutOutOfStock($ads) { + return $ads->filter( + function ($entry) { + return (($entry->is_get_adv == true && $entry->stock > 0) || ($entry->is_get_adv == false)); + } + ); + } /** * Get Latest Ads @@ -410,16 +417,28 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface ->get(); if (setting_value('visiosoft.module.advs::hide_out_of_stock_products_without_listing')) { - $latest_advs = $latest_advs->filter( - function ($entry) { - return (($entry->is_get_adv == true && $entry->stock > 0) || ($entry->is_get_adv == false)); - } - ); + $latest_advs = $this->hideAdsWithoutOutOfStock($latest_advs); } return $this->model->getLocationNames($latest_advs); } + public function latestAdsWithout($keyword, $value) + { + $latest_ads = $this->model->currentAds() + ->where(function ($q) use ($keyword, $value) { + return $q->where($keyword, '<>', $value); + }) + ->limit(setting_value('visiosoft.module.advs::latest-limit')) + ->get(); + + if (setting_value('visiosoft.module.advs::hide_out_of_stock_products_without_listing')) { + $latest_ads = $this->hideAdsWithoutOutOfStock($latest_ads); + } + + return $this->model->getLocationNames($latest_ads); + } + public function bestsellerAds($catId = null, $limit = 10) { return $this->model->currentAds()->orderBy('total_sales', 'desc') 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 e47d9286f..131918bde 100644 --- a/addons/default/visiosoft/advs-module/src/Adv/Contract/AdvRepositoryInterface.php +++ b/addons/default/visiosoft/advs-module/src/Adv/Contract/AdvRepositoryInterface.php @@ -35,6 +35,8 @@ interface AdvRepositoryInterface extends EntryRepositoryInterface public function latestAds(); + public function latestAdsWithout($keyword, $value); + public function bestsellerAds($catId= null, $limit = 10); public function getByCat($catID, $level = 1, $limit = 20);