47 lines
1.1 KiB
PHP
47 lines
1.1 KiB
PHP
|
<?php
|
|||
|
|
|||
|
namespace Model\Constant;
|
|||
|
|
|||
|
class ShopOtdel extends Constant
|
|||
|
{
|
|||
|
|
|||
|
public function __construct()
|
|||
|
{
|
|||
|
self::$tableName = 'const_shop_otdels';
|
|||
|
parent::__construct();
|
|||
|
}
|
|||
|
|
|||
|
public function getName(int $id): string
|
|||
|
{
|
|||
|
foreach ($this->rows as $row) {
|
|||
|
if ($row['id'] === $id) {
|
|||
|
return $row['name'];
|
|||
|
}
|
|||
|
}
|
|||
|
return '';
|
|||
|
}
|
|||
|
|
|||
|
/**
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <EFBFBD><EFBFBD><EFBFBD> id <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD> <EFBFBD><EFBFBD> legacy-<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.
|
|||
|
* @return array
|
|||
|
*/
|
|||
|
public function getGroups(): array
|
|||
|
{
|
|||
|
$groups = [];
|
|||
|
foreach ($this->getGrouped() as $name => $arr) {
|
|||
|
$groups[$name] = array_keys($arr)[0];
|
|||
|
}
|
|||
|
return array_flip($groups);
|
|||
|
}
|
|||
|
|
|||
|
public function getGrouped(): array
|
|||
|
{
|
|||
|
$result = [];
|
|||
|
foreach ($this->rows as $row) {
|
|||
|
//$result[$row['id']] = [$row['name'], $row['group_name']];
|
|||
|
$result[$row['group_name']][$row['id']] = $row['name'];
|
|||
|
}
|
|||
|
return $result;
|
|||
|
}
|
|||
|
}
|