Task.php 890 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace app\admin\command;
  3. use think\console\Command;
  4. use think\console\Input;
  5. use think\console\input\Option;
  6. use think\console\Output;
  7. use think\Exception;
  8. use app\common\model\Region;
  9. class Task extends Command
  10. {
  11. protected function configure()
  12. {
  13. $this->setName('task')->setDescription('Compress js and css file');
  14. }
  15. protected function execute(Input $input, Output $output)
  16. {
  17. $reg = new Region();
  18. $list = collection($reg::where('level', '=', 1)->select())->toArray();
  19. $arr = array();
  20. foreach ($list as $key => $value) {
  21. $arr[$value['id']] = $reg->where('parent_id', '=', $value['id'])->column('id,name');
  22. }
  23. file_put_contents('./11.txt', json_encode($arr, JSON_UNESCAPED_UNICODE));
  24. $output->info("Ok Successed!");
  25. }
  26. }