mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-24 22:11:01 -06:00
#2647 emlak24 yapılacaklar
This commit is contained in:
parent
2006da4a96
commit
8f02472331
@ -1,6 +1,7 @@
|
|||||||
<?php namespace Visiosoft\LocationModule\Http\Controller;
|
<?php namespace Visiosoft\LocationModule\Http\Controller;
|
||||||
|
|
||||||
use Anomaly\Streams\Platform\Http\Controller\PublicController;
|
use Anomaly\Streams\Platform\Http\Controller\PublicController;
|
||||||
|
use Anomaly\Streams\Platform\Model\Location\LocationCitiesEntryTranslationsModel;
|
||||||
use Visiosoft\LocationModule\City\CityModel;
|
use Visiosoft\LocationModule\City\CityModel;
|
||||||
use Visiosoft\LocationModule\Country\CountryModel;
|
use Visiosoft\LocationModule\Country\CountryModel;
|
||||||
use Visiosoft\LocationModule\District\DistrictModel;
|
use Visiosoft\LocationModule\District\DistrictModel;
|
||||||
@ -30,6 +31,10 @@ class AjaxController extends PublicController
|
|||||||
* @var VillageModel
|
* @var VillageModel
|
||||||
*/
|
*/
|
||||||
private $village_model;
|
private $village_model;
|
||||||
|
/**
|
||||||
|
* @var LocationCitiesEntryTranslationsModel
|
||||||
|
*/
|
||||||
|
private $citiesEntryTranslationsModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AjaxController constructor.
|
* AjaxController constructor.
|
||||||
@ -40,7 +45,9 @@ class AjaxController extends PublicController
|
|||||||
CityModel $cityModel,
|
CityModel $cityModel,
|
||||||
DistrictModel $districtModel,
|
DistrictModel $districtModel,
|
||||||
NeighborhoodModel $neighborhoodModel,
|
NeighborhoodModel $neighborhoodModel,
|
||||||
VillageModel $villageModel)
|
VillageModel $villageModel,
|
||||||
|
LocationCitiesEntryTranslationsModel $citiesEntryTranslationsModel
|
||||||
|
)
|
||||||
{
|
{
|
||||||
$this->country_model = $countryModel;
|
$this->country_model = $countryModel;
|
||||||
$this->city_model = $cityModel;
|
$this->city_model = $cityModel;
|
||||||
@ -48,6 +55,7 @@ class AjaxController extends PublicController
|
|||||||
$this->neighborhood_model = $neighborhoodModel;
|
$this->neighborhood_model = $neighborhoodModel;
|
||||||
$this->village_model = $villageModel;
|
$this->village_model = $villageModel;
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
$this->citiesEntryTranslationsModel = $citiesEntryTranslationsModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -72,6 +80,21 @@ class AjaxController extends PublicController
|
|||||||
$id = explode(',', $this->request->id);
|
$id = explode(',', $this->request->id);
|
||||||
$query = $this->city_model->whereIn('parent_country_id', $id);
|
$query = $this->city_model->whereIn('parent_country_id', $id);
|
||||||
|
|
||||||
|
if (request()->order_by && $this->city_model->isTranslatedAttribute(request()->order_by)) {
|
||||||
|
return $this->citiesEntryTranslationsModel->newQuery()
|
||||||
|
->select('entry_id as id', 'name')
|
||||||
|
->whereIn('locale', [
|
||||||
|
Request()->session()->get('_locale'),
|
||||||
|
setting_value('streams::default_locale'),
|
||||||
|
'en'
|
||||||
|
])
|
||||||
|
->whereIn('entry_id', $query->pluck('id')->all())
|
||||||
|
->orderBy(request()->order_by)
|
||||||
|
->get();
|
||||||
|
} elseif ($orderBy = request()->order_by) {
|
||||||
|
return $this->queryOrder($query, $orderBy);
|
||||||
|
}
|
||||||
|
|
||||||
return $this->queryOrder($query);
|
return $this->queryOrder($query);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -133,10 +156,10 @@ class AjaxController extends PublicController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function queryOrder($query)
|
public function queryOrder($query, $orderBy = null)
|
||||||
{
|
{
|
||||||
$sorting_type = setting_value('visiosoft.module.location::sorting_type');
|
$sorting_type = setting_value('visiosoft.module.location::sorting_type');
|
||||||
$sorting_column = setting_value('visiosoft.module.location::sorting_column');
|
$sorting_column = $orderBy ?: setting_value('visiosoft.module.location::sorting_column');
|
||||||
|
|
||||||
return $query->orderBy($sorting_column, $sorting_type)->get();
|
return $query->orderBy($sorting_column, $sorting_type)->get();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user