@@ -78,6 +78,6 @@ |
||
78 | 78 | |
79 | 79 | function getFormStub($type) |
80 | 80 | { |
81 | - return file_get_contents(\Config::get('repository.stubs_path') . "/fields-".$type.".stub"); |
|
81 | + return file_get_contents(\Config::get('repository.stubs_path') . "/fields-" . $type . ".stub"); |
|
82 | 82 | } |
83 | 83 | } |
84 | 84 | \ No newline at end of file |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | |
13 | 13 | function template() |
14 | 14 | { |
15 | - $required=$this->column->getNotnull()?'required':''; |
|
15 | + $required = $this->column->getNotnull() ? 'required' : ''; |
|
16 | 16 | |
17 | 17 | $template = str_replace( |
18 | 18 | [ |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | $this->column->getName(), |
26 | 26 | $this->getType(), |
27 | 27 | $required, |
28 | - ucfirst(str_replace('_',' ',$this->column->getName())) |
|
28 | + ucfirst(str_replace('_', ' ', $this->column->getName())) |
|
29 | 29 | ], |
30 | 30 | $this->getFormStub('input') |
31 | 31 | ); |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | |
14 | 14 | function template() |
15 | 15 | { |
16 | - $required=$this->column->getNotnull()?'required':''; |
|
16 | + $required = $this->column->getNotnull() ? 'required' : ''; |
|
17 | 17 | |
18 | 18 | $template = str_replace( |
19 | 19 | [ |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | $this->column->getName(), |
27 | 27 | $this->getType(), |
28 | 28 | $required, |
29 | - ucfirst(str_replace('_',' ',$this->column->getName())) |
|
29 | + ucfirst(str_replace('_', ' ', $this->column->getName())) |
|
30 | 30 | ], |
31 | 31 | $this->getFormStub('textArea') |
32 | 32 | ); |
@@ -71,10 +71,10 @@ discard block |
||
71 | 71 | * @param string $method |
72 | 72 | * @return string |
73 | 73 | */ |
74 | - function generateForm($entity,$method = 'post') |
|
74 | + function generateForm($entity, $method = 'post') |
|
75 | 75 | { |
76 | 76 | $html = '<form method="post" action="#"> |
77 | - <input type="hidden" name="__method" value="'.$method.'">'; |
|
77 | + <input type="hidden" name="__method" value="'.$method . '">'; |
|
78 | 78 | $html .= $this->getInputs($entity); |
79 | 79 | $html .= '</form>'; |
80 | 80 | return $html; |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | */ |
87 | 87 | function getFillables($entity) |
88 | 88 | { |
89 | - if(!empty($entity->getFillable())) |
|
89 | + if (!empty($entity->getFillable())) |
|
90 | 90 | return $entity->getFillable(); |
91 | 91 | |
92 | 92 | $columns = \Schema::getColumnListing($entity->getTable()); |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | */ |
108 | 108 | function getInputs($entity) |
109 | 109 | { |
110 | - if($this->inputs) |
|
110 | + if ($this->inputs) |
|
111 | 111 | return $this->inputs; |
112 | 112 | |
113 | 113 | return $this->generateInputs($entity); |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | $html = ''; |
123 | 123 | foreach ($this->getFillables($entity) as $fillable) |
124 | 124 | { |
125 | - $column = DB::connection()->getDoctrineColumn($entity->getTable(),$fillable); |
|
125 | + $column = DB::connection()->getDoctrineColumn($entity->getTable(), $fillable); |
|
126 | 126 | |
127 | 127 | $html .= $this->generateFormInput($column); |
128 | 128 | } |
@@ -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 | |
@@ -181,21 +181,21 @@ discard block |
||
181 | 181 | $this->repoName, |
182 | 182 | str_plural($folder), |
183 | 183 | $path, |
184 | - str_plural(\Config::get('repository.model','Entity')), |
|
185 | - str_plural(\Config::get('repository.interface','Interface')), |
|
184 | + str_plural(\Config::get('repository.model', 'Entity')), |
|
185 | + str_plural(\Config::get('repository.interface', 'Interface')), |
|
186 | 186 | $form |
187 | 187 | ], |
188 | 188 | $this->getStub($type) |
189 | 189 | ); |
190 | 190 | |
191 | - $folder = str_replace('\\','/',$folder); |
|
192 | - $path = str_replace('\\','/',$path); |
|
191 | + $folder = str_replace('\\', '/', $folder); |
|
192 | + $path = str_replace('\\', '/', $path); |
|
193 | 193 | |
194 | 194 | switch ($type) |
195 | 195 | { |
196 | 196 | case 'Entity': |
197 | 197 | $filePath = $this->getFolderOrCreate(\Config::get('repository.app_path') . "/{$folder}/{$path}"); |
198 | - $filePath = rtrim($filePath,'/'); |
|
198 | + $filePath = rtrim($filePath, '/'); |
|
199 | 199 | $filePath .= "/"; |
200 | 200 | file_put_contents($filePath . "{$this->repoName}.php", $template); |
201 | 201 | break; |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | case 'Repository': |
205 | 205 | case 'Interface': |
206 | 206 | $filePath = $this->getFolderOrCreate(\Config::get('repository.app_path') . "/{$folder}/{$path}"); |
207 | - $filePath = rtrim($filePath,'/'); |
|
207 | + $filePath = rtrim($filePath, '/'); |
|
208 | 208 | $filePath .= "/"; |
209 | 209 | file_put_contents($filePath . "{$this->repoName}{$type}.php", $template); |
210 | 210 | break; |
@@ -212,14 +212,14 @@ discard block |
||
212 | 212 | case 'edit': |
213 | 213 | case 'index': |
214 | 214 | case 'show': |
215 | - $filePath = $this->getFolderOrCreate($folder."/".str_plural($path))."/"; |
|
215 | + $filePath = $this->getFolderOrCreate($folder . "/" . str_plural($path)) . "/"; |
|
216 | 216 | $repoName = lcfirst($type); |
217 | - file_put_contents($filePath . $repoName.".blade.php", $template); |
|
217 | + file_put_contents($filePath . $repoName . ".blade.php", $template); |
|
218 | 218 | break; |
219 | 219 | default: |
220 | - $filePath = $this->getFolderOrCreate($folder)."/"; |
|
220 | + $filePath = $this->getFolderOrCreate($folder) . "/"; |
|
221 | 221 | $repoName = lcfirst($this->repoName); |
222 | - file_put_contents($filePath . $repoName.".php", $template); |
|
222 | + file_put_contents($filePath . $repoName . ".php", $template); |
|
223 | 223 | } |
224 | 224 | return true; |
225 | 225 | } |