48 lines
1.2 KiB
PHP
48 lines
1.2 KiB
PHP
<?php
|
|
|
|
use KupShop\KupShopBundle\Util\Functional\Mapping;
|
|
|
|
class FANCourier extends Delivery
|
|
{
|
|
public static $className = 'FAN Courier';
|
|
|
|
public static $tableName = '`kupshop_shared`.`delivery_ro_regions`';
|
|
|
|
private $county;
|
|
|
|
public static function isEnabled()
|
|
{
|
|
return findModule('deliveries', 'ro_deliveries');
|
|
}
|
|
|
|
public function getCounty()
|
|
{
|
|
if ($this->county) {
|
|
return $this->county;
|
|
}
|
|
|
|
$county = sqlQueryBuilder()->select('county')
|
|
->from(self::$tableName)
|
|
->groupBy('county')
|
|
->orderBy('county', 'ASC')
|
|
->execute()->fetchAll();
|
|
|
|
return $this->county = Mapping::mapKeys($county, function ($k, $v) {
|
|
return [$k, $v['county']];
|
|
});
|
|
}
|
|
|
|
public function getCities($county)
|
|
{
|
|
$cities = sqlQueryBuilder()->select('city')
|
|
->from(self::$tableName)
|
|
->where(\Query\Operator::equals(['county' => $county]))
|
|
->orderBy('city', 'ASC')
|
|
->execute()->fetchAll();
|
|
|
|
return Mapping::mapKeys($cities, function ($k, $v) {
|
|
return [$k, $v['city']];
|
|
});
|
|
}
|
|
}
|