setName('test') ->setDescription('调试用'); } protected function execute(Input $input, Output $output) { $validate = new TestValidate(); $date = [ 'cates' => [1, 2], 'inteval' => 1, 'number' => 1.9, ]; $res = $validate->check($date); /** @var TestServices $service */ $service = app()->make(TestServices::class); var_dump($service->get(1)->toArray()); } public function get_tree_children($data, $id = 0, $field = 'id', $pid = 'pid', $init = true) { static $children; if ($init) { $children = []; foreach ($data as $v) { $children[$v[$pid]][] = $v; } $this->log(count($children)); } var_dump($children[16]); $arr = ($children[$id] ?? []); // if (count($arr) > 0) { // foreach ($arr as &$v) { // $this->log($v[$field]); // $v['children'] = $this->get_tree_children($data, $v[$field], $field, $pid, false); // } // } return $arr; } /** * 日志输出 * @param string $msg */ private function log($msg) { $str = ""; $str .= $msg; $str .= " 时间:" . date('Y - m - d H:i:s') . PHP_EOL; @file_put_contents('test.log', "[" . date('Y - m - d H:i:s') . "]:" . $msg . PHP_EOL, FILE_APPEND); echo $str; } }