| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- namespace app\admin\command;
- use think\console\Command;
- use think\console\Input;
- use think\console\input\Option;
- use think\console\Output;
- use think\Exception;
- use app\common\model\Region;
- class Task extends Command
- {
-
- protected function configure()
- {
- $this->setName('task')->setDescription('Compress js and css file');
- }
- protected function execute(Input $input, Output $output)
- {
- $reg = new Region();
- $list = $reg::where('level', '=', 1)->field('id,name,ext_id')->select();
- $arr = array();
-
- foreach ($list as $i=>$item) {
- $arr[$i]['label'] = $item->name;
- $arr[$i]['id'] = $item->ext_id;
- $list1 =$reg::where('parent_id', '=', $item->id)->field('id,name,ext_id')->select();
-
- foreach ($list1 as $j => $item1) {
- $arr[$i]['children'][$j]['label'] = $item1->name;
- $arr[$i]['children'][$j]['id'] = $item1->ext_id;
- $list2 =$reg::where('parent_id', '=', $item1->id)->field('id,name,ext_id')->select();
- foreach ($list2 as $s => $item2) {
- $arr[$i]['children'][$j]['children'][$s]['label'] = $item2->name;
- $arr[$i]['children'][$j]['children'][$s]['id'] = $item2->ext_id;
- $list3 =$reg::where('parent_id', '=', $item2->id)->field('id,name,ext_id')->select();
- foreach ($list3 as $d => $item3) {
- if(!empty($item3)){
- $arr[$i]['children'][$j]['children'][$s]['children'][$d]['label'] = $item3->name;
- $arr[$i]['children'][$j]['children'][$s]['children'][$d]['id'] = $item3->ext_id;
- }
-
- }
-
- }
-
- }
-
- }
- file_put_contents('./11.txt', json_encode($arr, JSON_UNESCAPED_UNICODE));
- $output->info("Ok Successed!");
- }
- }
|