@@ -104,8 +104,7 @@ discard block |
||
| 104 | 104 | { |
| 105 | 105 | $createHtml = $this->formGenerator->generateForm($entity); |
| 106 | 106 | $editHtml = $this->formGenerator->generateForm($entity,'put'); |
| 107 | - } |
|
| 108 | - else |
|
| 107 | + } else |
|
| 109 | 108 | { |
| 110 | 109 | if(!$this->confirm('There is no entity for '.$this->repoName.", do you want to continue (this will disable form generator) ?")) |
| 111 | 110 | { |
@@ -132,8 +131,9 @@ discard block |
||
| 132 | 131 | function getEntity($path) |
| 133 | 132 | { |
| 134 | 133 | $myClass = 'App\Entities\\'.$path."\\".$this->repoName; |
| 135 | - if(!class_exists($myClass)) |
|
| 136 | - return false; |
|
| 134 | + if(!class_exists($myClass)) { |
|
| 135 | + return false; |
|
| 136 | + } |
|
| 137 | 137 | |
| 138 | 138 | $refl = new ReflectionClass($myClass); |
| 139 | 139 | |
@@ -60,13 +60,13 @@ discard block |
||
| 60 | 60 | */ |
| 61 | 61 | public function handle() |
| 62 | 62 | { |
| 63 | - $file = preg_split( " (/|\\\\) ", (string)$this->argument('name')) ?? []; |
|
| 63 | + $file = preg_split(" (/|\\\\) ", (string) $this->argument('name')) ?? []; |
|
| 64 | 64 | $this->repoName = $file[count($file) - 1]; |
| 65 | 65 | |
| 66 | 66 | unset($file[count($file) - 1]); |
| 67 | 67 | $path = implode("\\", $file); |
| 68 | 68 | |
| 69 | - if($this->option('only-view')) |
|
| 69 | + if ($this->option('only-view')) |
|
| 70 | 70 | { |
| 71 | 71 | $this->makeViewsAndLanguage($path); |
| 72 | 72 | return null; |
@@ -77,9 +77,9 @@ discard block |
||
| 77 | 77 | |
| 78 | 78 | function makeRepositoryPatternFiles($path) |
| 79 | 79 | { |
| 80 | - $model= str_plural(\Config::get('repository.model')); |
|
| 81 | - $interface= str_plural(\Config::get('repository.interface')); |
|
| 82 | - $repository= str_plural(\Config::get('repository.repository')); |
|
| 80 | + $model = str_plural(\Config::get('repository.model')); |
|
| 81 | + $interface = str_plural(\Config::get('repository.interface')); |
|
| 82 | + $repository = str_plural(\Config::get('repository.repository')); |
|
| 83 | 83 | |
| 84 | 84 | $this->generate($path, \Config::get('repository.controllers_folder'), 'Controller'); |
| 85 | 85 | $this->generate($path, $model, 'Entity'); |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | $this->generate($path, $interface, 'Interface'); |
| 88 | 88 | $this->generate($path, $repository, 'Repository'); |
| 89 | 89 | |
| 90 | - File::append(\Config::get('repository.route_path') . '/web.php', "\n" . 'Route::resource(\'' . strtolower(str_plural($this->repoName)) . "', '".$path."\\".$this->repoName."Controller');"); |
|
| 90 | + File::append(\Config::get('repository.route_path') . '/web.php', "\n" . 'Route::resource(\'' . strtolower(str_plural($this->repoName)) . "', '" . $path . "\\" . $this->repoName . "Controller');"); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | /** |
@@ -100,14 +100,14 @@ discard block |
||
| 100 | 100 | |
| 101 | 101 | $createHtml = ''; |
| 102 | 102 | $editHtml = ''; |
| 103 | - if($entity instanceof Model) |
|
| 103 | + if ($entity instanceof Model) |
|
| 104 | 104 | { |
| 105 | 105 | $createHtml = $this->formGenerator->generateForm($entity); |
| 106 | - $editHtml = $this->formGenerator->generateForm($entity,'put'); |
|
| 106 | + $editHtml = $this->formGenerator->generateForm($entity, 'put'); |
|
| 107 | 107 | } |
| 108 | 108 | else |
| 109 | 109 | { |
| 110 | - if(!$this->confirm('There is no entity for '.$this->repoName.", do you want to continue (this will disable form generator) ?")) |
|
| 110 | + if (!$this->confirm('There is no entity for ' . $this->repoName . ", do you want to continue (this will disable form generator) ?")) |
|
| 111 | 111 | { |
| 112 | 112 | echo "Dispatch .."; |
| 113 | 113 | die; |
@@ -116,12 +116,12 @@ discard block |
||
| 116 | 116 | |
| 117 | 117 | foreach (\Config::get('repository.languages') as $lang) |
| 118 | 118 | { |
| 119 | - $this->generate(lcfirst($this->repoName),\Config::get('repository.lang_path')."/{$lang}" , 'lang'); |
|
| 119 | + $this->generate(lcfirst($this->repoName), \Config::get('repository.lang_path') . "/{$lang}", 'lang'); |
|
| 120 | 120 | } |
| 121 | - $this->generate(lcfirst($this->repoName),\Config::get('repository.resources_path')."/views" , 'create',$createHtml); |
|
| 122 | - $this->generate(lcfirst($this->repoName),\Config::get('repository.resources_path')."/views" , 'edit',$editHtml); |
|
| 123 | - $this->generate(lcfirst($this->repoName),\Config::get('repository.resources_path')."/views" , 'index'); |
|
| 124 | - $this->generate(lcfirst($this->repoName),\Config::get('repository.resources_path')."/views" , 'show'); |
|
| 121 | + $this->generate(lcfirst($this->repoName), \Config::get('repository.resources_path') . "/views", 'create', $createHtml); |
|
| 122 | + $this->generate(lcfirst($this->repoName), \Config::get('repository.resources_path') . "/views", 'edit', $editHtml); |
|
| 123 | + $this->generate(lcfirst($this->repoName), \Config::get('repository.resources_path') . "/views", 'index'); |
|
| 124 | + $this->generate(lcfirst($this->repoName), \Config::get('repository.resources_path') . "/views", 'show'); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | /** |
@@ -131,8 +131,8 @@ discard block |
||
| 131 | 131 | */ |
| 132 | 132 | function getEntity($path) |
| 133 | 133 | { |
| 134 | - $myClass = 'App\Entities\\'.$path."\\".$this->repoName; |
|
| 135 | - if(!class_exists($myClass)) |
|
| 134 | + $myClass = 'App\Entities\\' . $path . "\\" . $this->repoName; |
|
| 135 | + if (!class_exists($myClass)) |
|
| 136 | 136 | return false; |
| 137 | 137 | |
| 138 | 138 | $refl = new ReflectionClass($myClass); |
@@ -158,13 +158,13 @@ discard block |
||
| 158 | 158 | * @param string $form |
| 159 | 159 | * @return bool |
| 160 | 160 | */ |
| 161 | - protected function generate($path, $folder, $type,$form ='') |
|
| 161 | + protected function generate($path, $folder, $type, $form = '') |
|
| 162 | 162 | { |
| 163 | 163 | $content = $this->getStub($type); |
| 164 | 164 | |
| 165 | - if($content === false) |
|
| 165 | + if ($content === false) |
|
| 166 | 166 | { |
| 167 | - echo 'file '.$type.".stub is not exist !"; |
|
| 167 | + echo 'file ' . $type . ".stub is not exist !"; |
|
| 168 | 168 | return false; |
| 169 | 169 | } |
| 170 | 170 | |
@@ -183,21 +183,21 @@ discard block |
||
| 183 | 183 | str_plural(lcfirst($this->repoName)), |
| 184 | 184 | str_plural($folder), |
| 185 | 185 | $path, |
| 186 | - str_plural(\Config::get('repository.model','Entity')), |
|
| 187 | - str_plural(\Config::get('repository.interface','Interface')), |
|
| 186 | + str_plural(\Config::get('repository.model', 'Entity')), |
|
| 187 | + str_plural(\Config::get('repository.interface', 'Interface')), |
|
| 188 | 188 | $form |
| 189 | 189 | ], |
| 190 | 190 | $this->getStub($type) |
| 191 | 191 | ); |
| 192 | 192 | |
| 193 | - $folder = str_replace('\\','/',$folder); |
|
| 194 | - $path = str_replace('\\','/',$path); |
|
| 193 | + $folder = str_replace('\\', '/', $folder); |
|
| 194 | + $path = str_replace('\\', '/', $path); |
|
| 195 | 195 | |
| 196 | 196 | switch ($type) |
| 197 | 197 | { |
| 198 | 198 | case 'Entity': |
| 199 | 199 | $filePath = $this->getFolderOrCreate(\Config::get('repository.app_path') . "/{$folder}/{$path}"); |
| 200 | - $filePath = rtrim($filePath,'/'); |
|
| 200 | + $filePath = rtrim($filePath, '/'); |
|
| 201 | 201 | $filePath .= "/"; |
| 202 | 202 | file_put_contents($filePath . "{$this->repoName}.php", $template); |
| 203 | 203 | break; |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | case 'Repository': |
| 207 | 207 | case 'Interface': |
| 208 | 208 | $filePath = $this->getFolderOrCreate(\Config::get('repository.app_path') . "/{$folder}/{$path}"); |
| 209 | - $filePath = rtrim($filePath,'/'); |
|
| 209 | + $filePath = rtrim($filePath, '/'); |
|
| 210 | 210 | $filePath .= "/"; |
| 211 | 211 | file_put_contents($filePath . "{$this->repoName}{$type}.php", $template); |
| 212 | 212 | break; |
@@ -214,14 +214,14 @@ discard block |
||
| 214 | 214 | case 'edit': |
| 215 | 215 | case 'index': |
| 216 | 216 | case 'show': |
| 217 | - $filePath = $this->getFolderOrCreate($folder."/".str_plural($path))."/"; |
|
| 217 | + $filePath = $this->getFolderOrCreate($folder . "/" . str_plural($path)) . "/"; |
|
| 218 | 218 | $repoName = lcfirst($type); |
| 219 | - file_put_contents($filePath . $repoName.".blade.php", $template); |
|
| 219 | + file_put_contents($filePath . $repoName . ".blade.php", $template); |
|
| 220 | 220 | break; |
| 221 | 221 | default: |
| 222 | - $filePath = $this->getFolderOrCreate($folder)."/"; |
|
| 222 | + $filePath = $this->getFolderOrCreate($folder) . "/"; |
|
| 223 | 223 | $repoName = lcfirst($this->repoName); |
| 224 | - file_put_contents($filePath . $repoName.".php", $template); |
|
| 224 | + file_put_contents($filePath . $repoName . ".php", $template); |
|
| 225 | 225 | } |
| 226 | 226 | return true; |
| 227 | 227 | } |