@@ -48,27 +48,27 @@ discard block |
||
| 48 | 48 | $dbName = $input->getOption('db'); |
| 49 | 49 | $tables = $this->app->db->getConnection()->getTables($dbName); |
| 50 | 50 | } else { |
| 51 | - if (empty($app) && !is_dir($this->app->getBasePath() . 'controller')) { |
|
| 51 | + if (empty($app) && !is_dir($this->app->getBasePath().'controller')) { |
|
| 52 | 52 | $output->writeln('<error>Miss app name!</error>'); |
| 53 | 53 | return false; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | if ($app) { |
| 57 | - $appPath = $this->app->getBasePath() . $app . DIRECTORY_SEPARATOR; |
|
| 58 | - $namespace = 'app\\' . $app; |
|
| 57 | + $appPath = $this->app->getBasePath().$app.DIRECTORY_SEPARATOR; |
|
| 58 | + $namespace = 'app\\'.$app; |
|
| 59 | 59 | } else { |
| 60 | 60 | $appPath = $this->app->getBasePath(); |
| 61 | 61 | $namespace = 'app'; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - $path = $appPath . 'model'; |
|
| 64 | + $path = $appPath.'model'; |
|
| 65 | 65 | $list = is_dir($path) ? scandir($path) : []; |
| 66 | 66 | |
| 67 | 67 | foreach ($list as $file) { |
| 68 | 68 | if (0 === strpos($file, '.')) { |
| 69 | 69 | continue; |
| 70 | 70 | } |
| 71 | - $class = '\\' . $namespace . '\\model\\' . pathinfo($file, PATHINFO_FILENAME); |
|
| 71 | + $class = '\\'.$namespace.'\\model\\'.pathinfo($file, PATHINFO_FILENAME); |
|
| 72 | 72 | $this->buildModelSchema($class); |
| 73 | 73 | } |
| 74 | 74 | |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | return; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - $db = isset($dbName) ? $dbName . '.' : ''; |
|
| 79 | + $db = isset($dbName) ? $dbName.'.' : ''; |
|
| 80 | 80 | $this->buildDataBaseSchema($schemaPath, $tables, $db); |
| 81 | 81 | |
| 82 | 82 | $output->writeln('<info>Succeed!</info>'); |
@@ -93,27 +93,27 @@ discard block |
||
| 93 | 93 | $table = $model->getTable(); |
| 94 | 94 | $dbName = $model->getConnection()->getConfig('database'); |
| 95 | 95 | $path = $model->getConnection()->getConfig('schema_cache_path'); |
| 96 | - $content = '<?php ' . PHP_EOL . 'return '; |
|
| 96 | + $content = '<?php '.PHP_EOL.'return '; |
|
| 97 | 97 | $info = $model->db()->getConnection()->getFields($table); |
| 98 | - $content .= var_export($info, true) . ';'; |
|
| 98 | + $content .= var_export($info, true).';'; |
|
| 99 | 99 | |
| 100 | - file_put_contents($path . $dbName . '.' . $table . '.php', $content); |
|
| 100 | + file_put_contents($path.$dbName.'.'.$table.'.php', $content); |
|
| 101 | 101 | } |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | protected function buildDataBaseSchema(string $path, array $tables, string $db): void |
| 105 | 105 | { |
| 106 | 106 | if ('' == $db) { |
| 107 | - $dbName = $this->app->db->getConnection()->getConfig('database') . '.'; |
|
| 107 | + $dbName = $this->app->db->getConnection()->getConfig('database').'.'; |
|
| 108 | 108 | } else { |
| 109 | 109 | $dbName = $db; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | foreach ($tables as $table) { |
| 113 | - $content = '<?php ' . PHP_EOL . 'return '; |
|
| 114 | - $info = $this->app->db->getConnection()->getFields($db . $table); |
|
| 115 | - $content .= var_export($info, true) . ';'; |
|
| 116 | - file_put_contents($path . $dbName . $table . '.php', $content); |
|
| 113 | + $content = '<?php '.PHP_EOL.'return '; |
|
| 114 | + $info = $this->app->db->getConnection()->getFields($db.$table); |
|
| 115 | + $content .= var_export($info, true).';'; |
|
| 116 | + file_put_contents($path.$dbName.$table.'.php', $content); |
|
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | } |