@@ -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 | |
@@ -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, |
@@ -138,7 +138,7 @@ |
||
| 138 | 138 | |
| 139 | 139 | return $rules; |
| 140 | 140 | }*/ |
| 141 | - protected function getRules($id = null){ |
|
| 141 | + protected function getRules($id = null) { |
|
| 142 | 142 | // default object rules |
| 143 | 143 | $model = new {{class_name}}(); |
| 144 | 144 | $rules = $model::$rules; |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | ]; |
| 28 | 28 | |
| 29 | 29 | // validation rules |
| 30 | - public static $rules = [ |
|
| 30 | + public static $rules = [ |
|
| 31 | 31 | {{validations}} |
| 32 | 32 | ]; |
| 33 | 33 | |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | //get first row by field and value |
| 77 | 77 | public function findByField(Request $request) |
| 78 | 78 | { |
| 79 | - ${{class_name_lw}} = {{class_name}}::where($request->input('field') , '=', $request->input('value'))->first(); |
|
| 79 | + ${{class_name_lw}} = {{class_name}}::where($request->input('field'), '=', $request->input('value'))->first(); |
|
| 80 | 80 | return ${{class_name_lw}} ; |
| 81 | 81 | } |
| 82 | 82 | |
@@ -118,16 +118,16 @@ discard block |
||
| 118 | 118 | $params = $request->all(); |
| 119 | 119 | |
| 120 | 120 | // get pagination conditions |
| 121 | - if(isset($params["pagination"])) { |
|
| 121 | + if (isset($params["pagination"])) { |
|
| 122 | 122 | $pagination = $params["pagination"]; |
| 123 | 123 | } |
| 124 | 124 | else { // set default |
| 125 | - $pagination = ["actual" => 1, "itensPerPage" => 25 ] ; |
|
| 125 | + $pagination = ["actual" => 1, "itensPerPage" => 25]; |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | // resolve current page |
| 129 | 129 | $currentPage = $pagination["actual"]; |
| 130 | - Paginator::currentPageResolver(function () use ($currentPage) { |
|
| 130 | + Paginator::currentPageResolver(function() use ($currentPage) { |
|
| 131 | 131 | return $currentPage; |
| 132 | 132 | }); |
| 133 | 133 | |
@@ -149,8 +149,8 @@ discard block |
||
| 149 | 149 | // join relationship tables objects |
| 150 | 150 | {{relationship_tables_joins}} |
| 151 | 151 | // get sort clauses |
| 152 | - if(isset($params["sort"]) && count($params["sort"])) { |
|
| 153 | - foreach($params["sort"] as $sort){ |
|
| 152 | + if (isset($params["sort"]) && count($params["sort"])) { |
|
| 153 | + foreach ($params["sort"] as $sort) { |
|
| 154 | 154 | {{relationship_tables_joins_sort}} |
| 155 | 155 | $query->orderBy($sort["field"], $sort["order"]); |
| 156 | 156 | } |
@@ -172,42 +172,42 @@ discard block |
||
| 172 | 172 | $orderBy = '{{primary_key}}'; |
| 173 | 173 | $fields = null; |
| 174 | 174 | $selectArray = []; |
| 175 | - array_push($selectArray,'{{primary_key}}'); |
|
| 175 | + array_push($selectArray, '{{primary_key}}'); |
|
| 176 | 176 | |
| 177 | 177 | // get pagination conditions |
| 178 | - if(isset($params["pagination"])) { |
|
| 178 | + if (isset($params["pagination"])) { |
|
| 179 | 179 | $pagination = $params["pagination"]; |
| 180 | 180 | } |
| 181 | 181 | else { // set default |
| 182 | - $pagination = ["actual" => 1, "itensPerPage" => 25 ] ; |
|
| 182 | + $pagination = ["actual" => 1, "itensPerPage" => 25]; |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | // resolve current page |
| 186 | 186 | $currentPage = $pagination["actual"]; |
| 187 | - Paginator::currentPageResolver(function () use ($currentPage) { |
|
| 187 | + Paginator::currentPageResolver(function() use ($currentPage) { |
|
| 188 | 188 | return $currentPage; |
| 189 | 189 | }); |
| 190 | 190 | |
| 191 | - if(isset($params["fields"])) { |
|
| 191 | + if (isset($params["fields"])) { |
|
| 192 | 192 | $fields = $params["fields"]; |
| 193 | 193 | |
| 194 | 194 | foreach ($fields as $field) { |
| 195 | - if(Schema::hasColumn('{{table_name}}', $field)){ |
|
| 195 | + if (Schema::hasColumn('{{table_name}}', $field)) { |
|
| 196 | 196 | array_push($selectArray, $field); |
| 197 | 197 | } |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | - if(isset($params["orderBy"])) { |
|
| 203 | - if(Schema::hasColumn('{{table_name}}',$params["orderBy"])){ |
|
| 202 | + if (isset($params["orderBy"])) { |
|
| 203 | + if (Schema::hasColumn('{{table_name}}', $params["orderBy"])) { |
|
| 204 | 204 | $orderBy = $params["orderBy"]; |
| 205 | 205 | } |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | ${{class_name_lw}} = {{class_name}}::WhereNotNull('{{table_name}}.{{primary_key}}'); |
| 209 | 209 | |
| 210 | - ${{class_name_lw}}->select($selectArray)->orderBy($orderBy,'asc'); |
|
| 210 | + ${{class_name_lw}}->select($selectArray)->orderBy($orderBy, 'asc'); |
|
| 211 | 211 | |
| 212 | 212 | return ${{class_name_lw}}->paginate($pagination["itensPerPage"]); |
| 213 | 213 | } |
@@ -3,14 +3,14 @@ |
||
| 3 | 3 | use Illuminate\Database\Schema\Blueprint; |
| 4 | 4 | use Illuminate\Database\Migrations\Migration; |
| 5 | 5 | |
| 6 | -class Create{{class_name}}Table extends Migration |
|
| 6 | +class Create {{class_name}}Table extends Migration |
|
| 7 | 7 | { |
| 8 | 8 | /** |
| 9 | 9 | * Run the migrations. |
| 10 | 10 | */ |
| 11 | 11 | public function up() |
| 12 | 12 | { |
| 13 | - Schema::create('{{table_name}}', function (Blueprint $table) { |
|
| 13 | + Schema::create('{{table_name}}', function(Blueprint $table) { |
|
| 14 | 14 | {{fields}} |
| 15 | 15 | }); |
| 16 | 16 | } |