mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-11 18:01:10 -06:00
commit
868cab8845
@ -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;
|
||||
}
|
||||
|
||||
@ -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')
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user