@@ -30,8 +30,7 @@ discard block |
||
| 30 | 30 | if (File::exists(base_path('scaffolder-config/cache/view_edit_' . $hash . self::CACHE_EXT))) |
| 31 | 31 | { |
| 32 | 32 | return $this->store($modelName, $scaffolderConfig, '', new FileToCompile(true, $hash)); |
| 33 | - } |
|
| 34 | - else |
|
| 33 | + } else |
|
| 35 | 34 | { |
| 36 | 35 | $this->stub = $stub; |
| 37 | 36 | |
@@ -67,8 +66,7 @@ discard block |
||
| 67 | 66 | if ($fileToCompile->cached) |
| 68 | 67 | { |
| 69 | 68 | File::copy(base_path('scaffolder-config/cache/view_edit_' . $fileToCompile->hash . self::CACHE_EXT), $path); |
| 70 | - } |
|
| 71 | - else |
|
| 69 | + } else |
|
| 72 | 70 | { |
| 73 | 71 | File::put(base_path('scaffolder-config/cache/view_edit_' . $fileToCompile->hash . self::CACHE_EXT), $compiled); |
| 74 | 72 | File::copy(base_path('scaffolder-config/cache/view_edit_' . $fileToCompile->hash . self::CACHE_EXT), $path); |
@@ -95,8 +93,7 @@ discard block |
||
| 95 | 93 | { |
| 96 | 94 | $fields .= sprintf(self::getInputFor($field) . PHP_EOL, $field->name); |
| 97 | 95 | $firstIteration = false; |
| 98 | - } |
|
| 99 | - else |
|
| 96 | + } else |
|
| 100 | 97 | { |
| 101 | 98 | $fields .= sprintf("\t" . self::getInputFor($field) . PHP_EOL, $field->name); |
| 102 | 99 | } |
@@ -26,8 +26,7 @@ discard block |
||
| 26 | 26 | if (File::exists(base_path('scaffolder-config/cache/view_index_' . $hash . self::CACHE_EXT))) |
| 27 | 27 | { |
| 28 | 28 | return $this->store($modelName, $scaffolderConfig, '', new FileToCompile(true, $hash)); |
| 29 | - } |
|
| 30 | - else |
|
| 29 | + } else |
|
| 31 | 30 | { |
| 32 | 31 | $this->stub = $stub; |
| 33 | 32 | |
@@ -58,8 +57,7 @@ discard block |
||
| 58 | 57 | if ($fileToCompile->cached) |
| 59 | 58 | { |
| 60 | 59 | File::copy(base_path('scaffolder-config/cache/view_index_' . $fileToCompile->hash . self::CACHE_EXT), $path); |
| 61 | - } |
|
| 62 | - else |
|
| 60 | + } else |
|
| 63 | 61 | { |
| 64 | 62 | File::put(base_path('scaffolder-config/cache/view_index_' . $fileToCompile->hash . self::CACHE_EXT), $compiled); |
| 65 | 63 | File::copy(base_path('scaffolder-config/cache/view_index_' . $fileToCompile->hash . self::CACHE_EXT), $path); |
@@ -89,8 +87,7 @@ discard block |
||
| 89 | 87 | { |
| 90 | 88 | $fields .= sprintf("{ data: '%s', name: '%s' }," . PHP_EOL, $field->name, $field->name); |
| 91 | 89 | $firstIteration = false; |
| 92 | - } |
|
| 93 | - else |
|
| 90 | + } else |
|
| 94 | 91 | { |
| 95 | 92 | $fields .= sprintf("\t\t\t\t{ data: '%s', name: '%s' }," . PHP_EOL, $field->name, $field->name); |
| 96 | 93 | } |
@@ -124,8 +121,7 @@ discard block |
||
| 124 | 121 | $fields .= sprintf("<th>%s</th>" . PHP_EOL, ucfirst($field->name)); |
| 125 | 122 | $firstIteration = false; |
| 126 | 123 | |
| 127 | - } |
|
| 128 | - else |
|
| 124 | + } else |
|
| 129 | 125 | { |
| 130 | 126 | $fields .= sprintf("\t\t\t<th>%s</th>" . PHP_EOL, ucfirst($field->name)); |
| 131 | 127 | } |
@@ -30,8 +30,7 @@ discard block |
||
| 30 | 30 | if (File::exists(base_path('scaffolder-config/cache/view_create_' . $hash . self::CACHE_EXT))) |
| 31 | 31 | { |
| 32 | 32 | return $this->store($modelName, $scaffolderConfig, '', new FileToCompile(true, $hash)); |
| 33 | - } |
|
| 34 | - else |
|
| 33 | + } else |
|
| 35 | 34 | { |
| 36 | 35 | $this->stub = $stub; |
| 37 | 36 | |
@@ -66,8 +65,7 @@ discard block |
||
| 66 | 65 | if ($fileToCompile->cached) |
| 67 | 66 | { |
| 68 | 67 | File::copy(base_path('scaffolder-config/cache/view_create_' . $fileToCompile->hash . self::CACHE_EXT), $path); |
| 69 | - } |
|
| 70 | - else |
|
| 68 | + } else |
|
| 71 | 69 | { |
| 72 | 70 | File::put(base_path('scaffolder-config/cache/view_create_' . $fileToCompile->hash . self::CACHE_EXT), $compiled); |
| 73 | 71 | File::copy(base_path('scaffolder-config/cache/view_create_' . $fileToCompile->hash . self::CACHE_EXT), $path); |
@@ -94,8 +92,7 @@ discard block |
||
| 94 | 92 | { |
| 95 | 93 | $fields .= sprintf(self::getInputFor($field) . PHP_EOL, $field->name); |
| 96 | 94 | $firstIteration = false; |
| 97 | - } |
|
| 98 | - else |
|
| 95 | + } else |
|
| 99 | 96 | { |
| 100 | 97 | $fields .= sprintf("\t" . self::getInputFor($field) . PHP_EOL, $field->name); |
| 101 | 98 | } |
@@ -30,8 +30,7 @@ discard block |
||
| 30 | 30 | if (File::exists(base_path('scaffolder-config/cache/view_edit_' . $hash . self::CACHE_EXT))) |
| 31 | 31 | { |
| 32 | 32 | return $this->store($modelName, $scaffolderConfig, '', new FileToCompile(true, $hash)); |
| 33 | - } |
|
| 34 | - else |
|
| 33 | + } else |
|
| 35 | 34 | { |
| 36 | 35 | $this->stub = $stub; |
| 37 | 36 | |
@@ -67,8 +66,7 @@ discard block |
||
| 67 | 66 | if ($fileToCompile->cached) |
| 68 | 67 | { |
| 69 | 68 | File::copy(base_path('scaffolder-config/cache/view_edit_' . $fileToCompile->hash . self::CACHE_EXT), $path); |
| 70 | - } |
|
| 71 | - else |
|
| 69 | + } else |
|
| 72 | 70 | { |
| 73 | 71 | File::put(base_path('scaffolder-config/cache/view_edit_' . $fileToCompile->hash . self::CACHE_EXT), $compiled); |
| 74 | 72 | File::copy(base_path('scaffolder-config/cache/view_edit_' . $fileToCompile->hash . self::CACHE_EXT), $path); |
@@ -95,8 +93,7 @@ discard block |
||
| 95 | 93 | { |
| 96 | 94 | $fields .= sprintf(self::getInputFor($field) . PHP_EOL, $field->name); |
| 97 | 95 | $firstIteration = false; |
| 98 | - } |
|
| 99 | - else |
|
| 96 | + } else |
|
| 100 | 97 | { |
| 101 | 98 | $fields .= sprintf("\t" . self::getInputFor($field) . PHP_EOL, $field->name); |
| 102 | 99 | } |
@@ -122,10 +122,11 @@ discard block |
||
| 122 | 122 | $inputValidations = '' ; |
| 123 | 123 | |
| 124 | 124 | foreach ($validationsConverted as $attribute => $value) { |
| 125 | - if($value) |
|
| 126 | - $inputValidations .= ' '.$attribute.'="'. $value.'"' ; |
|
| 127 | - else |
|
| 128 | - $inputValidations .= ' '.$attribute ; |
|
| 125 | + if($value) { |
|
| 126 | + $inputValidations .= ' '.$attribute.'="'. $value.'"' ; |
|
| 127 | + } else { |
|
| 128 | + $inputValidations .= ' '.$attribute ; |
|
| 129 | + } |
|
| 129 | 130 | } |
| 130 | 131 | |
| 131 | 132 | $fieldStub = str_replace('{{field_validation}}', $inputValidations, $fieldStub); |
@@ -174,21 +175,19 @@ discard block |
||
| 174 | 175 | |
| 175 | 176 | if($field->index == 'primary'){ |
| 176 | 177 | $uiType = 'primary' ; |
| 177 | - } |
|
| 178 | - elseif(isset($field->foreignKey) && $field->foreignKey){ |
|
| 179 | - if(isset($field->foreignKey->eager) && $field->foreignKey->eager) |
|
| 180 | - $uiType = 'foreign_eager' ; |
|
| 181 | - else |
|
| 182 | - $uiType = $field->type->ui ; |
|
| 183 | - } |
|
| 184 | - else { |
|
| 178 | + } elseif(isset($field->foreignKey) && $field->foreignKey){ |
|
| 179 | + if(isset($field->foreignKey->eager) && $field->foreignKey->eager) { |
|
| 180 | + $uiType = 'foreign_eager' ; |
|
| 181 | + } else { |
|
| 182 | + $uiType = $field->type->ui ; |
|
| 183 | + } |
|
| 184 | + } else { |
|
| 185 | 185 | $uiType = $field->type->ui ; |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | if(array_key_exists($uiType, $this->inputStub)){ |
| 189 | 189 | return $this->inputStub[$uiType]; |
| 190 | - } |
|
| 191 | - else { |
|
| 190 | + } else { |
|
| 192 | 191 | $this->inputStub[$uiType] = File::get($this->stubsDirectory . 'List/'. CamelCase::convertToCamelCase($uiType). '.html'); |
| 193 | 192 | |
| 194 | 193 | return $this->inputStub[$uiType]; |
@@ -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 | |