class Menu extends ActiveRecord
{
// ...
public static function getList()
{
$data = static::find()
->select(['id', 'parent_id', 'title'])
->orderBy('parent_id ASC')
->asArray()
->all();
$sort = new SortList([
'data' => $data,
'prefix' => '------',
]);
$sortList = ArrayHelper::map($sort->getList(), 'id', 'title');
return $sortList;
}
}
class SortList extends Object
{
public $data;
public $prefix = ' ';
protected function getPath($category_id, $prefix = false)
{
foreach ($this->data as $item) {
if ($category_id == $item['id']) {
$prefix = $prefix ? $this->prefix . $prefix : $item['title'];
if ($item['parent_id']) {
return $this->getPath($item['parent_id'], $prefix);
} else {
return $prefix;
}
}
}
return '';
}
public function getList($parent_id = 0)
{
$data = [];
foreach ($this->data as $item) {
if ($parent_id == $item['parent_id']) {
$data[] = [
'id' => $item['id'],
'title' => $this->getPath($item['id'])
];
$data = array_merge($data, $this->getList($item['id']));
}
}
return $data;
}
}
<div class="box">
<div class="block block_1">block # 1</div>
<div class="block block_2">block # 2</div>
<div class="block block_3">block # 3</div>
</div>
.box{
width: 400px;
margin: 50px auto;
}
.box:before {
background-color: rgb(100, 250, 100);
display: block;
content: "full";
}
.block {
width: 33.3333%;
height: 100px;
border: 1px dotted black;
box-sizing: border-box;
display: inline-block;
}
.block_1 {
float: none;
}
.block_2 {
float: left;
}
.block_3{
float: right;
}
@media (max-width: 600px) {
.box:before {
background-color: rgb(150, 150, 250);
content: "mobile";
}
.block_1 {
width: 100%;
}
.block_2 {
width: 50%;
}
.block_3{
width: 50%;
float: left;
}
}
The idea is to solve the common issues with connecting those frameworks, build a robust framework to support daily development needs, and help developers use better practices while working with popular JavaScript components.
drop database dbname; create database dbname; это если полные доступы. Или получить список таблиц из show tables, и в цикле при переборе массива удалять по названию drop table tbl_name