@@ -6,11 +6,11 @@ |
||
6 | 6 | * Time: 09:58 am |
7 | 7 | */ |
8 | 8 | return [ |
9 | - 'app_path' => realpath(__DIR__.'/../app/'), |
|
9 | + 'app_path' => realpath(__DIR__ . '/../app/'), |
|
10 | 10 | 'route_path' => realpath('routes/'), |
11 | - 'resources_path' => realpath(__DIR__.'/../vendor/shamaseen/repository-generator/stubs'), |
|
12 | - 'stubs_path' => realpath('resources')."/stubs", |
|
13 | - 'lang_path' => realpath('resources')."/lang", |
|
11 | + 'resources_path' => realpath(__DIR__ . '/../vendor/shamaseen/repository-generator/stubs'), |
|
12 | + 'stubs_path' => realpath('resources') . "/stubs", |
|
13 | + 'lang_path' => realpath('resources') . "/lang", |
|
14 | 14 | |
15 | 15 | //relative to app path |
16 | 16 | 'interface' => 'Interface', |
@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public function handle() |
57 | 57 | { |
58 | - $file = preg_split( " (/|\\\\) ", (string)$this->argument('name')) ?? []; |
|
58 | + $file = preg_split(" (/|\\\\) ", (string) $this->argument('name')) ?? []; |
|
59 | 59 | $this->repoName = $file[count($file) - 1]; |
60 | - if($this->option('only-view')) |
|
60 | + if ($this->option('only-view')) |
|
61 | 61 | { |
62 | 62 | $this->makeViewsAndLanguage(); |
63 | 63 | return null; |
@@ -71,9 +71,9 @@ discard block |
||
71 | 71 | unset($file[count($file) - 1]); |
72 | 72 | $path = implode("\\", $file); |
73 | 73 | |
74 | - $model= str_plural(\Config::get('repository.model')); |
|
75 | - $interface= str_plural(\Config::get('repository.interface')); |
|
76 | - $repository= str_plural(\Config::get('repository.repository')); |
|
74 | + $model = str_plural(\Config::get('repository.model')); |
|
75 | + $interface = str_plural(\Config::get('repository.interface')); |
|
76 | + $repository = str_plural(\Config::get('repository.repository')); |
|
77 | 77 | |
78 | 78 | $this->generate($path, \Config::get('repository.controllers_folder'), 'Controller'); |
79 | 79 | $this->generate($path, $model, 'Entity'); |
@@ -81,19 +81,19 @@ discard block |
||
81 | 81 | $this->generate($path, $interface, 'Interface'); |
82 | 82 | $this->generate($path, $repository, 'Repository'); |
83 | 83 | |
84 | - File::append(\Config::get('repository.route_path') . '/web.php', "\n" . 'Route::resource(\'' . strtolower(str_plural($this->repoName)) . "', '".$path."\\".$this->repoName."Controller');"); |
|
84 | + File::append(\Config::get('repository.route_path') . '/web.php', "\n" . 'Route::resource(\'' . strtolower(str_plural($this->repoName)) . "', '" . $path . "\\" . $this->repoName . "Controller');"); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | function makeViewsAndLanguage() |
88 | 88 | { |
89 | 89 | foreach (\Config::get('repository.languages') as $lang) |
90 | 90 | { |
91 | - $this->generate(lcfirst($this->repoName),\Config::get('repository.lang_path')."/{$lang}" , 'lang'); |
|
91 | + $this->generate(lcfirst($this->repoName), \Config::get('repository.lang_path') . "/{$lang}", 'lang'); |
|
92 | 92 | } |
93 | - $this->generate(lcfirst($this->repoName),\Config::get('repository.resources_path')."/views" , 'create'); |
|
94 | - $this->generate(lcfirst($this->repoName),\Config::get('repository.resources_path')."/views" , 'edit'); |
|
95 | - $this->generate(lcfirst($this->repoName),\Config::get('repository.resources_path')."/views" , 'index'); |
|
96 | - $this->generate(lcfirst($this->repoName),\Config::get('repository.resources_path')."/views" , 'show'); |
|
93 | + $this->generate(lcfirst($this->repoName), \Config::get('repository.resources_path') . "/views", 'create'); |
|
94 | + $this->generate(lcfirst($this->repoName), \Config::get('repository.resources_path') . "/views", 'edit'); |
|
95 | + $this->generate(lcfirst($this->repoName), \Config::get('repository.resources_path') . "/views", 'index'); |
|
96 | + $this->generate(lcfirst($this->repoName), \Config::get('repository.resources_path') . "/views", 'show'); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -117,9 +117,9 @@ discard block |
||
117 | 117 | { |
118 | 118 | $content = $this->getStub($type); |
119 | 119 | |
120 | - if($content === false) |
|
120 | + if ($content === false) |
|
121 | 121 | { |
122 | - echo 'file '.$type.".stub is not exist !"; |
|
122 | + echo 'file ' . $type . ".stub is not exist !"; |
|
123 | 123 | return false; |
124 | 124 | } |
125 | 125 | |
@@ -135,20 +135,20 @@ discard block |
||
135 | 135 | $this->repoName, |
136 | 136 | str_plural($folder), |
137 | 137 | $path, |
138 | - str_plural(\Config::get('repository.model','Entity')), |
|
139 | - str_plural(\Config::get('repository.interface','Interface')), |
|
138 | + str_plural(\Config::get('repository.model', 'Entity')), |
|
139 | + str_plural(\Config::get('repository.interface', 'Interface')), |
|
140 | 140 | ], |
141 | 141 | $this->getStub($type) |
142 | 142 | ); |
143 | 143 | |
144 | - $folder = str_replace('\\','/',$folder); |
|
145 | - $path = str_replace('\\','/',$path); |
|
144 | + $folder = str_replace('\\', '/', $folder); |
|
145 | + $path = str_replace('\\', '/', $path); |
|
146 | 146 | |
147 | 147 | switch ($type) |
148 | 148 | { |
149 | 149 | case 'Entity': |
150 | 150 | $filePath = $this->getFolderOrCreate(\Config::get('repository.app_path') . "/{$folder}/{$path}"); |
151 | - $filePath = rtrim($filePath,'/'); |
|
151 | + $filePath = rtrim($filePath, '/'); |
|
152 | 152 | $filePath .= "/"; |
153 | 153 | file_put_contents($filePath . "{$this->repoName}.php", $template); |
154 | 154 | break; |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | case 'Repository': |
158 | 158 | case 'Interface': |
159 | 159 | $filePath = $this->getFolderOrCreate(\Config::get('repository.app_path') . "/{$folder}/{$path}"); |
160 | - $filePath = rtrim($filePath,'/'); |
|
160 | + $filePath = rtrim($filePath, '/'); |
|
161 | 161 | $filePath .= "/"; |
162 | 162 | file_put_contents($filePath . "{$this->repoName}{$type}.php", $template); |
163 | 163 | break; |
@@ -165,14 +165,14 @@ discard block |
||
165 | 165 | case 'edit': |
166 | 166 | case 'index': |
167 | 167 | case 'show': |
168 | - $filePath = $this->getFolderOrCreate($folder."/".str_plural($path))."/"; |
|
168 | + $filePath = $this->getFolderOrCreate($folder . "/" . str_plural($path)) . "/"; |
|
169 | 169 | $repoName = lcfirst($type); |
170 | - file_put_contents($filePath . $repoName.".blade.php", $template); |
|
170 | + file_put_contents($filePath . $repoName . ".blade.php", $template); |
|
171 | 171 | break; |
172 | 172 | default: |
173 | - $filePath = $this->getFolderOrCreate($folder)."/"; |
|
173 | + $filePath = $this->getFolderOrCreate($folder) . "/"; |
|
174 | 174 | $repoName = lcfirst($this->repoName); |
175 | - file_put_contents($filePath . $repoName.".php", $template); |
|
175 | + file_put_contents($filePath . $repoName . ".php", $template); |
|
176 | 176 | } |
177 | 177 | return true; |
178 | 178 | } |