@@ -11,11 +11,11 @@ discard block |
||
11 | 11 | class RegisterModuleCompiler extends AbstractCompiler |
12 | 12 | { |
13 | 13 | protected $cachePrefix = 'register_module_'; |
14 | - protected $stubFilename = 'RegisterModule.js' ; |
|
14 | + protected $stubFilename = 'RegisterModule.js'; |
|
15 | 15 | |
16 | 16 | public function __construct($scaffolderConfig, $modelData = null) |
17 | 17 | { |
18 | - $this->stubsDirectory = __DIR__ . '/../../../../stubs/AngularJs/'; |
|
18 | + $this->stubsDirectory = __DIR__.'/../../../../stubs/AngularJs/'; |
|
19 | 19 | parent::__construct($scaffolderConfig, $modelData); |
20 | 20 | } |
21 | 21 | |
@@ -39,11 +39,11 @@ discard block |
||
39 | 39 | */ |
40 | 40 | protected function getOutputFilename() |
41 | 41 | { |
42 | - $folder = PathParser::parse($this->scaffolderConfig->generator->paths->pages).$this->modelData->tableName.'/register/' ; |
|
42 | + $folder = PathParser::parse($this->scaffolderConfig->generator->paths->pages).$this->modelData->tableName.'/register/'; |
|
43 | 43 | |
44 | 44 | Directory::createIfNotExists($folder, 0755, true); |
45 | 45 | |
46 | - return $folder .$this->modelData->tableName . '_register.module.js'; |
|
46 | + return $folder.$this->modelData->tableName.'_register.module.js'; |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | } |
50 | 50 | \ No newline at end of file |
@@ -5,30 +5,30 @@ discard block |
||
5 | 5 | use Scaffolder\Compilers\Support\FileToCompile; |
6 | 6 | use Illuminate\Support\Facades\File; |
7 | 7 | use Scaffolder\Support\Json; |
8 | -use stdClass ; |
|
8 | +use stdClass; |
|
9 | 9 | |
10 | 10 | abstract class AbstractCompiler |
11 | 11 | { |
12 | - protected $cachePrefix ; |
|
12 | + protected $cachePrefix; |
|
13 | 13 | protected $stubFilename; |
14 | 14 | |
15 | 15 | protected $stub; |
16 | - protected $scaffolderConfig ; |
|
17 | - protected $modelName ; |
|
18 | - protected $modelData ; |
|
19 | - protected $stubsDirectory ; |
|
16 | + protected $scaffolderConfig; |
|
17 | + protected $modelName; |
|
18 | + protected $modelData; |
|
19 | + protected $stubsDirectory; |
|
20 | 20 | |
21 | - protected $eagerTable ; |
|
21 | + protected $eagerTable; |
|
22 | 22 | |
23 | 23 | const CACHE_EXT = '.scf'; |
24 | 24 | |
25 | 25 | public function __construct($scaffolderConfig, $modelData = null) |
26 | 26 | { |
27 | - $this->modelName = isset($modelData->modelName) ? $modelData->modelName : null ; |
|
28 | - $this->modelData = $modelData ; |
|
29 | - $this->scaffolderConfig = $scaffolderConfig ; |
|
27 | + $this->modelName = isset($modelData->modelName) ? $modelData->modelName : null; |
|
28 | + $this->modelData = $modelData; |
|
29 | + $this->scaffolderConfig = $scaffolderConfig; |
|
30 | 30 | |
31 | - $this->stub = File::get($this->stubsDirectory . $this->stubFilename ); |
|
31 | + $this->stub = File::get($this->stubsDirectory.$this->stubFilename); |
|
32 | 32 | } |
33 | 33 | |
34 | 34 | /** |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function compile($extra = null) |
42 | 42 | { |
43 | - if (File::exists(base_path('scaffolder-config/cache/' . $this->cachePrefix . $this->modelData->modelHash . self::CACHE_EXT))) |
|
43 | + if (File::exists(base_path('scaffolder-config/cache/'.$this->cachePrefix.$this->modelData->modelHash.self::CACHE_EXT))) |
|
44 | 44 | { |
45 | 45 | return $this->store(new FileToCompile(true, $this->modelData->modelHash)); |
46 | 46 | } |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * |
70 | 70 | * @return string |
71 | 71 | */ |
72 | - protected function setEagerTable($eagerTable){ |
|
72 | + protected function setEagerTable($eagerTable) { |
|
73 | 73 | $this->eagerTable = $eagerTable.'.'; |
74 | 74 | } |
75 | 75 | |
@@ -87,12 +87,12 @@ discard block |
||
87 | 87 | // Store in cache |
88 | 88 | if ($fileToCompile->cached) |
89 | 89 | { |
90 | - File::copy(base_path('scaffolder-config/cache/' . $this->cachePrefix . $fileToCompile->hash . self::CACHE_EXT), $path); |
|
90 | + File::copy(base_path('scaffolder-config/cache/'.$this->cachePrefix.$fileToCompile->hash.self::CACHE_EXT), $path); |
|
91 | 91 | } |
92 | 92 | else |
93 | 93 | { |
94 | - File::put(base_path('scaffolder-config/cache/' . $this->cachePrefix . $fileToCompile->hash . self::CACHE_EXT), $this->stub); |
|
95 | - File::copy(base_path('scaffolder-config/cache/' . $this->cachePrefix . $fileToCompile->hash . self::CACHE_EXT), $path); |
|
94 | + File::put(base_path('scaffolder-config/cache/'.$this->cachePrefix.$fileToCompile->hash.self::CACHE_EXT), $this->stub); |
|
95 | + File::copy(base_path('scaffolder-config/cache/'.$this->cachePrefix.$fileToCompile->hash.self::CACHE_EXT), $path); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | return $path; |
@@ -121,27 +121,27 @@ discard block |
||
121 | 121 | return $this; |
122 | 122 | } |
123 | 123 | |
124 | - protected function getPrimaryKeyField(){ |
|
124 | + protected function getPrimaryKeyField() { |
|
125 | 125 | $primaryKey = new stdClass; |
126 | - $primaryKey->name = "id" ; |
|
127 | - $primaryKey->index = "primary" ; |
|
128 | - $primaryKey->declared = false ; |
|
129 | - $primaryKey->type = new stdClass ; |
|
130 | - $primaryKey->type->ui = 'label' ; |
|
131 | - $primaryKey->type->db = 'integer' ; |
|
126 | + $primaryKey->name = "id"; |
|
127 | + $primaryKey->index = "primary"; |
|
128 | + $primaryKey->declared = false; |
|
129 | + $primaryKey->type = new stdClass; |
|
130 | + $primaryKey->type->ui = 'label'; |
|
131 | + $primaryKey->type->db = 'integer'; |
|
132 | 132 | $primaryKey->foreignKey = []; |
133 | - $primaryKey->validations = "required" ; |
|
133 | + $primaryKey->validations = "required"; |
|
134 | 134 | |
135 | 135 | foreach ($this->modelData->fields as $field) |
136 | 136 | { |
137 | 137 | if ($field->index == 'primary') |
138 | 138 | { |
139 | - $primaryKey = $field ; |
|
139 | + $primaryKey = $field; |
|
140 | 140 | break; |
141 | 141 | } |
142 | 142 | } |
143 | 143 | |
144 | - return $primaryKey ; |
|
144 | + return $primaryKey; |
|
145 | 145 | } |
146 | 146 | |
147 | 147 | /** |
@@ -190,14 +190,14 @@ discard block |
||
190 | 190 | * |
191 | 191 | * @return $this |
192 | 192 | */ |
193 | - protected function replaceForeingStrings($field, $originalStubPart){ |
|
193 | + protected function replaceForeingStrings($field, $originalStubPart) { |
|
194 | 194 | $replaceStub = str_replace('{{foreign_table}}', $field->foreignKey->table, $originalStubPart); |
195 | 195 | $replaceStub = str_replace('{{table_name}}', $this->modelData->tableName, $replaceStub); |
196 | 196 | $replaceStub = str_replace('{{foreign_field}}', $field->foreignKey->field, $replaceStub); |
197 | 197 | $replaceStub = str_replace('{{foreign_model}}', ucwords($field->foreignKey->table), $replaceStub); |
198 | 198 | $replaceStub = str_replace('{{field}}', $field->name, $replaceStub); |
199 | 199 | |
200 | - if(isset($this->scaffolderConfig->generator->namespaces)) |
|
200 | + if (isset($this->scaffolderConfig->generator->namespaces)) |
|
201 | 201 | $replaceStub = str_replace('{{model_namespace}}', $this->scaffolderConfig->generator->namespaces->models, $replaceStub); |
202 | 202 | |
203 | 203 | return $replaceStub; |
@@ -212,10 +212,10 @@ discard block |
||
212 | 212 | * |
213 | 213 | * @return $this |
214 | 214 | */ |
215 | - protected function replaceFieldStrings($field, $originalStubPart){ |
|
215 | + protected function replaceFieldStrings($field, $originalStubPart) { |
|
216 | 216 | $replaceStub = str_replace('{{field}}', $field->name, $originalStubPart); |
217 | 217 | |
218 | - if($this->eagerTable) $this->eagerTable.'.' ; |
|
218 | + if ($this->eagerTable) $this->eagerTable.'.'; |
|
219 | 219 | |
220 | 220 | $replaceStub = str_replace('{{eager_table}}', $this->eagerTable, $replaceStub); |
221 | 221 | |
@@ -243,14 +243,14 @@ discard block |
||
243 | 243 | * @return $this |
244 | 244 | */ |
245 | 245 | protected $modelDataArray = []; |
246 | - protected function getModelData($tableName){ |
|
246 | + protected function getModelData($tableName) { |
|
247 | 247 | |
248 | - if(array_key_exists($tableName, $this->modelDataArray)){ |
|
248 | + if (array_key_exists($tableName, $this->modelDataArray)) { |
|
249 | 249 | return $this->modelDataArray[$tableName]; |
250 | 250 | } |
251 | 251 | else { |
252 | 252 | |
253 | - $modelFilename = base_path('scaffolder-config/models/') . $tableName . '.json' ; |
|
253 | + $modelFilename = base_path('scaffolder-config/models/').$tableName.'.json'; |
|
254 | 254 | |
255 | 255 | $modelData = Json::decodeFile($modelFilename); |
256 | 256 | |
@@ -261,10 +261,10 @@ discard block |
||
261 | 261 | $modelHash = md5_file($modelFilename); |
262 | 262 | |
263 | 263 | // Set model name |
264 | - $modelData->modelName = $modelName ; |
|
264 | + $modelData->modelName = $modelName; |
|
265 | 265 | |
266 | 266 | // Set model name |
267 | - $modelData->modelHash = $modelHash ; |
|
267 | + $modelData->modelHash = $modelHash; |
|
268 | 268 | |
269 | 269 | $this->modelDataArray[$tableName] = $modelData; |
270 | 270 |
@@ -12,13 +12,13 @@ discard block |
||
12 | 12 | class ModelCompiler extends AbstractCompiler |
13 | 13 | { |
14 | 14 | protected $cachePrefix = 'model_'; |
15 | - protected $stubFilename = 'Model/Model.php' ; |
|
15 | + protected $stubFilename = 'Model/Model.php'; |
|
16 | 16 | |
17 | 17 | public function __construct($scaffolderConfig, $modelData = null, $stubName = null) |
18 | 18 | { |
19 | 19 | if ($stubName) |
20 | 20 | $this->stubFilename = $stubName; |
21 | - $this->stubsDirectory = __DIR__ . '/../../../../stubs/Api/'; |
|
21 | + $this->stubsDirectory = __DIR__.'/../../../../stubs/Api/'; |
|
22 | 22 | parent::__construct($scaffolderConfig, $modelData); |
23 | 23 | } |
24 | 24 | |
@@ -58,9 +58,9 @@ discard block |
||
58 | 58 | */ |
59 | 59 | protected function getOutputFilename() |
60 | 60 | { |
61 | - $folder = PathParser::parse($this->scaffolderConfig->generator->paths->models) ; |
|
61 | + $folder = PathParser::parse($this->scaffolderConfig->generator->paths->models); |
|
62 | 62 | |
63 | - return $folder . $this->modelName . '.php'; |
|
63 | + return $folder.$this->modelName.'.php'; |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | |
@@ -91,21 +91,21 @@ discard block |
||
91 | 91 | |
92 | 92 | foreach ($this->modelData->fields as $field) |
93 | 93 | { |
94 | - if($field->index == "primary") |
|
95 | - continue ; |
|
96 | - if($this->modelData->timeStamps && $field->name == "created_at") |
|
97 | - continue ; |
|
98 | - if($this->modelData->timeStamps && $field->name == "updated_at") |
|
99 | - continue ; |
|
94 | + if ($field->index == "primary") |
|
95 | + continue; |
|
96 | + if ($this->modelData->timeStamps && $field->name == "created_at") |
|
97 | + continue; |
|
98 | + if ($this->modelData->timeStamps && $field->name == "updated_at") |
|
99 | + continue; |
|
100 | 100 | |
101 | 101 | if ($firstIteration) |
102 | 102 | { |
103 | - $fields .= sprintf("'%s'," . PHP_EOL, $field->name); |
|
103 | + $fields .= sprintf("'%s',".PHP_EOL, $field->name); |
|
104 | 104 | $firstIteration = false; |
105 | 105 | } |
106 | 106 | else |
107 | 107 | { |
108 | - $fields .= sprintf("\t\t'%s'," . PHP_EOL, $field->name); |
|
108 | + $fields .= sprintf("\t\t'%s',".PHP_EOL, $field->name); |
|
109 | 109 | } |
110 | 110 | } |
111 | 111 | |
@@ -120,13 +120,13 @@ discard block |
||
120 | 120 | $arrays = ''; |
121 | 121 | |
122 | 122 | foreach ($this->modelData->fields as $field) { |
123 | - $enumStub = File::get($this->stubsDirectory . '/Model/ModelEnum.php'); |
|
123 | + $enumStub = File::get($this->stubsDirectory.'/Model/ModelEnum.php'); |
|
124 | 124 | |
125 | 125 | if ($field->type->db == "enum") { |
126 | 126 | $items = ''; |
127 | 127 | |
128 | 128 | foreach ($field->options as $key => $option) { |
129 | - $items .= "'" . $option . "'"; |
|
129 | + $items .= "'".$option."'"; |
|
130 | 130 | if ($key < (count($field->options) - 1)) |
131 | 131 | $items .= ", "; |
132 | 132 | |
@@ -160,25 +160,25 @@ discard block |
||
160 | 160 | |
161 | 161 | foreach ($this->modelData->fields as $field) |
162 | 162 | { |
163 | - if($field->index == "primary") |
|
164 | - continue ; |
|
165 | - if($this->modelData->timeStamps && $field->name == "created_at") |
|
166 | - continue ; |
|
167 | - if($this->modelData->timeStamps && $field->name == "updated_at") |
|
168 | - continue ; |
|
163 | + if ($field->index == "primary") |
|
164 | + continue; |
|
165 | + if ($this->modelData->timeStamps && $field->name == "created_at") |
|
166 | + continue; |
|
167 | + if ($this->modelData->timeStamps && $field->name == "updated_at") |
|
168 | + continue; |
|
169 | 169 | |
170 | 170 | if ($firstIteration) |
171 | 171 | { |
172 | - $fields .= sprintf("'%s' => '%s'," . PHP_EOL, $field->name, $field->validations); |
|
172 | + $fields .= sprintf("'%s' => '%s',".PHP_EOL, $field->name, $field->validations); |
|
173 | 173 | $firstIteration = false; |
174 | 174 | } |
175 | 175 | else |
176 | 176 | { |
177 | - $fields .= sprintf("\t\t\t'%s' => '%s'," . PHP_EOL, $field->name, $field->validations); |
|
177 | + $fields .= sprintf("\t\t\t'%s' => '%s',".PHP_EOL, $field->name, $field->validations); |
|
178 | 178 | } |
179 | 179 | } |
180 | 180 | |
181 | - $fields = str_replace('unique','unique:'.$this->modelData->tableName,$fields); |
|
181 | + $fields = str_replace('unique', 'unique:'.$this->modelData->tableName, $fields); |
|
182 | 182 | //var_dump($fields); |
183 | 183 | |
184 | 184 | $this->stub = str_replace('{{validations}}', $fields, $this->stub); |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | */ |
193 | 193 | private function setTimeStamps() |
194 | 194 | { |
195 | - if($this->modelData->timeStamps) |
|
195 | + if ($this->modelData->timeStamps) |
|
196 | 196 | { |
197 | 197 | $this->stub = str_replace('{{timestamps}}', ' ', $this->stub); |
198 | 198 | } else { |
@@ -208,11 +208,11 @@ discard block |
||
208 | 208 | */ |
209 | 209 | private function setPrimaryKey() |
210 | 210 | { |
211 | - $primaryKey = '// Using default primary key' . PHP_EOL; |
|
211 | + $primaryKey = '// Using default primary key'.PHP_EOL; |
|
212 | 212 | |
213 | - $field = $this->getPrimaryKeyField() ; |
|
213 | + $field = $this->getPrimaryKeyField(); |
|
214 | 214 | |
215 | - $primaryKey = 'protected $primaryKey = \'' . $field->name . '\';' . PHP_EOL; |
|
215 | + $primaryKey = 'protected $primaryKey = \''.$field->name.'\';'.PHP_EOL; |
|
216 | 216 | |
217 | 217 | $this->stub = str_replace('{{primaryAttribute}}', $primaryKey, $this->stub); |
218 | 218 | |
@@ -241,13 +241,13 @@ discard block |
||
241 | 241 | $functionName = $field->foreignKey->table; |
242 | 242 | |
243 | 243 | if ($field->foreignKey->relationship == "belongsTo") { |
244 | - $belongsToOriginalStub = File::get($this->stubsDirectory . '/Model/ModelBelongsTo.php'); |
|
244 | + $belongsToOriginalStub = File::get($this->stubsDirectory.'/Model/ModelBelongsTo.php'); |
|
245 | 245 | $belongsToStub = str_replace('{{foreign_model}}', CamelCase::convertToCamelCase($field->foreignKey->table), $belongsToOriginalStub); |
246 | 246 | $belongsToStub = str_replace('{{field}}', $field->name, $belongsToStub); |
247 | 247 | $belongsToStub = str_replace('{{foreign_field}}', $field->foreignKey->field, $belongsToStub); |
248 | 248 | } |
249 | 249 | elseif ($field->foreignKey->relationship == "belongsToMany") { |
250 | - $belongsToOriginalStub = File::get($this->stubsDirectory . '/Model/ModelBelongsToMany.php'); |
|
250 | + $belongsToOriginalStub = File::get($this->stubsDirectory.'/Model/ModelBelongsToMany.php'); |
|
251 | 251 | $functionName = CamelCase::pluralize($field->foreignKey->table); |
252 | 252 | $belongsToStub = str_replace('{{foreign_model}}', CamelCase::convertToCamelCase($field->foreignKey->table), $belongsToOriginalStub); |
253 | 253 | $belongsToStub = str_replace('{{foreign_key}}', $field->name, $belongsToStub); |
@@ -258,9 +258,9 @@ discard block |
||
258 | 258 | $belongsToStub = str_replace('{{foreign_table}}', $functionName, $belongsToStub); |
259 | 259 | $belongsToStub = str_replace('{{model_namespace}}', $this->scaffolderConfig->generator->namespaces->models, $belongsToStub); |
260 | 260 | |
261 | - $functions .= $belongsToStub ; |
|
261 | + $functions .= $belongsToStub; |
|
262 | 262 | |
263 | - if(isset($field->foreignKey->eager) && $field->foreignKey->eager){ |
|
263 | + if (isset($field->foreignKey->eager) && $field->foreignKey->eager) { |
|
264 | 264 | array_push($eagerArray, "'".$field->foreignKey->table."'"); |
265 | 265 | } |
266 | 266 | } |
@@ -270,7 +270,7 @@ discard block |
||
270 | 270 | |
271 | 271 | $this->stub = str_replace('{{belongsTo}}', $functions, $this->stub); |
272 | 272 | |
273 | - $this->stub = str_replace('{{eager}}', join("," , $eagerArray) , $this->stub); |
|
273 | + $this->stub = str_replace('{{eager}}', join(",", $eagerArray), $this->stub); |
|
274 | 274 | |
275 | 275 | return $this; |
276 | 276 | } |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | $functionName = CamelCase::pluralize(strtolower($relationship->modelName)); |
296 | 296 | |
297 | 297 | if ($relationship->type == "belongsToMany") { |
298 | - $reverseRelationshipOriginalStub = File::get($this->stubsDirectory . '/Model/ModelBelongsToMany.php'); |
|
298 | + $reverseRelationshipOriginalStub = File::get($this->stubsDirectory.'/Model/ModelBelongsToMany.php'); |
|
299 | 299 | $reverseRelationshipStub = str_replace('{{foreign_model}}', CamelCase::convertToCamelCase($relationship->relatedTable), $reverseRelationshipOriginalStub); |
300 | 300 | $reverseRelationshipStub = str_replace('{{foreign_key}}', $relationship->foreignKey, $reverseRelationshipStub); |
301 | 301 | $reverseRelationshipStub = str_replace('{{table_name}}', $relationship->tableName, $reverseRelationshipStub); |
@@ -303,7 +303,7 @@ discard block |
||
303 | 303 | $reverseRelationshipStub = str_replace('{{foreign_table}}', CamelCase::pluralize(strtolower($relationship->relatedTable)), $reverseRelationshipStub); |
304 | 304 | } |
305 | 305 | else { |
306 | - $reverseRelationshipOriginalStub = File::get($this->stubsDirectory . '/Model/ModelReverseRelationship.php'); |
|
306 | + $reverseRelationshipOriginalStub = File::get($this->stubsDirectory.'/Model/ModelReverseRelationship.php'); |
|
307 | 307 | $reverseRelationshipStub = str_replace('{{foreign_model}}', $relationship->modelName, $reverseRelationshipOriginalStub); |
308 | 308 | $reverseRelationshipStub = str_replace('{{field}}', $relationship->foreignKey, $reverseRelationshipStub); |
309 | 309 | $reverseRelationshipStub = str_replace('{{foreign_field}}', $relationship->localKey, $reverseRelationshipStub); |
@@ -313,9 +313,9 @@ discard block |
||
313 | 313 | |
314 | 314 | $reverseRelationshipStub = str_replace('{{model_namespace}}', $this->scaffolderConfig->generator->namespaces->models, $reverseRelationshipStub); |
315 | 315 | |
316 | - $functions .= $reverseRelationshipStub ; |
|
316 | + $functions .= $reverseRelationshipStub; |
|
317 | 317 | |
318 | - if(isset($relationship->foreignKey->eager) && $relationship->foreignKey->eager){ |
|
318 | + if (isset($relationship->foreignKey->eager) && $relationship->foreignKey->eager) { |
|
319 | 319 | array_push($eagerArray, "'".$relationship->foreignKey->table."'"); |
320 | 320 | } |
321 | 321 | } |
@@ -340,11 +340,11 @@ discard block |
||
340 | 340 | $storeCommands = $updateCommands = $ruleCommands = $useCommands = ''; |
341 | 341 | $eagerConditions = $eagerJoins = ''; |
342 | 342 | |
343 | - $storeEagerStubOriginal = File::get($this->stubsDirectory . 'StoreEager.php'); |
|
344 | - $updateEagerStubOriginal = File::get($this->stubsDirectory . 'UpdateEager.php'); |
|
345 | - $rulesEagerStubOriginal = File::get($this->stubsDirectory . 'RulesEager.php'); |
|
346 | - $useEagerStubOriginal = File::get($this->stubsDirectory . 'UseEager.php'); |
|
347 | - $joinEagerStubOriginal = File::get($this->stubsDirectory . 'SearchConditions/JoinEager.php'); |
|
343 | + $storeEagerStubOriginal = File::get($this->stubsDirectory.'StoreEager.php'); |
|
344 | + $updateEagerStubOriginal = File::get($this->stubsDirectory.'UpdateEager.php'); |
|
345 | + $rulesEagerStubOriginal = File::get($this->stubsDirectory.'RulesEager.php'); |
|
346 | + $useEagerStubOriginal = File::get($this->stubsDirectory.'UseEager.php'); |
|
347 | + $joinEagerStubOriginal = File::get($this->stubsDirectory.'SearchConditions/JoinEager.php'); |
|
348 | 348 | |
349 | 349 | foreach ($this->modelData->fields as $field) |
350 | 350 | { |
@@ -354,20 +354,20 @@ discard block |
||
354 | 354 | { |
355 | 355 | |
356 | 356 | $storeCommands .= str_replace('{{foreign_model_name}}', CamelCase::convertToCamelCase($field->foreignKey->table), $this->replaceForeingStrings($field, $storeEagerStubOriginal)); |
357 | - $updateCommands .= str_replace('{{foreign_model_name}}', CamelCase::convertToCamelCase($field->foreignKey->table), $this->replaceForeingStrings($field, $updateEagerStubOriginal)) ; |
|
358 | - $ruleCommands .= str_replace('{{foreign_model_name}}', CamelCase::convertToCamelCase($field->foreignKey->table), $this->replaceForeingStrings($field, $rulesEagerStubOriginal)) ; |
|
359 | - $useCommands .= str_replace('{{foreign_model_name}}', CamelCase::convertToCamelCase($field->foreignKey->table), $this->replaceForeingStrings($field, $useEagerStubOriginal)) ; |
|
360 | - $eagerJoins .= $this->replaceForeingStrings($field, $joinEagerStubOriginal) ; |
|
357 | + $updateCommands .= str_replace('{{foreign_model_name}}', CamelCase::convertToCamelCase($field->foreignKey->table), $this->replaceForeingStrings($field, $updateEagerStubOriginal)); |
|
358 | + $ruleCommands .= str_replace('{{foreign_model_name}}', CamelCase::convertToCamelCase($field->foreignKey->table), $this->replaceForeingStrings($field, $rulesEagerStubOriginal)); |
|
359 | + $useCommands .= str_replace('{{foreign_model_name}}', CamelCase::convertToCamelCase($field->foreignKey->table), $this->replaceForeingStrings($field, $useEagerStubOriginal)); |
|
360 | + $eagerJoins .= $this->replaceForeingStrings($field, $joinEagerStubOriginal); |
|
361 | 361 | |
362 | 362 | // search eager fields |
363 | 363 | $foreignModelData = $this->getModelData($field->foreignKey->table); |
364 | 364 | $foreignControllerCompiler = new ControllerCompiler($this->scaffolderConfig, $foreignModelData); |
365 | 365 | $foreignControllerCompiler->setEagerTable($this->modelData->tableName); |
366 | - $eagerConditions .= $foreignControllerCompiler->getSearchConditions(); |
|
366 | + $eagerConditions .= $foreignControllerCompiler->getSearchConditions(); |
|
367 | 367 | $eagerUniqueRules = $foreignControllerCompiler->getEagerUniqueRules(); |
368 | 368 | $eagerUniqueRules = str_replace("{{class_name_lw}}", strtolower($this->modelName), $eagerUniqueRules); |
369 | 369 | $eagerUniqueRules = str_replace("{{field}}", $field->name, $eagerUniqueRules); |
370 | - $ruleCommands = str_replace('{{unique_eager_rules}}', $eagerUniqueRules, $ruleCommands) ; |
|
370 | + $ruleCommands = str_replace('{{unique_eager_rules}}', $eagerUniqueRules, $ruleCommands); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | } |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | $joins = ""; |
401 | 401 | $joinSorts = ""; |
402 | 402 | |
403 | - $method = File::get($this->stubsDirectory . '/Model/ModelRelationshipTable.php'); |
|
403 | + $method = File::get($this->stubsDirectory.'/Model/ModelRelationshipTable.php'); |
|
404 | 404 | |
405 | 405 | foreach ($this->modelData->reverseRelationships as $relationship) { |
406 | 406 | |
@@ -426,9 +426,9 @@ discard block |
||
426 | 426 | $methodCall = str_replace('{{related_table_pl}}', $relatedTablePluralized, $methodCall); |
427 | 427 | $methodCall = str_replace('{{class_name_lw}}', $this->modelData->tableName, $methodCall); |
428 | 428 | |
429 | - $functionsCall .= $methodCall . "\n\t\t"; |
|
429 | + $functionsCall .= $methodCall."\n\t\t"; |
|
430 | 430 | |
431 | - $removeAllMethod = File::get($this->stubsDirectory . '/Controller/ControllerRemoveAll.php'); |
|
431 | + $removeAllMethod = File::get($this->stubsDirectory.'/Controller/ControllerRemoveAll.php'); |
|
432 | 432 | $removeAllMethod = str_replace('{{related_table_pl_uc}}', $relatedTablePluralizedUc, $removeAllMethod); |
433 | 433 | $removeAllMethod = str_replace('{{foreign_key}}', $relationship->foreignKey, $removeAllMethod); |
434 | 434 | $removeAllMethod = str_replace('{{foreign_table}}', $relationship->modelName, $removeAllMethod); |
@@ -440,9 +440,9 @@ discard block |
||
440 | 440 | $removeAllCallMethod = str_replace('{{related_table_pl_uc}}', $relatedTablePluralizedUc, $removeAllCallMethod); |
441 | 441 | $removeAllCallMethod = str_replace('{{class_name_lw}}', $this->modelData->tableName, $removeAllCallMethod); |
442 | 442 | |
443 | - $removeAllCall .= $removeAllCallMethod . "\n\t\t"; |
|
443 | + $removeAllCall .= $removeAllCallMethod."\n\t\t"; |
|
444 | 444 | |
445 | - $joinRelationshipTableStub = File::get($this->stubsDirectory . 'SearchConditions/joinRelationshipTable.php'); |
|
445 | + $joinRelationshipTableStub = File::get($this->stubsDirectory.'SearchConditions/joinRelationshipTable.php'); |
|
446 | 446 | $joinRelationshipTableStub = str_replace('{{class_name_lw}}', $this->modelData->tableName, $joinRelationshipTableStub); |
447 | 447 | $joinRelationshipTableStub = str_replace('{{related_table_pl}}', $relatedTablePluralized, $joinRelationshipTableStub); |
448 | 448 | $joinRelationshipTableStub = str_replace('{{related_table}}', CamelCase::convertToCamelCase($relationship->relatedTable), $joinRelationshipTableStub); |
@@ -450,12 +450,12 @@ discard block |
||
450 | 450 | $joinRelationshipTableStub = str_replace('{{related_field}}', $relationship->relatedField, $joinRelationshipTableStub); |
451 | 451 | $joinRelationshipTableStub = str_replace('{{foreign_table}}', $relationship->tableName, $joinRelationshipTableStub); |
452 | 452 | |
453 | - $joins .= $joinRelationshipTableStub . "\n"; |
|
453 | + $joins .= $joinRelationshipTableStub."\n"; |
|
454 | 454 | |
455 | 455 | $use = 'use App\Models\{{foreign_table}};'; |
456 | 456 | $use = str_replace('{{foreign_table}}', $relationship->modelName, $use); |
457 | 457 | |
458 | - $includes .= $use . "\n"; |
|
458 | + $includes .= $use."\n"; |
|
459 | 459 | } |
460 | 460 | } |
461 | 461 | |
@@ -483,7 +483,7 @@ discard block |
||
483 | 483 | * |
484 | 484 | * @return $this |
485 | 485 | */ |
486 | - private function replaceSearchConditions(){ |
|
486 | + private function replaceSearchConditions() { |
|
487 | 487 | |
488 | 488 | $searchConditions = $this->getSearchConditions(); |
489 | 489 | |
@@ -497,16 +497,16 @@ discard block |
||
497 | 497 | * |
498 | 498 | * @return $this |
499 | 499 | */ |
500 | - public function getSearchConditions(){ |
|
500 | + public function getSearchConditions() { |
|
501 | 501 | |
502 | 502 | $fieldConditions = ''; |
503 | 503 | |
504 | - $searchConditions = File::get($this->stubsDirectory . '/SearchConditions/Conditions.php'); |
|
504 | + $searchConditions = File::get($this->stubsDirectory.'/SearchConditions/Conditions.php'); |
|
505 | 505 | |
506 | 506 | foreach ($this->modelData->fields as $field) |
507 | 507 | { |
508 | 508 | |
509 | - $fieldConditions .= $this->replaceFieldStrings($field, $this->getConditionStubByField($field)) ; |
|
509 | + $fieldConditions .= $this->replaceFieldStrings($field, $this->getConditionStubByField($field)); |
|
510 | 510 | |
511 | 511 | } |
512 | 512 | |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | // replace table name |
517 | 517 | $searchConditions = str_replace('{{table_name}}', $this->modelData->tableName, $searchConditions); |
518 | 518 | |
519 | - return $searchConditions ; |
|
519 | + return $searchConditions; |
|
520 | 520 | |
521 | 521 | } |
522 | 522 | |
@@ -528,43 +528,43 @@ discard block |
||
528 | 528 | * @return $this |
529 | 529 | */ |
530 | 530 | private $conditionsStub = []; |
531 | - private function getConditionStubByField($field){ |
|
531 | + private function getConditionStubByField($field) { |
|
532 | 532 | |
533 | - if($field->index == 'primary'){ |
|
534 | - $dbType = 'primary' ; |
|
533 | + if ($field->index == 'primary') { |
|
534 | + $dbType = 'primary'; |
|
535 | 535 | } |
536 | - elseif($field->foreignKey){ |
|
537 | - $dbType = 'primary' ; |
|
536 | + elseif ($field->foreignKey) { |
|
537 | + $dbType = 'primary'; |
|
538 | 538 | } |
539 | - elseif($field->type->db == 'enum'){ |
|
540 | - $dbType = 'primary' ; |
|
539 | + elseif ($field->type->db == 'enum') { |
|
540 | + $dbType = 'primary'; |
|
541 | 541 | } |
542 | - elseif($field->type->db == 'boolean'){ |
|
543 | - $dbType = 'primary' ; |
|
542 | + elseif ($field->type->db == 'boolean') { |
|
543 | + $dbType = 'primary'; |
|
544 | 544 | } |
545 | - elseif($field->type->db == 'text'){ |
|
546 | - $dbType = 'string' ; |
|
545 | + elseif ($field->type->db == 'text') { |
|
546 | + $dbType = 'string'; |
|
547 | 547 | } |
548 | 548 | else { |
549 | - $dbType = $field->type->db ; |
|
549 | + $dbType = $field->type->db; |
|
550 | 550 | } |
551 | 551 | |
552 | - if(array_key_exists($dbType, $this->conditionsStub)){ |
|
552 | + if (array_key_exists($dbType, $this->conditionsStub)) { |
|
553 | 553 | return $this->conditionsStub[$dbType]; |
554 | 554 | } |
555 | 555 | else { |
556 | - $this->conditionsStub[$dbType] = File::get($this->stubsDirectory . 'SearchConditions/'. ucwords($dbType). '.php');; |
|
556 | + $this->conditionsStub[$dbType] = File::get($this->stubsDirectory.'SearchConditions/'.ucwords($dbType).'.php'); ; |
|
557 | 557 | |
558 | 558 | return $this->conditionsStub[$dbType]; |
559 | 559 | } |
560 | 560 | } |
561 | 561 | |
562 | - public function replaceSortConditions() { |
|
562 | + public function replaceSortConditions() { |
|
563 | 563 | $joinSorts = ''; |
564 | 564 | |
565 | 565 | foreach ($this->modelData->fields as $field) { |
566 | - if($field->foreignKey){ |
|
567 | - $joinSortStub = File::get($this->stubsDirectory . 'SearchConditions/JoinSort.php'); |
|
566 | + if ($field->foreignKey) { |
|
567 | + $joinSortStub = File::get($this->stubsDirectory.'SearchConditions/JoinSort.php'); |
|
568 | 568 | $joinSortStub = str_replace('{{field}}', $field->name, $joinSortStub); |
569 | 569 | $joinSortStub = str_replace('{{foreign_table}}', $field->foreignKey->table, $joinSortStub); |
570 | 570 | $joinSortStub = str_replace('{{foreign_key}}', $field->foreignKey->table, $joinSortStub); |
@@ -589,11 +589,11 @@ discard block |
||
589 | 589 | * |
590 | 590 | * @return $this |
591 | 591 | */ |
592 | - public function replaceReverseRelationshipsFunctions(){ |
|
592 | + public function replaceReverseRelationshipsFunctions() { |
|
593 | 593 | |
594 | 594 | $functions = ''; |
595 | 595 | |
596 | - $method = File::get($this->stubsDirectory . '/Model/ModelReverseRelationshipFunctions.php'); |
|
596 | + $method = File::get($this->stubsDirectory.'/Model/ModelReverseRelationshipFunctions.php'); |
|
597 | 597 | |
598 | 598 | foreach ($this->modelData->reverseRelationships as $relationship) |
599 | 599 | { |
@@ -625,9 +625,9 @@ discard block |
||
625 | 625 | * |
626 | 626 | * @return $this |
627 | 627 | */ |
628 | - public function replaceCheckbox(){ |
|
628 | + public function replaceCheckbox() { |
|
629 | 629 | |
630 | - $method = File::get($this->stubsDirectory . '/Model/ModelCheckbox.php'); |
|
630 | + $method = File::get($this->stubsDirectory.'/Model/ModelCheckbox.php'); |
|
631 | 631 | $key = false; |
632 | 632 | |
633 | 633 | $method = str_replace('{{class_name_lw}}', $this->modelData->tableName, $method); |
@@ -645,7 +645,7 @@ discard block |
||
645 | 645 | * |
646 | 646 | * @return $this |
647 | 647 | */ |
648 | - private function replaceSimpleFilter(){ |
|
648 | + private function replaceSimpleFilter() { |
|
649 | 649 | $i = 0; |
650 | 650 | |
651 | 651 | $stubSimpleFilter = ''; |
@@ -654,41 +654,41 @@ discard block |
||
654 | 654 | { |
655 | 655 | //var_dump($field->name); |
656 | 656 | |
657 | - if($field->index == 'primary'){ |
|
658 | - $dbType = 'primaryKey' ; |
|
657 | + if ($field->index == 'primary') { |
|
658 | + $dbType = 'primaryKey'; |
|
659 | 659 | } |
660 | - elseif($field->foreignKey){ |
|
661 | - $dbType = 'primary' ; |
|
660 | + elseif ($field->foreignKey) { |
|
661 | + $dbType = 'primary'; |
|
662 | 662 | } |
663 | - elseif($field->type->db == 'enum'){ |
|
664 | - $dbType = 'primary' ; |
|
663 | + elseif ($field->type->db == 'enum') { |
|
664 | + $dbType = 'primary'; |
|
665 | 665 | } |
666 | - elseif($field->type->db == 'boolean'){ |
|
667 | - $dbType = 'primary' ; |
|
666 | + elseif ($field->type->db == 'boolean') { |
|
667 | + $dbType = 'primary'; |
|
668 | 668 | } |
669 | - elseif($field->type->db == 'text'){ |
|
670 | - $dbType = 'string' ; |
|
669 | + elseif ($field->type->db == 'text') { |
|
670 | + $dbType = 'string'; |
|
671 | 671 | } |
672 | 672 | else { |
673 | - $dbType = $field->type->db ; |
|
673 | + $dbType = $field->type->db; |
|
674 | 674 | } |
675 | 675 | |
676 | - if($dbType == 'primaryKey') |
|
676 | + if ($dbType == 'primaryKey') |
|
677 | 677 | { |
678 | 678 | $stubSimpleFilter .= '$query->where("'.$this->modelData->tableName.'.'.$field->name.'", "=", $'.$this->modelData->tableName.'Conditions["'.$field->name.'"])'.PHP_EOL; |
679 | 679 | } |
680 | 680 | |
681 | - if($dbType == 'primary') |
|
681 | + if ($dbType == 'primary') |
|
682 | 682 | { |
683 | 683 | $stubSimpleFilter .= '->orWhere("'.$this->modelData->tableName.'.'.$field->name.'", "=", $'.$this->modelData->tableName.'Conditions["'.$field->name.'"])'.PHP_EOL; |
684 | 684 | } |
685 | 685 | |
686 | - if($dbType == 'string') |
|
686 | + if ($dbType == 'string') |
|
687 | 687 | { |
688 | 688 | $stubSimpleFilter .= '->orWhere("'.$this->modelData->tableName.'.'.$field->name.'", "LIKE", "%".$'.$this->modelData->tableName.'Conditions["'.$field->name.'"]."%")'.PHP_EOL; |
689 | 689 | } |
690 | 690 | |
691 | - if($dbType == 'date' || $dbType == 'datetime' || $dbType == 'float' || $dbType == 'integer' || $dbType == 'number') |
|
691 | + if ($dbType == 'date' || $dbType == 'datetime' || $dbType == 'float' || $dbType == 'integer' || $dbType == 'number') |
|
692 | 692 | { |
693 | 693 | $stubSimpleFilter .= '->orWhere("'.$this->modelData->tableName.'.'.$field->name.'", "=", $'.$this->modelData->tableName.'Conditions["'.$field->name.'"])'.PHP_EOL; |
694 | 694 | } |
@@ -13,11 +13,11 @@ discard block |
||
13 | 13 | private $date; |
14 | 14 | |
15 | 15 | protected $cachePrefix = 'migration_'; |
16 | - protected $stubFilename = 'Migration.php' ; |
|
16 | + protected $stubFilename = 'Migration.php'; |
|
17 | 17 | |
18 | 18 | public function __construct($scaffolderConfig, $modelData = null) |
19 | 19 | { |
20 | - $this->stubsDirectory = __DIR__ . '/../../../../stubs/Api/'; |
|
20 | + $this->stubsDirectory = __DIR__.'/../../../../stubs/Api/'; |
|
21 | 21 | |
22 | 22 | parent::__construct($scaffolderConfig, $modelData); |
23 | 23 | |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | protected function getOutputFilename() |
47 | 47 | { |
48 | 48 | |
49 | - return PathParser::parse($this->scaffolderConfig->generator->paths->migrations) . $this->date->format('Y_m_d_') . str_pad($this->modelData->migrationOrder, 2, 0, STR_PAD_LEFT) . '_create_' . strtolower($this->modelName) . '_table.php'; |
|
49 | + return PathParser::parse($this->scaffolderConfig->generator->paths->migrations).$this->date->format('Y_m_d_').str_pad($this->modelData->migrationOrder, 2, 0, STR_PAD_LEFT).'_create_'.strtolower($this->modelName).'_table.php'; |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | private function addFields() |
60 | 60 | { |
61 | 61 | // Default primary key |
62 | - $fields = "\t\t\t\$table->increments('id');" . PHP_EOL . PHP_EOL; |
|
62 | + $fields = "\t\t\t\$table->increments('id');".PHP_EOL.PHP_EOL; |
|
63 | 63 | |
64 | 64 | // Check primary key |
65 | 65 | # TODO FIX, primary |
@@ -68,12 +68,12 @@ discard block |
||
68 | 68 | { |
69 | 69 | $parsedModifiers = ''; |
70 | 70 | |
71 | - if($field->index == "primary") |
|
72 | - continue ; |
|
73 | - if($this->modelData->timeStamps && $field->name == "created_at") |
|
74 | - continue ; |
|
75 | - if($this->modelData->timeStamps && $field->name == "updated_at") |
|
76 | - continue ; |
|
71 | + if ($field->index == "primary") |
|
72 | + continue; |
|
73 | + if ($this->modelData->timeStamps && $field->name == "created_at") |
|
74 | + continue; |
|
75 | + if ($this->modelData->timeStamps && $field->name == "updated_at") |
|
76 | + continue; |
|
77 | 77 | |
78 | 78 | // Check modifiers |
79 | 79 | if (!empty($field->modifiers)) |
@@ -86,11 +86,11 @@ discard block |
||
86 | 86 | |
87 | 87 | if (count($modifierAndValue) == 2) |
88 | 88 | { |
89 | - $parsedModifiers .= '->' . $modifierAndValue[0] . '(' . $modifierAndValue[1] . ')'; |
|
89 | + $parsedModifiers .= '->'.$modifierAndValue[0].'('.$modifierAndValue[1].')'; |
|
90 | 90 | } |
91 | 91 | else |
92 | 92 | { |
93 | - $parsedModifiers .= '->' . $modifierAndValue[0] . '()'; |
|
93 | + $parsedModifiers .= '->'.$modifierAndValue[0].'()'; |
|
94 | 94 | } |
95 | 95 | } |
96 | 96 | } |
@@ -104,33 +104,33 @@ discard block |
||
104 | 104 | // Check indexes |
105 | 105 | if ($field->index != 'none') |
106 | 106 | { |
107 | - $fields .= sprintf("\t\t\t\$table->%s('%s')%s->%s();" . PHP_EOL, $field->type->db, $field->name, $parsedModifiers, $field->index); |
|
107 | + $fields .= sprintf("\t\t\t\$table->%s('%s')%s->%s();".PHP_EOL, $field->type->db, $field->name, $parsedModifiers, $field->index); |
|
108 | 108 | } |
109 | 109 | else |
110 | 110 | { |
111 | 111 | if ($field->type->db == "enum") { |
112 | 112 | $items = ''; |
113 | 113 | foreach ($field->options as $key => $option) { |
114 | - $items .= "'" . $option . "'"; |
|
114 | + $items .= "'".$option."'"; |
|
115 | 115 | if ($key < (count($field->options) - 1)) |
116 | 116 | $items .= ", "; |
117 | 117 | } |
118 | 118 | |
119 | - $fields .= sprintf("\t\t\t\$table->%s('%s', array(%s));" . PHP_EOL, $field->type->db, $field->name, $items); |
|
119 | + $fields .= sprintf("\t\t\t\$table->%s('%s', array(%s));".PHP_EOL, $field->type->db, $field->name, $items); |
|
120 | 120 | } |
121 | 121 | else |
122 | - $fields .= sprintf("\t\t\t\$table->%s('%s')%s;" . PHP_EOL, $field->type->db, $field->name, $parsedModifiers); |
|
122 | + $fields .= sprintf("\t\t\t\$table->%s('%s')%s;".PHP_EOL, $field->type->db, $field->name, $parsedModifiers); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | // Check foreign key |
126 | 126 | if ($field->foreignKey) |
127 | 127 | { |
128 | - $fields .= sprintf("\t\t\t\$table->foreign('%s')->references('%s')->on('%s');" . PHP_EOL . PHP_EOL, $field->name, $field->foreignKey->field, $field->foreignKey->table); |
|
128 | + $fields .= sprintf("\t\t\t\$table->foreign('%s')->references('%s')->on('%s');".PHP_EOL.PHP_EOL, $field->name, $field->foreignKey->field, $field->foreignKey->table); |
|
129 | 129 | } |
130 | 130 | } |
131 | 131 | |
132 | - if($this->modelData->timeStamps) |
|
133 | - $fields .= PHP_EOL . "\t\t\t\$table->timestamps();" . PHP_EOL; |
|
132 | + if ($this->modelData->timeStamps) |
|
133 | + $fields .= PHP_EOL."\t\t\t\$table->timestamps();".PHP_EOL; |
|
134 | 134 | |
135 | 135 | $this->stub = str_replace('{{fields}}', $fields, $this->stub); |
136 | 136 |
@@ -11,13 +11,13 @@ discard block |
||
11 | 11 | class ControllerCompiler extends AbstractCompiler |
12 | 12 | { |
13 | 13 | protected $cachePrefix = 'controller_'; |
14 | - protected $stubFilename = 'Controller/Controller.php' ; |
|
14 | + protected $stubFilename = 'Controller/Controller.php'; |
|
15 | 15 | |
16 | 16 | public function __construct($scaffolderConfig, $modelData = null, $stubName = null) |
17 | 17 | { |
18 | 18 | if ($stubName) |
19 | 19 | $this->stubFilename = $stubName; |
20 | - $this->stubsDirectory = __DIR__ . '/../../../../stubs/Api/'; |
|
20 | + $this->stubsDirectory = __DIR__.'/../../../../stubs/Api/'; |
|
21 | 21 | parent::__construct($scaffolderConfig, $modelData); |
22 | 22 | } |
23 | 23 | |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | protected function getOutputFilename() |
55 | 55 | { |
56 | 56 | |
57 | - return PathParser::parse($this->scaffolderConfig->generator->paths->controllers) . $this->modelName . 'Controller.php'; |
|
57 | + return PathParser::parse($this->scaffolderConfig->generator->paths->controllers).$this->modelName.'Controller.php'; |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -67,11 +67,11 @@ discard block |
||
67 | 67 | $storeCommands = $updateCommands = $ruleCommands = $useCommands = ''; |
68 | 68 | $eagerConditions = $eagerJoins = ''; |
69 | 69 | |
70 | - $storeEagerStubOriginal = File::get($this->stubsDirectory . 'StoreEager.php'); |
|
71 | - $updateEagerStubOriginal = File::get($this->stubsDirectory . 'UpdateEager.php'); |
|
72 | - $rulesEagerStubOriginal = File::get($this->stubsDirectory . 'RulesEager.php'); |
|
73 | - $useEagerStubOriginal = File::get($this->stubsDirectory . 'UseEager.php'); |
|
74 | - $joinEagerStubOriginal = File::get($this->stubsDirectory . 'SearchConditions/JoinEager.php'); |
|
70 | + $storeEagerStubOriginal = File::get($this->stubsDirectory.'StoreEager.php'); |
|
71 | + $updateEagerStubOriginal = File::get($this->stubsDirectory.'UpdateEager.php'); |
|
72 | + $rulesEagerStubOriginal = File::get($this->stubsDirectory.'RulesEager.php'); |
|
73 | + $useEagerStubOriginal = File::get($this->stubsDirectory.'UseEager.php'); |
|
74 | + $joinEagerStubOriginal = File::get($this->stubsDirectory.'SearchConditions/JoinEager.php'); |
|
75 | 75 | |
76 | 76 | foreach ($this->modelData->fields as $field) |
77 | 77 | { |
@@ -81,20 +81,20 @@ discard block |
||
81 | 81 | { |
82 | 82 | |
83 | 83 | $storeCommands .= str_replace('{{foreign_model_name}}', CamelCase::convertToCamelCase($field->foreignKey->table), $this->replaceForeingStrings($field, $storeEagerStubOriginal)); |
84 | - $updateCommands .= str_replace('{{foreign_model_name}}', CamelCase::convertToCamelCase($field->foreignKey->table), $this->replaceForeingStrings($field, $updateEagerStubOriginal)) ; |
|
85 | - $ruleCommands .= str_replace('{{foreign_model_name}}', CamelCase::convertToCamelCase($field->foreignKey->table), $this->replaceForeingStrings($field, $rulesEagerStubOriginal)) ; |
|
86 | - $useCommands .= str_replace('{{foreign_model_name}}', CamelCase::convertToCamelCase($field->foreignKey->table), $this->replaceForeingStrings($field, $useEagerStubOriginal)) ; |
|
87 | - $eagerJoins .= $this->replaceForeingStrings($field, $joinEagerStubOriginal) ; |
|
84 | + $updateCommands .= str_replace('{{foreign_model_name}}', CamelCase::convertToCamelCase($field->foreignKey->table), $this->replaceForeingStrings($field, $updateEagerStubOriginal)); |
|
85 | + $ruleCommands .= str_replace('{{foreign_model_name}}', CamelCase::convertToCamelCase($field->foreignKey->table), $this->replaceForeingStrings($field, $rulesEagerStubOriginal)); |
|
86 | + $useCommands .= str_replace('{{foreign_model_name}}', CamelCase::convertToCamelCase($field->foreignKey->table), $this->replaceForeingStrings($field, $useEagerStubOriginal)); |
|
87 | + $eagerJoins .= $this->replaceForeingStrings($field, $joinEagerStubOriginal); |
|
88 | 88 | |
89 | 89 | // search eager fields |
90 | 90 | $foreignModelData = $this->getModelData($field->foreignKey->table); |
91 | 91 | $foreignControllerCompiler = new ControllerCompiler($this->scaffolderConfig, $foreignModelData); |
92 | 92 | $foreignControllerCompiler->setEagerTable($this->modelData->tableName); |
93 | - $eagerConditions .= $foreignControllerCompiler->getSearchConditions(); |
|
93 | + $eagerConditions .= $foreignControllerCompiler->getSearchConditions(); |
|
94 | 94 | $eagerUniqueRules = $foreignControllerCompiler->getEagerUniqueRules(); |
95 | 95 | $eagerUniqueRules = str_replace("{{class_name_lw}}", strtolower($this->modelName), $eagerUniqueRules); |
96 | 96 | $eagerUniqueRules = str_replace("{{field}}", $field->name, $eagerUniqueRules); |
97 | - $ruleCommands = str_replace('{{unique_eager_rules}}', $eagerUniqueRules, $ruleCommands) ; |
|
97 | + $ruleCommands = str_replace('{{unique_eager_rules}}', $eagerUniqueRules, $ruleCommands); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | } |
@@ -113,12 +113,12 @@ discard block |
||
113 | 113 | } |
114 | 114 | |
115 | 115 | |
116 | - public function replaceSortConditions() { |
|
116 | + public function replaceSortConditions() { |
|
117 | 117 | $joinSorts = ''; |
118 | 118 | |
119 | 119 | foreach ($this->modelData->fields as $field) { |
120 | - if($field->foreignKey){ |
|
121 | - $joinSortStub = File::get($this->stubsDirectory . 'SearchConditions/JoinSort.php'); |
|
120 | + if ($field->foreignKey) { |
|
121 | + $joinSortStub = File::get($this->stubsDirectory.'SearchConditions/JoinSort.php'); |
|
122 | 122 | $joinSortStub = str_replace('{{field}}', $field->name, $joinSortStub); |
123 | 123 | $joinSortStub = str_replace('{{foreign_table}}', $field->foreignKey->table, $joinSortStub); |
124 | 124 | $joinSortStub = str_replace('{{foreign_key}}', $field->foreignKey->table, $joinSortStub); |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | foreach ($this->modelData->fields as $field) { |
143 | 143 | if (strpos($field->validations, 'unique')) { |
144 | 144 | $rule = sprintf('$rules["%s"] = $rules["%s"] . \',%s,\' . $id;', $field->name, $field->name, $field->name); |
145 | - $uniqueRules .= $rule . "\n"; |
|
145 | + $uniqueRules .= $rule."\n"; |
|
146 | 146 | } |
147 | 147 | } |
148 | 148 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | foreach ($this->modelData->fields as $field) { |
158 | 158 | if (strpos($field->validations, 'unique')) { |
159 | 159 | $rule = sprintf('$rules["%s.%s"] .= \',%s,\' . ${{class_name_lw}}->{{field}};', $this->modelData->tableName, $field->name, $field->name); |
160 | - $uniqueRules .= $rule . "\n"; |
|
160 | + $uniqueRules .= $rule."\n"; |
|
161 | 161 | } |
162 | 162 | } |
163 | 163 | |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | * |
170 | 170 | * @return $this |
171 | 171 | */ |
172 | - private function replaceSearchConditions(){ |
|
172 | + private function replaceSearchConditions() { |
|
173 | 173 | |
174 | 174 | $searchConditions = $this->getSearchConditions(); |
175 | 175 | |
@@ -183,16 +183,16 @@ discard block |
||
183 | 183 | * |
184 | 184 | * @return $this |
185 | 185 | */ |
186 | - public function getSearchConditions(){ |
|
186 | + public function getSearchConditions() { |
|
187 | 187 | |
188 | 188 | $fieldConditions = ''; |
189 | 189 | |
190 | - $searchConditions = File::get($this->stubsDirectory . '/SearchConditions/Conditions.php'); |
|
190 | + $searchConditions = File::get($this->stubsDirectory.'/SearchConditions/Conditions.php'); |
|
191 | 191 | |
192 | 192 | foreach ($this->modelData->fields as $field) |
193 | 193 | { |
194 | 194 | |
195 | - $fieldConditions .= $this->replaceFieldStrings($field, $this->getConditionStubByField($field)) ; |
|
195 | + $fieldConditions .= $this->replaceFieldStrings($field, $this->getConditionStubByField($field)); |
|
196 | 196 | |
197 | 197 | } |
198 | 198 | |
@@ -202,7 +202,7 @@ discard block |
||
202 | 202 | // replace table name |
203 | 203 | $searchConditions = str_replace('{{table_name}}', $this->modelData->tableName, $searchConditions); |
204 | 204 | |
205 | - return $searchConditions ; |
|
205 | + return $searchConditions; |
|
206 | 206 | |
207 | 207 | } |
208 | 208 | |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | * |
213 | 213 | * @return $this |
214 | 214 | */ |
215 | - private function replaceSimpleFilter(){ |
|
215 | + private function replaceSimpleFilter() { |
|
216 | 216 | $i = 0; |
217 | 217 | |
218 | 218 | $stubSimpleFilter = ''; |
@@ -221,41 +221,41 @@ discard block |
||
221 | 221 | { |
222 | 222 | //var_dump($field->name); |
223 | 223 | |
224 | - if($field->index == 'primary'){ |
|
225 | - $dbType = 'primaryKey' ; |
|
224 | + if ($field->index == 'primary') { |
|
225 | + $dbType = 'primaryKey'; |
|
226 | 226 | } |
227 | - elseif($field->foreignKey){ |
|
228 | - $dbType = 'primary' ; |
|
227 | + elseif ($field->foreignKey) { |
|
228 | + $dbType = 'primary'; |
|
229 | 229 | } |
230 | - elseif($field->type->db == 'enum'){ |
|
231 | - $dbType = 'primary' ; |
|
230 | + elseif ($field->type->db == 'enum') { |
|
231 | + $dbType = 'primary'; |
|
232 | 232 | } |
233 | - elseif($field->type->db == 'boolean'){ |
|
234 | - $dbType = 'primary' ; |
|
233 | + elseif ($field->type->db == 'boolean') { |
|
234 | + $dbType = 'primary'; |
|
235 | 235 | } |
236 | - elseif($field->type->db == 'text'){ |
|
237 | - $dbType = 'string' ; |
|
236 | + elseif ($field->type->db == 'text') { |
|
237 | + $dbType = 'string'; |
|
238 | 238 | } |
239 | 239 | else { |
240 | - $dbType = $field->type->db ; |
|
240 | + $dbType = $field->type->db; |
|
241 | 241 | } |
242 | 242 | |
243 | - if($dbType == 'primaryKey') |
|
243 | + if ($dbType == 'primaryKey') |
|
244 | 244 | { |
245 | 245 | $stubSimpleFilter .= '$query->where("'.$this->modelData->tableName.'.'.$field->name.'", "=", $'.$this->modelData->tableName.'Conditions["'.$field->name.'"])'.PHP_EOL; |
246 | 246 | } |
247 | 247 | |
248 | - if($dbType == 'primary') |
|
248 | + if ($dbType == 'primary') |
|
249 | 249 | { |
250 | 250 | $stubSimpleFilter .= '->orWhere("'.$this->modelData->tableName.'.'.$field->name.'", "=", $'.$this->modelData->tableName.'Conditions["'.$field->name.'"])'.PHP_EOL; |
251 | 251 | } |
252 | 252 | |
253 | - if($dbType == 'string') |
|
253 | + if ($dbType == 'string') |
|
254 | 254 | { |
255 | 255 | $stubSimpleFilter .= '->orWhere("'.$this->modelData->tableName.'.'.$field->name.'", "LIKE", "%".$'.$this->modelData->tableName.'Conditions["'.$field->name.'"]."%")'.PHP_EOL; |
256 | 256 | } |
257 | 257 | |
258 | - if($dbType == 'date' || $dbType == 'datetime' || $dbType == 'float' || $dbType == 'integer' || $dbType == 'number') |
|
258 | + if ($dbType == 'date' || $dbType == 'datetime' || $dbType == 'float' || $dbType == 'integer' || $dbType == 'number') |
|
259 | 259 | { |
260 | 260 | $stubSimpleFilter .= '->orWhere("'.$this->modelData->tableName.'.'.$field->name.'", "=", $'.$this->modelData->tableName.'Conditions["'.$field->name.'"])'.PHP_EOL; |
261 | 261 | } |
@@ -273,11 +273,11 @@ discard block |
||
273 | 273 | * |
274 | 274 | * @return $this |
275 | 275 | */ |
276 | - public function replaceReverseRelationships(){ |
|
276 | + public function replaceReverseRelationships() { |
|
277 | 277 | |
278 | 278 | $functions = ''; |
279 | 279 | |
280 | - $method = File::get($this->stubsDirectory . '/Controller/ControllerReverseRelationship.php'); |
|
280 | + $method = File::get($this->stubsDirectory.'/Controller/ControllerReverseRelationship.php'); |
|
281 | 281 | |
282 | 282 | foreach ($this->modelData->reverseRelationships as $relationship) |
283 | 283 | { |
@@ -308,11 +308,11 @@ discard block |
||
308 | 308 | * |
309 | 309 | * @return $this |
310 | 310 | */ |
311 | - public function replaceEnum(){ |
|
311 | + public function replaceEnum() { |
|
312 | 312 | |
313 | 313 | $functions = ''; |
314 | 314 | |
315 | - $method = File::get($this->stubsDirectory . '/Controller/ControllerEnum.php'); |
|
315 | + $method = File::get($this->stubsDirectory.'/Controller/ControllerEnum.php'); |
|
316 | 316 | |
317 | 317 | foreach ($this->modelData->fields as $field) |
318 | 318 | { |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | $joins = ""; |
348 | 348 | $joinSorts = ""; |
349 | 349 | |
350 | - $method = File::get($this->stubsDirectory . '/Controller/ControllerRelationshipTable.php'); |
|
350 | + $method = File::get($this->stubsDirectory.'/Controller/ControllerRelationshipTable.php'); |
|
351 | 351 | |
352 | 352 | foreach ($this->modelData->reverseRelationships as $relationship) { |
353 | 353 | |
@@ -373,9 +373,9 @@ discard block |
||
373 | 373 | $methodCall = str_replace('{{related_table_pl}}', $relatedTablePluralized, $methodCall); |
374 | 374 | $methodCall = str_replace('{{class_name_lw}}', $this->modelData->tableName, $methodCall); |
375 | 375 | |
376 | - $functionsCall .= $methodCall . "\n\t\t"; |
|
376 | + $functionsCall .= $methodCall."\n\t\t"; |
|
377 | 377 | |
378 | - $removeAllMethod = File::get($this->stubsDirectory . '/Controller/ControllerRemoveAll.php'); |
|
378 | + $removeAllMethod = File::get($this->stubsDirectory.'/Controller/ControllerRemoveAll.php'); |
|
379 | 379 | $removeAllMethod = str_replace('{{related_table_pl_uc}}', $relatedTablePluralizedUc, $removeAllMethod); |
380 | 380 | $removeAllMethod = str_replace('{{foreign_key}}', $relationship->foreignKey, $removeAllMethod); |
381 | 381 | $removeAllMethod = str_replace('{{foreign_table}}', $relationship->modelName, $removeAllMethod); |
@@ -387,9 +387,9 @@ discard block |
||
387 | 387 | $removeAllCallMethod = str_replace('{{related_table_pl_uc}}', $relatedTablePluralizedUc, $removeAllCallMethod); |
388 | 388 | $removeAllCallMethod = str_replace('{{class_name_lw}}', $this->modelData->tableName, $removeAllCallMethod); |
389 | 389 | |
390 | - $removeAllCall .= $removeAllCallMethod . "\n\t\t"; |
|
390 | + $removeAllCall .= $removeAllCallMethod."\n\t\t"; |
|
391 | 391 | |
392 | - $joinRelationshipTableStub = File::get($this->stubsDirectory . 'SearchConditions/joinRelationshipTable.php'); |
|
392 | + $joinRelationshipTableStub = File::get($this->stubsDirectory.'SearchConditions/joinRelationshipTable.php'); |
|
393 | 393 | $joinRelationshipTableStub = str_replace('{{class_name_lw}}', $this->modelData->tableName, $joinRelationshipTableStub); |
394 | 394 | $joinRelationshipTableStub = str_replace('{{related_table_pl}}', $relatedTablePluralized, $joinRelationshipTableStub); |
395 | 395 | $joinRelationshipTableStub = str_replace('{{related_table}}', CamelCase::convertToCamelCase($relationship->relatedTable), $joinRelationshipTableStub); |
@@ -397,12 +397,12 @@ discard block |
||
397 | 397 | $joinRelationshipTableStub = str_replace('{{related_field}}', $relationship->relatedField, $joinRelationshipTableStub); |
398 | 398 | $joinRelationshipTableStub = str_replace('{{foreign_table}}', $relationship->tableName, $joinRelationshipTableStub); |
399 | 399 | |
400 | - $joins .= $joinRelationshipTableStub . "\n"; |
|
400 | + $joins .= $joinRelationshipTableStub."\n"; |
|
401 | 401 | |
402 | 402 | $use = 'use App\Models\{{foreign_table}};'; |
403 | 403 | $use = str_replace('{{foreign_table}}', $relationship->modelName, $use); |
404 | 404 | |
405 | - $includes .= $use . "\n"; |
|
405 | + $includes .= $use."\n"; |
|
406 | 406 | } |
407 | 407 | } |
408 | 408 | |
@@ -430,9 +430,9 @@ discard block |
||
430 | 430 | * |
431 | 431 | * @return $this |
432 | 432 | */ |
433 | - public function replaceCheckbox(){ |
|
433 | + public function replaceCheckbox() { |
|
434 | 434 | |
435 | - $method = File::get($this->stubsDirectory . '/Controller/ControllerCheckbox.php'); |
|
435 | + $method = File::get($this->stubsDirectory.'/Controller/ControllerCheckbox.php'); |
|
436 | 436 | $key = false; |
437 | 437 | |
438 | 438 | $method = str_replace('{{class_name_lw}}', $this->modelData->tableName, $method); |
@@ -474,32 +474,32 @@ discard block |
||
474 | 474 | * @return $this |
475 | 475 | */ |
476 | 476 | private $conditionsStub = []; |
477 | - private function getConditionStubByField($field){ |
|
477 | + private function getConditionStubByField($field) { |
|
478 | 478 | |
479 | - if($field->index == 'primary'){ |
|
480 | - $dbType = 'primary' ; |
|
479 | + if ($field->index == 'primary') { |
|
480 | + $dbType = 'primary'; |
|
481 | 481 | } |
482 | - elseif($field->foreignKey){ |
|
483 | - $dbType = 'primary' ; |
|
482 | + elseif ($field->foreignKey) { |
|
483 | + $dbType = 'primary'; |
|
484 | 484 | } |
485 | - elseif($field->type->db == 'enum'){ |
|
486 | - $dbType = 'primary' ; |
|
485 | + elseif ($field->type->db == 'enum') { |
|
486 | + $dbType = 'primary'; |
|
487 | 487 | } |
488 | - elseif($field->type->db == 'boolean'){ |
|
489 | - $dbType = 'primary' ; |
|
488 | + elseif ($field->type->db == 'boolean') { |
|
489 | + $dbType = 'primary'; |
|
490 | 490 | } |
491 | - elseif($field->type->db == 'text'){ |
|
492 | - $dbType = 'string' ; |
|
491 | + elseif ($field->type->db == 'text') { |
|
492 | + $dbType = 'string'; |
|
493 | 493 | } |
494 | 494 | else { |
495 | - $dbType = $field->type->db ; |
|
495 | + $dbType = $field->type->db; |
|
496 | 496 | } |
497 | 497 | |
498 | - if(array_key_exists($dbType, $this->conditionsStub)){ |
|
498 | + if (array_key_exists($dbType, $this->conditionsStub)) { |
|
499 | 499 | return $this->conditionsStub[$dbType]; |
500 | 500 | } |
501 | 501 | else { |
502 | - $this->conditionsStub[$dbType] = File::get($this->stubsDirectory . 'SearchConditions/'. ucwords($dbType). '.php');; |
|
502 | + $this->conditionsStub[$dbType] = File::get($this->stubsDirectory.'SearchConditions/'.ucwords($dbType).'.php'); ; |
|
503 | 503 | |
504 | 504 | return $this->conditionsStub[$dbType]; |
505 | 505 | } |
@@ -10,18 +10,18 @@ discard block |
||
10 | 10 | |
11 | 11 | class RouteCompiler extends AbstractCompiler |
12 | 12 | { |
13 | - protected $stubFilename = 'Routes.php' ; |
|
13 | + protected $stubFilename = 'Routes.php'; |
|
14 | 14 | |
15 | - protected $stubResourceFilename = 'ResourceRoute.php' ; |
|
16 | - protected $stubResource ; |
|
15 | + protected $stubResourceFilename = 'ResourceRoute.php'; |
|
16 | + protected $stubResource; |
|
17 | 17 | |
18 | 18 | |
19 | 19 | public function __construct($scaffolderConfig, $modelData = null) |
20 | 20 | { |
21 | - $this->stubsDirectory = __DIR__ . '/../../../../stubs/Api/'; |
|
21 | + $this->stubsDirectory = __DIR__.'/../../../../stubs/Api/'; |
|
22 | 22 | parent::__construct($scaffolderConfig, null); |
23 | 23 | |
24 | - $this->stubResource = File::get($this->stubsDirectory . $this->stubResourceFilename ); |
|
24 | + $this->stubResource = File::get($this->stubsDirectory.$this->stubResourceFilename); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | /** |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * |
30 | 30 | * @return string |
31 | 31 | */ |
32 | - public function replaceAndStore(){} |
|
32 | + public function replaceAndStore() {} |
|
33 | 33 | |
34 | 34 | /** |
35 | 35 | * Compiles a resource. |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | { |
71 | 71 | $folder = PathParser::parse($this->scaffolderConfig->generator->paths->routes); |
72 | 72 | |
73 | - return $folder . 'routes.php'; |
|
73 | + return $folder.'routes.php'; |
|
74 | 74 | } |
75 | 75 | |
76 | 76 |
@@ -17,7 +17,7 @@ |
||
17 | 17 | public function get{{class_name}}s() |
18 | 18 | { |
19 | 19 | return Datatables::of({{class_name}}::select('*')) |
20 | - ->addColumn('action', function ($model) { |
|
20 | + ->addColumn('action', function($model) { |
|
21 | 21 | return ' |
22 | 22 | <a href="/{{route_prefix}}/{{class_name_lw}}/'.$model->{{primaryKey}}.'/edit"><i class="material-icons">create</i></a> |
23 | 23 | <a href="#" onclick="deleteModel(\''.$model->{{primaryKey}}.'\')"><i class="material-icons">delete</i></a>'; |
@@ -5,10 +5,10 @@ discard block |
||
5 | 5 | |-------------------------------------------------------------------------- |
6 | 6 | */ |
7 | 7 | |
8 | -Route::group(['prefix' => '{{route_prefix}}', 'middleware' => 'cors'], function () |
|
8 | +Route::group(['prefix' => '{{route_prefix}}', 'middleware' => 'cors'], function() |
|
9 | 9 | { |
10 | 10 | |
11 | - Route::get('dashboard', function () |
|
11 | + Route::get('dashboard', function() |
|
12 | 12 | { |
13 | 13 | return view('dashboard'); |
14 | 14 | }); |
@@ -21,15 +21,15 @@ discard block |
||
21 | 21 | |
22 | 22 | # todo fix in the correct manner |
23 | 23 | // font fix issues |
24 | -Route::get('/styles/ui-grid.woff', function(){ |
|
24 | +Route::get('/styles/ui-grid.woff', function() { |
|
25 | 25 | return file_get_contents(base_path('public').'/fonts/ui-grid.woff'); |
26 | 26 | }); |
27 | 27 | |
28 | -Route::get('/styles/ui-grid.ttf', function(){ |
|
28 | +Route::get('/styles/ui-grid.ttf', function() { |
|
29 | 29 | return file_get_contents(base_path('public').'/fonts/ui-grid.ttf'); |
30 | 30 | }); |
31 | 31 | |
32 | 32 | // other routes point for the dist html file |
33 | -Route::any('{any}', function(){ |
|
33 | +Route::any('{any}', function() { |
|
34 | 34 | return file_get_contents(base_path('public').'/index.html'); |
35 | 35 | })->where('any', '.*'); |
36 | 36 | \ No newline at end of file |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | use Illuminate\Http\Request; |
6 | 6 | use Illuminate\Pagination\Paginator; |
7 | 7 | use App\Http\Controllers\Controller; |
8 | -use App\Models\{{class_name}} as {{class_name}}Model;; |
|
8 | +use App\Models\{{class_name}} as {{class_name}}Model; ; |
|
9 | 9 | use App\Http\Controllers\File as ScaffolderFile; |
10 | 10 | use Log; |
11 | 11 | use Flow\Config as FlowConfig; |
@@ -21,13 +21,13 @@ discard block |
||
21 | 21 | public function show($id) |
22 | 22 | { |
23 | 23 | $file = {{class_name}}Model::find($id); |
24 | - return $file ; |
|
24 | + return $file; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | public function upload() |
28 | 28 | { |
29 | 29 | $config = new FlowConfig(); |
30 | - $config->setTempDir(storage_path() . '/tmp'); |
|
30 | + $config->setTempDir(storage_path().'/tmp'); |
|
31 | 31 | $config->setDeleteChunksOnSave(true); |
32 | 32 | |
33 | 33 | $request = new FlowRequest(); |
@@ -47,12 +47,12 @@ discard block |
||
47 | 47 | $file->saveChunk(); |
48 | 48 | } |
49 | 49 | |
50 | - if ($file->save(storage_path() . '/tmp/' . $request->getFileName())) |
|
50 | + if ($file->save(storage_path().'/tmp/'.$request->getFileName())) |
|
51 | 51 | { |
52 | 52 | $file = FileModel::create([ |
53 | 53 | 'mime_type' => $requestFile['type'], |
54 | 54 | 'size' => $requestFile['size'], |
55 | - 'file_path' => storage_path() . '/tmp/', |
|
55 | + 'file_path' => storage_path().'/tmp/', |
|
56 | 56 | 'filename' => $requestFile['name'], |
57 | 57 | 'disk' => 'local', |
58 | 58 | 'status' => false, |