mirror of
https://github.com/openclassify/openclassify.git
synced 2026-03-10 10:15:28 -05:00
#2647 emlak24 yapılacaklar
This commit is contained in:
parent
8f02472331
commit
4a25e7834a
@ -1,5 +1,6 @@
|
||||
<?php namespace Visiosoft\LocationModule\City;
|
||||
|
||||
use Anomaly\Streams\Platform\Model\Location\LocationCitiesEntryTranslationsModel;
|
||||
use Visiosoft\LocationModule\City\Contract\CityRepositoryInterface;
|
||||
use Anomaly\Streams\Platform\Entry\EntryRepository;
|
||||
|
||||
@ -13,18 +14,38 @@ class CityRepository extends EntryRepository implements CityRepositoryInterface
|
||||
*/
|
||||
protected $model;
|
||||
|
||||
/**
|
||||
* @var LocationCitiesEntryTranslationsModel
|
||||
*/
|
||||
private $citiesEntryTranslationsModel;
|
||||
|
||||
/**
|
||||
* Create a new CityRepository instance.
|
||||
*
|
||||
* @param CityModel $model
|
||||
*/
|
||||
public function __construct(CityModel $model)
|
||||
public function __construct(CityModel $model, LocationCitiesEntryTranslationsModel $citiesEntryTranslationsModel)
|
||||
{
|
||||
$this->model = $model;
|
||||
$this->citiesEntryTranslationsModel = $citiesEntryTranslationsModel;
|
||||
}
|
||||
|
||||
public function findById($id)
|
||||
{
|
||||
return $this->model->orderBy('created_at', 'DESC')->where('location_cities.id', $id)->first();
|
||||
}
|
||||
|
||||
public function getByEntryIDsAndOrderByTransCol($entryIDs, $orderBy)
|
||||
{
|
||||
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', $entryIDs)
|
||||
->orderBy($orderBy)
|
||||
->get();
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,4 +5,6 @@ use Anomaly\Streams\Platform\Entry\Contract\EntryRepositoryInterface;
|
||||
interface CityRepositoryInterface extends EntryRepositoryInterface
|
||||
{
|
||||
public function findById($id);
|
||||
|
||||
public function getByEntryIDsAndOrderByTransCol($entryIDs, $orderBy);
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
use Anomaly\Streams\Platform\Http\Controller\PublicController;
|
||||
use Anomaly\Streams\Platform\Model\Location\LocationCitiesEntryTranslationsModel;
|
||||
use Visiosoft\LocationModule\City\CityModel;
|
||||
use Visiosoft\LocationModule\City\Contract\CityRepositoryInterface;
|
||||
use Visiosoft\LocationModule\Country\CountryModel;
|
||||
use Visiosoft\LocationModule\District\DistrictModel;
|
||||
use Visiosoft\LocationModule\Neighborhood\NeighborhoodModel;
|
||||
@ -11,56 +12,34 @@ use Illuminate\Support\Str;
|
||||
|
||||
class AjaxController extends PublicController
|
||||
{
|
||||
/**
|
||||
* @var CountryModel
|
||||
*/
|
||||
private $country_model;
|
||||
/**
|
||||
* @var CityModel
|
||||
*/
|
||||
private $city_model;
|
||||
/**
|
||||
* @var DistrictModel
|
||||
*/
|
||||
private $district_model;
|
||||
/**
|
||||
* @var NeighborhoodModel
|
||||
*/
|
||||
private $neighborhood_model;
|
||||
/**
|
||||
* @var VillageModel
|
||||
*/
|
||||
private $village_model;
|
||||
/**
|
||||
* @var LocationCitiesEntryTranslationsModel
|
||||
*/
|
||||
private $citiesEntryTranslationsModel;
|
||||
private $cityRepository;
|
||||
|
||||
/**
|
||||
* AjaxController constructor.
|
||||
* @param CountryModel $countryModel
|
||||
*/
|
||||
public function __construct(
|
||||
CountryModel $countryModel,
|
||||
CityModel $cityModel,
|
||||
DistrictModel $districtModel,
|
||||
NeighborhoodModel $neighborhoodModel,
|
||||
VillageModel $villageModel,
|
||||
LocationCitiesEntryTranslationsModel $citiesEntryTranslationsModel
|
||||
LocationCitiesEntryTranslationsModel $citiesEntryTranslationsModel,
|
||||
CityRepositoryInterface $cityRepository
|
||||
)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->country_model = $countryModel;
|
||||
$this->city_model = $cityModel;
|
||||
$this->district_model = $districtModel;
|
||||
$this->neighborhood_model = $neighborhoodModel;
|
||||
$this->village_model = $villageModel;
|
||||
parent::__construct();
|
||||
$this->citiesEntryTranslationsModel = $citiesEntryTranslationsModel;
|
||||
$this->cityRepository = $cityRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCountries()
|
||||
{
|
||||
if ($this->request->id)
|
||||
@ -71,9 +50,6 @@ class AjaxController extends PublicController
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCities()
|
||||
{
|
||||
if ($this->request->id) {
|
||||
@ -81,16 +57,10 @@ class AjaxController extends PublicController
|
||||
$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();
|
||||
return $this->cityRepository->getByEntryIDsAndOrderByTransCol(
|
||||
$query->pluck('id')->all(),
|
||||
request()->order_by
|
||||
);
|
||||
} elseif ($orderBy = request()->order_by) {
|
||||
return $this->queryOrder($query, $orderBy);
|
||||
}
|
||||
@ -99,9 +69,6 @@ class AjaxController extends PublicController
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDistricts()
|
||||
{
|
||||
if ($this->request->id) {
|
||||
@ -113,9 +80,6 @@ class AjaxController extends PublicController
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getNeighborhoods()
|
||||
{
|
||||
if ($this->request->id) {
|
||||
@ -127,9 +91,6 @@ class AjaxController extends PublicController
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getVillage()
|
||||
{
|
||||
if ($this->request->id) {
|
||||
@ -141,9 +102,6 @@ class AjaxController extends PublicController
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCity()
|
||||
{
|
||||
if ($this->request->name) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user