mirror of
https://github.com/openclassify/openclassify.git
synced 2026-01-24 22:11:01 -06:00
Merge pull request #433 from openclassify/vedat
get Locations and Cities
This commit is contained in:
commit
545af807ea
@ -0,0 +1,34 @@
|
|||||||
|
<?php namespace Visiosoft\LocationModule\City\Command;
|
||||||
|
|
||||||
|
use Visiosoft\LocationModule\City\CityModel;
|
||||||
|
|
||||||
|
class GetCities
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var $country
|
||||||
|
*/
|
||||||
|
protected $country;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GetProduct constructor.
|
||||||
|
* @param $country
|
||||||
|
*/
|
||||||
|
public function __construct($country)
|
||||||
|
{
|
||||||
|
$this->country = $country;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param CityModel $groups
|
||||||
|
* @return |null
|
||||||
|
*/
|
||||||
|
public function handle(CityModel $groups)
|
||||||
|
{
|
||||||
|
if ($this->country) {
|
||||||
|
return $groups->where('parent_country_id', $this->country)->get();
|
||||||
|
}
|
||||||
|
return $groups::query()->get();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
<?php namespace Visiosoft\LocationModule\Country\Command;
|
||||||
|
|
||||||
|
use Visiosoft\LocationModule\Country\CountryModel;
|
||||||
|
|
||||||
|
class GetCountries
|
||||||
|
{
|
||||||
|
|
||||||
|
public function handle(CountryModel $groups)
|
||||||
|
{
|
||||||
|
return $groups::query()->get();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,7 +1,9 @@
|
|||||||
<?php namespace Visiosoft\LocationModule;
|
<?php namespace Visiosoft\LocationModule;
|
||||||
|
|
||||||
use Anomaly\Streams\Platform\Addon\Plugin\Plugin;
|
use Anomaly\Streams\Platform\Addon\Plugin\Plugin;
|
||||||
|
use Visiosoft\LocationModule\City\Command\GetCities;
|
||||||
use Visiosoft\LocationModule\City\Command\GetCity;
|
use Visiosoft\LocationModule\City\Command\GetCity;
|
||||||
|
use Visiosoft\LocationModule\Country\Command\GetCountries;
|
||||||
use Visiosoft\LocationModule\Country\Command\GetCountry;
|
use Visiosoft\LocationModule\Country\Command\GetCountry;
|
||||||
use Visiosoft\LocationModule\District\Command\GetDistrict;
|
use Visiosoft\LocationModule\District\Command\GetDistrict;
|
||||||
use Visiosoft\LocationModule\Neighborhood\Command\GetNeighborhood;
|
use Visiosoft\LocationModule\Neighborhood\Command\GetNeighborhood;
|
||||||
@ -49,6 +51,17 @@ class LocationModulePlugin extends Plugin
|
|||||||
return $ad;
|
return $ad;
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
new \Twig_SimpleFunction(
|
||||||
|
'getCities',
|
||||||
|
function ($country = null) {
|
||||||
|
|
||||||
|
if (!$ad = $this->dispatch(new GetCities($country))) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $ad;
|
||||||
|
}
|
||||||
|
),
|
||||||
new \Twig_SimpleFunction(
|
new \Twig_SimpleFunction(
|
||||||
'getCountry',
|
'getCountry',
|
||||||
function ($id) {
|
function ($id) {
|
||||||
@ -60,6 +73,16 @@ class LocationModulePlugin extends Plugin
|
|||||||
return $ad;
|
return $ad;
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
|
new \Twig_SimpleFunction(
|
||||||
|
'getCountries',
|
||||||
|
function () {
|
||||||
|
|
||||||
|
if (!$ad = $this->dispatch(new GetCountries())) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return $ad;
|
||||||
|
}
|
||||||
|
),
|
||||||
new \Twig_SimpleFunction(
|
new \Twig_SimpleFunction(
|
||||||
'getVillage',
|
'getVillage',
|
||||||
function ($id) {
|
function ($id) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user