#4671 [advs-module] Date sorting is not working properly

This commit is contained in:
diashalabi 2021-10-12 10:44:43 +03:00
parent 1025e4521d
commit 8ea7879cd0
2 changed files with 7 additions and 8 deletions

View File

@ -38,6 +38,7 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
$limit = null, $category = null, $city = null, $paginate = true
)
{
$isSort = !empty($param['sort_by']);
$isActiveDopings = new AdvModel();
$isActiveDopings = $isActiveDopings->is_enabled('dopings');
@ -161,11 +162,11 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
$query = $query->whereRaw("ST_DISTANCE(ST_GeomFromText('POINT(" . $param['dlong'] . " " . $param['dlat'] . ")'), coor) < " . $param['distance']);
}
if ($isActiveDopings) {
if ($isActiveDopings && !$isSort) {
$query = app('Visiosoft\DopingsModule\Http\Controller\DopingsController')->search($query, $param);
}
if (!empty($param['sort_by'])) {
if ($isSort) {
switch ($param['sort_by']) {
case "popular":
$query = $query->orderBy('advs_advs.count_show_ad', 'desc');
@ -177,10 +178,10 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
$query = $query->orderBy('advs_advs.price', 'asc');
break;
case "sort_time_newest":
$query = $query->orderBy('advs_advs.created_at', 'desc');
$query = $query->orderBy('advs_advs.publish_at', 'desc');
break;
case "sort_time_oldest":
$query = $query->orderBy('advs_advs.created_at', 'asc');
$query = $query->orderBy('advs_advs.publish_at', 'asc');
break;
case "address_a_z":
$query = $query->join('location_cities_translations', 'advs_advs.city', '=', 'location_cities_translations.entry_id')
@ -201,7 +202,7 @@ class AdvRepository extends EntryRepository implements AdvRepositoryInterface
$query = $query->orderBy('advs_advs.created_at', 'desc');
}
if ($isActiveDopings) {
if ($isActiveDopings && !$isSort) {
$query = app('Visiosoft\DopingsModule\Http\Controller\DopingsController')->querySelect($query, $param);
} else {
$query = $query->select('advs_advs.*', 'advs_advs_translations.name as name',

View File

@ -22,8 +22,6 @@ use Visiosoft\AdvsModule\Adv\Form\AdvFormBuilder;
use Visiosoft\AdvsModule\Option\Contract\OptionRepositoryInterface;
use Visiosoft\AdvsModule\OptionConfiguration\Contract\OptionConfigurationRepositoryInterface;
use Visiosoft\AdvsModule\OptionConfiguration\OptionConfigurationModel;
use Visiosoft\AdvsModule\Productoption\Contract\ProductoptionRepositoryInterface;
use Visiosoft\AdvsModule\ProductoptionsValue\Contract\ProductoptionsValueRepositoryInterface;
use Visiosoft\CatsModule\Category\Contract\CategoryRepositoryInterface;
use Visiosoft\LocationModule\City\CityModel;
use Visiosoft\LocationModule\City\CityRepository;
@ -218,7 +216,7 @@ class AdvsController extends PublicController
'list', $param, $customParameters, null, $category, $cityId, false
);
if ($isActiveDopings) {
if ($isActiveDopings && empty($param['sort_by'])) {
$featuredAdvsQuery = clone $advs;
$response__featured_doping = app('Visiosoft\DopingsModule\Http\Controller\DopingsController')
->listFeatures($featuredAdvsQuery);