@@ -41,8 +41,7 @@ |
||
41 | 41 | if (File::exists(base_path('scaffolder-config/cache/' . $this->cachePrefix . self::CACHE_EXT))) |
42 | 42 | { |
43 | 43 | return $this->store(new FileToCompile(true, $this->cachePrefix)); |
44 | - } |
|
45 | - else |
|
44 | + } else |
|
46 | 45 | { |
47 | 46 | |
48 | 47 | return $this->replaceAndStore(); |
@@ -153,10 +153,11 @@ discard block |
||
153 | 153 | $inputValidations = '' ; |
154 | 154 | |
155 | 155 | foreach ($validationsConverted as $attribute => $value) { |
156 | - if($value) |
|
157 | - $inputValidations .= ' '.$attribute.'="'. $value.'"' ; |
|
158 | - else |
|
159 | - $inputValidations .= ' '.$attribute ; |
|
156 | + if($value) { |
|
157 | + $inputValidations .= ' '.$attribute.'="'. $value.'"' ; |
|
158 | + } else { |
|
159 | + $inputValidations .= ' '.$attribute ; |
|
160 | + } |
|
160 | 161 | } |
161 | 162 | |
162 | 163 | $fieldStub = str_replace('{{field_validation}}', $inputValidations, $fieldStub); |
@@ -177,21 +178,19 @@ discard block |
||
177 | 178 | |
178 | 179 | if($field->index == 'primary'){ |
179 | 180 | $uiType = 'primary' ; |
180 | - } |
|
181 | - elseif(isset($field->foreignKey) && $field->foreignKey){ |
|
182 | - if(isset($field->foreignKey->eager) && $field->foreignKey->eager) |
|
183 | - $uiType = 'foreign_eager' ; |
|
184 | - else |
|
185 | - $uiType = $field->type->ui ; |
|
186 | - } |
|
187 | - else { |
|
181 | + } elseif(isset($field->foreignKey) && $field->foreignKey){ |
|
182 | + if(isset($field->foreignKey->eager) && $field->foreignKey->eager) { |
|
183 | + $uiType = 'foreign_eager' ; |
|
184 | + } else { |
|
185 | + $uiType = $field->type->ui ; |
|
186 | + } |
|
187 | + } else { |
|
188 | 188 | $uiType = $field->type->ui ; |
189 | 189 | } |
190 | 190 | |
191 | 191 | if(array_key_exists($uiType, $this->inputStub)){ |
192 | 192 | return $this->inputStub[$uiType]; |
193 | - } |
|
194 | - else { |
|
193 | + } else { |
|
195 | 194 | $this->inputStub[$uiType] = File::get($this->stubsDirectory . 'Register/'. CamelCase::convertToCamelCase($uiType). '.html'); |
196 | 195 | |
197 | 196 | return $this->inputStub[$uiType]; |
@@ -43,8 +43,7 @@ discard block |
||
43 | 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 | - } |
|
47 | - else |
|
46 | + } else |
|
48 | 47 | { |
49 | 48 | |
50 | 49 | return $this->replacePrimaryKey() |
@@ -88,8 +87,7 @@ discard block |
||
88 | 87 | if ($fileToCompile->cached) |
89 | 88 | { |
90 | 89 | File::copy(base_path('scaffolder-config/cache/' . $this->cachePrefix . $fileToCompile->hash . self::CACHE_EXT), $path); |
91 | - } |
|
92 | - else |
|
90 | + } else |
|
93 | 91 | { |
94 | 92 | File::put(base_path('scaffolder-config/cache/' . $this->cachePrefix . $fileToCompile->hash . self::CACHE_EXT), $this->stub); |
95 | 93 | File::copy(base_path('scaffolder-config/cache/' . $this->cachePrefix . $fileToCompile->hash . self::CACHE_EXT), $path); |
@@ -197,8 +195,9 @@ discard block |
||
197 | 195 | $replaceStub = str_replace('{{foreign_model}}', ucwords($field->foreignKey->table), $replaceStub); |
198 | 196 | $replaceStub = str_replace('{{field}}', $field->name, $replaceStub); |
199 | 197 | |
200 | - if(isset($this->scaffolderConfig->generator->namespaces)) |
|
201 | - $replaceStub = str_replace('{{model_namespace}}', $this->scaffolderConfig->generator->namespaces->models, $replaceStub); |
|
198 | + if(isset($this->scaffolderConfig->generator->namespaces)) { |
|
199 | + $replaceStub = str_replace('{{model_namespace}}', $this->scaffolderConfig->generator->namespaces->models, $replaceStub); |
|
200 | + } |
|
202 | 201 | |
203 | 202 | return $replaceStub; |
204 | 203 | |
@@ -215,7 +214,9 @@ discard block |
||
215 | 214 | protected function replaceFieldStrings($field, $originalStubPart){ |
216 | 215 | $replaceStub = str_replace('{{field}}', $field->name, $originalStubPart); |
217 | 216 | |
218 | - if($this->eagerTable) $this->eagerTable.'.' ; |
|
217 | + if($this->eagerTable) { |
|
218 | + $this->eagerTable.'.' ; |
|
219 | + } |
|
219 | 220 | |
220 | 221 | $replaceStub = str_replace('{{eager_table}}', $this->eagerTable, $replaceStub); |
221 | 222 | |
@@ -247,8 +248,7 @@ discard block |
||
247 | 248 | |
248 | 249 | if(array_key_exists($tableName, $this->modelDataArray)){ |
249 | 250 | return $this->modelDataArray[$tableName]; |
250 | - } |
|
251 | - else { |
|
251 | + } else { |
|
252 | 252 | |
253 | 253 | $modelFilename = base_path('scaffolder-config/models/') . $tableName . '.json' ; |
254 | 254 |
@@ -16,8 +16,9 @@ discard block |
||
16 | 16 | |
17 | 17 | public function __construct($scaffolderConfig, $modelData = null, $stubName = null) |
18 | 18 | { |
19 | - if ($stubName) |
|
20 | - $this->stubFilename = $stubName; |
|
19 | + if ($stubName) { |
|
20 | + $this->stubFilename = $stubName; |
|
21 | + } |
|
21 | 22 | $this->stubsDirectory = __DIR__ . '/../../../../stubs/Api/'; |
22 | 23 | parent::__construct($scaffolderConfig, $modelData); |
23 | 24 | } |
@@ -91,19 +92,21 @@ discard block |
||
91 | 92 | |
92 | 93 | foreach ($this->modelData->fields as $field) |
93 | 94 | { |
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 ; |
|
95 | + if($field->index == "primary") { |
|
96 | + continue ; |
|
97 | + } |
|
98 | + if($this->modelData->timeStamps && $field->name == "created_at") { |
|
99 | + continue ; |
|
100 | + } |
|
101 | + if($this->modelData->timeStamps && $field->name == "updated_at") { |
|
102 | + continue ; |
|
103 | + } |
|
100 | 104 | |
101 | 105 | if ($firstIteration) |
102 | 106 | { |
103 | 107 | $fields .= sprintf("'%s'," . PHP_EOL, $field->name); |
104 | 108 | $firstIteration = false; |
105 | - } |
|
106 | - else |
|
109 | + } else |
|
107 | 110 | { |
108 | 111 | $fields .= sprintf("\t\t'%s'," . PHP_EOL, $field->name); |
109 | 112 | } |
@@ -127,8 +130,9 @@ discard block |
||
127 | 130 | |
128 | 131 | foreach ($field->options as $key => $option) { |
129 | 132 | $items .= "'" . $option . "'"; |
130 | - if ($key < (count($field->options) - 1)) |
|
131 | - $items .= ", "; |
|
133 | + if ($key < (count($field->options) - 1)) { |
|
134 | + $items .= ", "; |
|
135 | + } |
|
132 | 136 | |
133 | 137 | } |
134 | 138 | |
@@ -160,19 +164,21 @@ discard block |
||
160 | 164 | |
161 | 165 | foreach ($this->modelData->fields as $field) |
162 | 166 | { |
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 ; |
|
167 | + if($field->index == "primary") { |
|
168 | + continue ; |
|
169 | + } |
|
170 | + if($this->modelData->timeStamps && $field->name == "created_at") { |
|
171 | + continue ; |
|
172 | + } |
|
173 | + if($this->modelData->timeStamps && $field->name == "updated_at") { |
|
174 | + continue ; |
|
175 | + } |
|
169 | 176 | |
170 | 177 | if ($firstIteration) |
171 | 178 | { |
172 | 179 | $fields .= sprintf("'%s' => '%s'," . PHP_EOL, $field->name, $field->validations); |
173 | 180 | $firstIteration = false; |
174 | - } |
|
175 | - else |
|
181 | + } else |
|
176 | 182 | { |
177 | 183 | $fields .= sprintf("\t\t\t'%s' => '%s'," . PHP_EOL, $field->name, $field->validations); |
178 | 184 | } |
@@ -245,8 +251,7 @@ discard block |
||
245 | 251 | $belongsToStub = str_replace('{{foreign_model}}', CamelCase::convertToCamelCase($field->foreignKey->table), $belongsToOriginalStub); |
246 | 252 | $belongsToStub = str_replace('{{field}}', $field->name, $belongsToStub); |
247 | 253 | $belongsToStub = str_replace('{{foreign_field}}', $field->foreignKey->field, $belongsToStub); |
248 | - } |
|
249 | - elseif ($field->foreignKey->relationship == "belongsToMany") { |
|
254 | + } elseif ($field->foreignKey->relationship == "belongsToMany") { |
|
250 | 255 | $belongsToOriginalStub = File::get($this->stubsDirectory . '/Model/ModelBelongsToMany.php'); |
251 | 256 | $functionName = CamelCase::pluralize($field->foreignKey->table); |
252 | 257 | $belongsToStub = str_replace('{{foreign_model}}', CamelCase::convertToCamelCase($field->foreignKey->table), $belongsToOriginalStub); |
@@ -289,10 +294,11 @@ discard block |
||
289 | 294 | { |
290 | 295 | $reverseRelationshipStub = ""; |
291 | 296 | $functionName = ''; |
292 | - if ($relationship->type == "hasOne") |
|
293 | - $functionName = strtolower($relationship->modelName); |
|
294 | - else |
|
295 | - $functionName = CamelCase::pluralize(strtolower($relationship->modelName)); |
|
297 | + if ($relationship->type == "hasOne") { |
|
298 | + $functionName = strtolower($relationship->modelName); |
|
299 | + } else { |
|
300 | + $functionName = CamelCase::pluralize(strtolower($relationship->modelName)); |
|
301 | + } |
|
296 | 302 | |
297 | 303 | if ($relationship->type == "belongsToMany") { |
298 | 304 | $reverseRelationshipOriginalStub = File::get($this->stubsDirectory . '/Model/ModelBelongsToMany.php'); |
@@ -301,8 +307,7 @@ discard block |
||
301 | 307 | $reverseRelationshipStub = str_replace('{{table_name}}', $relationship->tableName, $reverseRelationshipStub); |
302 | 308 | $reverseRelationshipStub = str_replace('{{related_field}}', $relationship->relatedField, $reverseRelationshipStub); |
303 | 309 | $reverseRelationshipStub = str_replace('{{foreign_table}}', CamelCase::pluralize(strtolower($relationship->relatedTable)), $reverseRelationshipStub); |
304 | - } |
|
305 | - else { |
|
310 | + } else { |
|
306 | 311 | $reverseRelationshipOriginalStub = File::get($this->stubsDirectory . '/Model/ModelReverseRelationship.php'); |
307 | 312 | $reverseRelationshipStub = str_replace('{{foreign_model}}', $relationship->modelName, $reverseRelationshipOriginalStub); |
308 | 313 | $reverseRelationshipStub = str_replace('{{field}}', $relationship->foreignKey, $reverseRelationshipStub); |
@@ -532,27 +537,21 @@ discard block |
||
532 | 537 | |
533 | 538 | if($field->index == 'primary'){ |
534 | 539 | $dbType = 'primary' ; |
535 | - } |
|
536 | - elseif($field->foreignKey){ |
|
540 | + } elseif($field->foreignKey){ |
|
537 | 541 | $dbType = 'primary' ; |
538 | - } |
|
539 | - elseif($field->type->db == 'enum'){ |
|
542 | + } elseif($field->type->db == 'enum'){ |
|
540 | 543 | $dbType = 'primary' ; |
541 | - } |
|
542 | - elseif($field->type->db == 'boolean'){ |
|
544 | + } elseif($field->type->db == 'boolean'){ |
|
543 | 545 | $dbType = 'primary' ; |
544 | - } |
|
545 | - elseif($field->type->db == 'text'){ |
|
546 | + } elseif($field->type->db == 'text'){ |
|
546 | 547 | $dbType = 'string' ; |
547 | - } |
|
548 | - else { |
|
548 | + } else { |
|
549 | 549 | $dbType = $field->type->db ; |
550 | 550 | } |
551 | 551 | |
552 | 552 | if(array_key_exists($dbType, $this->conditionsStub)){ |
553 | 553 | return $this->conditionsStub[$dbType]; |
554 | - } |
|
555 | - else { |
|
554 | + } else { |
|
556 | 555 | $this->conditionsStub[$dbType] = File::get($this->stubsDirectory . 'SearchConditions/'. ucwords($dbType). '.php');; |
557 | 556 | |
558 | 557 | return $this->conditionsStub[$dbType]; |
@@ -598,12 +597,13 @@ discard block |
||
598 | 597 | foreach ($this->modelData->reverseRelationships as $relationship) |
599 | 598 | { |
600 | 599 | $functionName = ''; |
601 | - if ($relationship->type == "hasOne") |
|
602 | - $functionName = strtolower($relationship->modelName); |
|
603 | - elseif ($relationship->type == "belongsToMany") |
|
604 | - $functionName = CamelCase::pluralize(strtolower($relationship->relatedTable)); |
|
605 | - else |
|
606 | - $functionName = CamelCase::pluralize(strtolower($relationship->modelName)); |
|
600 | + if ($relationship->type == "hasOne") { |
|
601 | + $functionName = strtolower($relationship->modelName); |
|
602 | + } elseif ($relationship->type == "belongsToMany") { |
|
603 | + $functionName = CamelCase::pluralize(strtolower($relationship->relatedTable)); |
|
604 | + } else { |
|
605 | + $functionName = CamelCase::pluralize(strtolower($relationship->modelName)); |
|
606 | + } |
|
607 | 607 | |
608 | 608 | $replacedMethod = ''; |
609 | 609 | $replacedMethod = str_replace('{{function_name}}', $functionName, $method); |
@@ -656,20 +656,15 @@ discard block |
||
656 | 656 | |
657 | 657 | if($field->index == 'primary'){ |
658 | 658 | $dbType = 'primaryKey' ; |
659 | - } |
|
660 | - elseif($field->foreignKey){ |
|
659 | + } elseif($field->foreignKey){ |
|
661 | 660 | $dbType = 'primary' ; |
662 | - } |
|
663 | - elseif($field->type->db == 'enum'){ |
|
661 | + } elseif($field->type->db == 'enum'){ |
|
664 | 662 | $dbType = 'primary' ; |
665 | - } |
|
666 | - elseif($field->type->db == 'boolean'){ |
|
663 | + } elseif($field->type->db == 'boolean'){ |
|
667 | 664 | $dbType = 'primary' ; |
668 | - } |
|
669 | - elseif($field->type->db == 'text'){ |
|
665 | + } elseif($field->type->db == 'text'){ |
|
670 | 666 | $dbType = 'string' ; |
671 | - } |
|
672 | - else { |
|
667 | + } else { |
|
673 | 668 | $dbType = $field->type->db ; |
674 | 669 | } |
675 | 670 |
@@ -68,12 +68,15 @@ 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 | + } |
|
74 | + if($this->modelData->timeStamps && $field->name == "created_at") { |
|
75 | + continue ; |
|
76 | + } |
|
77 | + if($this->modelData->timeStamps && $field->name == "updated_at") { |
|
78 | + continue ; |
|
79 | + } |
|
77 | 80 | |
78 | 81 | // Check modifiers |
79 | 82 | if (!empty($field->modifiers)) |
@@ -87,8 +90,7 @@ discard block |
||
87 | 90 | if (count($modifierAndValue) == 2) |
88 | 91 | { |
89 | 92 | $parsedModifiers .= '->' . $modifierAndValue[0] . '(' . $modifierAndValue[1] . ')'; |
90 | - } |
|
91 | - else |
|
93 | + } else |
|
92 | 94 | { |
93 | 95 | $parsedModifiers .= '->' . $modifierAndValue[0] . '()'; |
94 | 96 | } |
@@ -105,21 +107,21 @@ discard block |
||
105 | 107 | if ($field->index != 'none') |
106 | 108 | { |
107 | 109 | $fields .= sprintf("\t\t\t\$table->%s('%s')%s->%s();" . PHP_EOL, $field->type->db, $field->name, $parsedModifiers, $field->index); |
108 | - } |
|
109 | - else |
|
110 | + } else |
|
110 | 111 | { |
111 | 112 | if ($field->type->db == "enum") { |
112 | 113 | $items = ''; |
113 | 114 | foreach ($field->options as $key => $option) { |
114 | 115 | $items .= "'" . $option . "'"; |
115 | - if ($key < (count($field->options) - 1)) |
|
116 | - $items .= ", "; |
|
116 | + if ($key < (count($field->options) - 1)) { |
|
117 | + $items .= ", "; |
|
118 | + } |
|
117 | 119 | } |
118 | 120 | |
119 | 121 | $fields .= sprintf("\t\t\t\$table->%s('%s', array(%s));" . PHP_EOL, $field->type->db, $field->name, $items); |
122 | + } else { |
|
123 | + $fields .= sprintf("\t\t\t\$table->%s('%s')%s;" . PHP_EOL, $field->type->db, $field->name, $parsedModifiers); |
|
120 | 124 | } |
121 | - else |
|
122 | - $fields .= sprintf("\t\t\t\$table->%s('%s')%s;" . PHP_EOL, $field->type->db, $field->name, $parsedModifiers); |
|
123 | 125 | } |
124 | 126 | |
125 | 127 | // Check foreign key |
@@ -129,8 +131,9 @@ discard block |
||
129 | 131 | } |
130 | 132 | } |
131 | 133 | |
132 | - if($this->modelData->timeStamps) |
|
133 | - $fields .= PHP_EOL . "\t\t\t\$table->timestamps();" . PHP_EOL; |
|
134 | + if($this->modelData->timeStamps) { |
|
135 | + $fields .= PHP_EOL . "\t\t\t\$table->timestamps();" . PHP_EOL; |
|
136 | + } |
|
134 | 137 | |
135 | 138 | $this->stub = str_replace('{{fields}}', $fields, $this->stub); |
136 | 139 |
@@ -15,8 +15,9 @@ discard block |
||
15 | 15 | |
16 | 16 | public function __construct($scaffolderConfig, $modelData = null, $stubName = null) |
17 | 17 | { |
18 | - if ($stubName) |
|
19 | - $this->stubFilename = $stubName; |
|
18 | + if ($stubName) { |
|
19 | + $this->stubFilename = $stubName; |
|
20 | + } |
|
20 | 21 | $this->stubsDirectory = __DIR__ . '/../../../../stubs/Api/'; |
21 | 22 | parent::__construct($scaffolderConfig, $modelData); |
22 | 23 | } |
@@ -223,20 +224,15 @@ discard block |
||
223 | 224 | |
224 | 225 | if($field->index == 'primary'){ |
225 | 226 | $dbType = 'primaryKey' ; |
226 | - } |
|
227 | - elseif($field->foreignKey){ |
|
227 | + } elseif($field->foreignKey){ |
|
228 | 228 | $dbType = 'primary' ; |
229 | - } |
|
230 | - elseif($field->type->db == 'enum'){ |
|
229 | + } elseif($field->type->db == 'enum'){ |
|
231 | 230 | $dbType = 'primary' ; |
232 | - } |
|
233 | - elseif($field->type->db == 'boolean'){ |
|
231 | + } elseif($field->type->db == 'boolean'){ |
|
234 | 232 | $dbType = 'primary' ; |
235 | - } |
|
236 | - elseif($field->type->db == 'text'){ |
|
233 | + } elseif($field->type->db == 'text'){ |
|
237 | 234 | $dbType = 'string' ; |
238 | - } |
|
239 | - else { |
|
235 | + } else { |
|
240 | 236 | $dbType = $field->type->db ; |
241 | 237 | } |
242 | 238 | |
@@ -282,12 +278,13 @@ discard block |
||
282 | 278 | foreach ($this->modelData->reverseRelationships as $relationship) |
283 | 279 | { |
284 | 280 | $functionName = ''; |
285 | - if ($relationship->type == "hasOne") |
|
286 | - $functionName = strtolower($relationship->modelName); |
|
287 | - elseif ($relationship->type == "belongsToMany") |
|
288 | - $functionName = CamelCase::pluralize(strtolower($relationship->relatedTable)); |
|
289 | - else |
|
290 | - $functionName = CamelCase::pluralize(strtolower($relationship->modelName)); |
|
281 | + if ($relationship->type == "hasOne") { |
|
282 | + $functionName = strtolower($relationship->modelName); |
|
283 | + } elseif ($relationship->type == "belongsToMany") { |
|
284 | + $functionName = CamelCase::pluralize(strtolower($relationship->relatedTable)); |
|
285 | + } else { |
|
286 | + $functionName = CamelCase::pluralize(strtolower($relationship->modelName)); |
|
287 | + } |
|
291 | 288 | |
292 | 289 | $replacedMethod = ''; |
293 | 290 | $replacedMethod = str_replace('{{function_name}}', $functionName, $method); |
@@ -478,27 +475,21 @@ discard block |
||
478 | 475 | |
479 | 476 | if($field->index == 'primary'){ |
480 | 477 | $dbType = 'primary' ; |
481 | - } |
|
482 | - elseif($field->foreignKey){ |
|
478 | + } elseif($field->foreignKey){ |
|
483 | 479 | $dbType = 'primary' ; |
484 | - } |
|
485 | - elseif($field->type->db == 'enum'){ |
|
480 | + } elseif($field->type->db == 'enum'){ |
|
486 | 481 | $dbType = 'primary' ; |
487 | - } |
|
488 | - elseif($field->type->db == 'boolean'){ |
|
482 | + } elseif($field->type->db == 'boolean'){ |
|
489 | 483 | $dbType = 'primary' ; |
490 | - } |
|
491 | - elseif($field->type->db == 'text'){ |
|
484 | + } elseif($field->type->db == 'text'){ |
|
492 | 485 | $dbType = 'string' ; |
493 | - } |
|
494 | - else { |
|
486 | + } else { |
|
495 | 487 | $dbType = $field->type->db ; |
496 | 488 | } |
497 | 489 | |
498 | 490 | if(array_key_exists($dbType, $this->conditionsStub)){ |
499 | 491 | return $this->conditionsStub[$dbType]; |
500 | - } |
|
501 | - else { |
|
492 | + } else { |
|
502 | 493 | $this->conditionsStub[$dbType] = File::get($this->stubsDirectory . 'SearchConditions/'. ucwords($dbType). '.php');; |
503 | 494 | |
504 | 495 | return $this->conditionsStub[$dbType]; |
@@ -108,12 +108,13 @@ |
||
108 | 108 | if ($relationship) |
109 | 109 | { |
110 | 110 | $functionName = ''; |
111 | - if ($relationship->type == "hasOne") |
|
112 | - $functionName = strtolower($relationship->modelName); |
|
113 | - elseif ($relationship->type == "belongsToMany") |
|
114 | - $functionName = CamelCase::pluralize(strtolower($relationship->relatedTable)); |
|
115 | - else |
|
116 | - $functionName = CamelCase::pluralize(strtolower($relationship->modelName)); |
|
111 | + if ($relationship->type == "hasOne") { |
|
112 | + $functionName = strtolower($relationship->modelName); |
|
113 | + } elseif ($relationship->type == "belongsToMany") { |
|
114 | + $functionName = CamelCase::pluralize(strtolower($relationship->relatedTable)); |
|
115 | + } else { |
|
116 | + $functionName = CamelCase::pluralize(strtolower($relationship->modelName)); |
|
117 | + } |
|
117 | 118 | |
118 | 119 | $method = "\tRoute::get('{{resource_lw}}/{id}/{{function_name}}', '{{resource}}Controller@{{function_name}}');\n"; |
119 | 120 | $method = str_replace('{{resource_lw}}', strtolower($modelData->modelName), $method); |
@@ -59,8 +59,7 @@ |
||
59 | 59 | ]); |
60 | 60 | |
61 | 61 | return $file->id; |
62 | - } |
|
63 | - else |
|
62 | + } else |
|
64 | 63 | { |
65 | 64 | // Indicate that we are not done with all the chunks. |
66 | 65 | return null; |
@@ -174,8 +174,9 @@ |
||
174 | 174 | $success = $model->destroy($ids); |
175 | 175 | |
176 | 176 | $status = array("error" => true, "message" => "Error deleting object"); |
177 | - if ($success) |
|
178 | - $status = array("error" => false, "message" => "Object successfully deleted"); |
|
177 | + if ($success) { |
|
178 | + $status = array("error" => false, "message" => "Object successfully deleted"); |
|
179 | + } |
|
179 | 180 | |
180 | 181 | return json_encode($status); |
181 | 182 |