| @@ 26-44 (lines=19) @@ | ||
| 23 | $this->addArgument('name', InputArgument::REQUIRED); |
|
| 24 | } |
|
| 25 | ||
| 26 | public function execute(InputInterface $input, OutputInterface $output) |
|
| 27 | { |
|
| 28 | $controllerPath = app()->getPath().'/src/Controller'; |
|
| 29 | if (!file_exists($controllerPath)) { |
|
| 30 | mkdir($controllerPath, 0755, true); |
|
| 31 | } |
|
| 32 | ||
| 33 | $name = ucfirst($input->getArgument('name')).'Controller'; |
|
| 34 | $content = $this->createControllerTemplate($name); |
|
| 35 | ||
| 36 | $controllerFile = $controllerPath.'/'.$name.'.php'; |
|
| 37 | ||
| 38 | if (file_exists($controllerFile)) { |
|
| 39 | throw new \LogicException(sprintf('Controller %s is already exists', $name)); |
|
| 40 | } |
|
| 41 | ||
| 42 | file_put_contents($controllerFile, $content); |
|
| 43 | $output->writeln(sprintf('Controller %s created successful. path in %s', $name, $controllerPath)); |
|
| 44 | } |
|
| 45 | ||
| 46 | public function createControllerTemplate($name) |
|
| 47 | { |
|
| @@ 29-47 (lines=19) @@ | ||
| 26 | $this->addArgument('name', InputArgument::REQUIRED); |
|
| 27 | } |
|
| 28 | ||
| 29 | public function execute(InputInterface $input, OutputInterface $output) |
|
| 30 | { |
|
| 31 | $modelPath = app()->getPath().'/src/Model'; |
|
| 32 | if (!file_exists($modelPath)) { |
|
| 33 | mkdir($modelPath, 0755, true); |
|
| 34 | } |
|
| 35 | ||
| 36 | $name = ucfirst($input->getArgument('name')).'Model'; |
|
| 37 | $content = $this->createModelTemplate($name); |
|
| 38 | ||
| 39 | $modelFile = $modelPath.'/'.$name.'.php'; |
|
| 40 | ||
| 41 | if (file_exists($modelFile)) { |
|
| 42 | throw new \LogicException(sprintf('Model %s is already exists', $name)); |
|
| 43 | } |
|
| 44 | ||
| 45 | file_put_contents($modelFile, $content); |
|
| 46 | $output->writeln(sprintf('Model %s created successful. path in %s', $name, $modelPath)); |
|
| 47 | } |
|
| 48 | ||
| 49 | protected function createModelTemplate($name) |
|
| 50 | { |
|