@@ -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 |
@@ -120,8 +120,7 @@ discard block |
||
120 | 120 | // get pagination conditions |
121 | 121 | if(isset($params["pagination"])) { |
122 | 122 | $pagination = $params["pagination"]; |
123 | - } |
|
124 | - else { // set default |
|
123 | + } else { // set default |
|
125 | 124 | $pagination = ["actual" => 1, "itensPerPage" => 25 ] ; |
126 | 125 | } |
127 | 126 | |
@@ -177,8 +176,7 @@ discard block |
||
177 | 176 | // get pagination conditions |
178 | 177 | if(isset($params["pagination"])) { |
179 | 178 | $pagination = $params["pagination"]; |
180 | - } |
|
181 | - else { // set default |
|
179 | + } else { // set default |
|
182 | 180 | $pagination = ["actual" => 1, "itensPerPage" => 25 ] ; |
183 | 181 | } |
184 | 182 |