get Detail function on twig for Address and Location Module

This commit is contained in:
vedatakd 2019-12-24 18:49:35 +03:00
parent ca5bd2cac9
commit a05417c57b
5 changed files with 137 additions and 0 deletions

View File

@ -0,0 +1,34 @@
<?php namespace Visiosoft\LocationModule\City\Command;
use Visiosoft\LocationModule\City\CityModel;
class GetCity
{
/**
* @var $id
*/
protected $id;
/**
* GetProduct constructor.
* @param $id
*/
public function __construct($id)
{
$this->id = $id;
}
/**
* @param CityModel $groups
* @return |null
*/
public function handle(CityModel $groups)
{
if ($this->id) {
return $groups->find($this->id);
}
return null;
}
}

View File

@ -0,0 +1,33 @@
<?php namespace Visiosoft\LocationModule\Country\Command;
use Visiosoft\LocationModule\Country\CountryModel;
class GetCountry
{
/**
* @var $id
*/
protected $id;
/**
* GetProduct constructor.
* @param $id
*/
public function __construct($id)
{
$this->id = $id;
}
/**
* @param CountryModel $groups
* @return |null
*/
public function handle(CountryModel $groups)
{
if ($this->id) {
return $groups->find($this->id);
}
return null;
}
}

View File

@ -1,6 +1,8 @@
<?php namespace Visiosoft\LocationModule;
use Anomaly\Streams\Platform\Addon\Plugin\Plugin;
use Visiosoft\LocationModule\City\Command\GetCity;
use Visiosoft\LocationModule\Country\Command\GetCountry;
use Visiosoft\LocationModule\District\Command\GetDistrict;
use Visiosoft\LocationModule\Neighborhood\Command\GetNeighborhood;
@ -32,6 +34,28 @@ class LocationModulePlugin extends Plugin
return null;
}
return $ad;
}
),
new \Twig_SimpleFunction(
'getCity',
function ($id) {
if (!$ad = $this->dispatch(new GetCity($id))) {
return null;
}
return $ad;
}
),
new \Twig_SimpleFunction(
'getCountry',
function ($id) {
if (!$ad = $this->dispatch(new GetCountry($id))) {
return null;
}
return $ad;
}
),

View File

@ -0,0 +1,34 @@
<?php namespace Visiosoft\ProfileModule\Adress\Command;
use Visiosoft\ProfileModule\Adress\Contract\AdressRepositoryInterface;
class GetAddress
{
/**
* @var $id
*/
protected $id;
/**
* GetProduct constructor.
* @param $id
*/
public function __construct($id)
{
$this->id = $id;
}
/**
* @param AdressRepositoryInterface $adressRepository
* @return \Anomaly\Streams\Platform\Model\EloquentModel|null
*/
public function handle(AdressRepositoryInterface $adressRepository)
{
if ($this->id) {
return $adressRepository->find($this->id);
}
return null;
}
}

View File

@ -1,6 +1,7 @@
<?php namespace Visiosoft\ProfileModule;
use Anomaly\Streams\Platform\Addon\Plugin\Plugin;
use Visiosoft\ProfileModule\Adress\Command\GetAddress;
use Visiosoft\ProfileModule\Profile\Command\FindUserProfile;
class ProfileModulePlugin extends Plugin
@ -20,6 +21,17 @@ class ProfileModulePlugin extends Plugin
return null;
}
return $ad;
}
),
new \Twig_SimpleFunction(
'getAddress',
function ($id) {
if (!$ad = $this->dispatch(new GetAddress($id))) {
return null;
}
return $ad;
}
)