@@ -23,7 +23,7 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | public function register() |
| 25 | 25 | { |
| 26 | - $this->app->singleton('command.drawmyattention.makeresource', function ($app) { |
|
| 26 | + $this->app->singleton('command.drawmyattention.makeresource', function($app) { |
|
| 27 | 27 | return $app['DrawMyAttention\ResourceGenerator\Commands\ResourceMakeCommand']; |
| 28 | 28 | }); |
| 29 | 29 | $this->commands('command.drawmyattention.makeresource'); |
@@ -97,11 +97,11 @@ discard block |
||
| 97 | 97 | { |
| 98 | 98 | $model = $this->modelName($name); |
| 99 | 99 | |
| 100 | - $stub = $this->files->get(__DIR__ . '/../Stubs/factory.stub'); |
|
| 100 | + $stub = $this->files->get(__DIR__.'/../Stubs/factory.stub'); |
|
| 101 | 101 | |
| 102 | 102 | $stub = str_replace('CLASSNAME', $model, $stub); |
| 103 | 103 | |
| 104 | - $class = 'App\\' . $model; |
|
| 104 | + $class = 'App\\'.$model; |
|
| 105 | 105 | $model = new $class; |
| 106 | 106 | |
| 107 | 107 | $stub = str_replace( |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | $method = $formatter['method']; |
| 130 | 130 | $parameters = $formatter['parameters']; |
| 131 | 131 | |
| 132 | - $faker .= "'".$attribute['name']."' => \$faker->".$method."(".$parameters.")," . PHP_EOL . ' '; |
|
| 132 | + $faker .= "'".$attribute['name']."' => \$faker->".$method."(".$parameters."),".PHP_EOL.' '; |
|
| 133 | 133 | |
| 134 | 134 | } |
| 135 | 135 | |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | { |
| 147 | 147 | $modelName = $this->modelName($name); |
| 148 | 148 | |
| 149 | - $filename = $modelName . '.php'; |
|
| 149 | + $filename = $modelName.'.php'; |
|
| 150 | 150 | |
| 151 | 151 | if ($this->files->exists(app_path($filename))) { |
| 152 | 152 | $this->error('Model already exists!'); |
@@ -155,9 +155,9 @@ discard block |
||
| 155 | 155 | |
| 156 | 156 | $model = $this->buildModel($name); |
| 157 | 157 | |
| 158 | - $this->files->put(app_path('/' . $filename), $model); |
|
| 158 | + $this->files->put(app_path('/'.$filename), $model); |
|
| 159 | 159 | |
| 160 | - $this->info($modelName . ' Model created'); |
|
| 160 | + $this->info($modelName.' Model created'); |
|
| 161 | 161 | |
| 162 | 162 | return true; |
| 163 | 163 | } |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | $migration = $this->buildMigration($name); |
| 175 | 175 | |
| 176 | 176 | $this->files->put( |
| 177 | - database_path('/migrations/' . $filename), |
|
| 177 | + database_path('/migrations/'.$filename), |
|
| 178 | 178 | $migration |
| 179 | 179 | ); |
| 180 | 180 | |
@@ -182,29 +182,29 @@ discard block |
||
| 182 | 182 | $this->composer->dumpAutoloads(); |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - $this->info('Created migration ' . $filename); |
|
| 185 | + $this->info('Created migration '.$filename); |
|
| 186 | 186 | |
| 187 | 187 | return true; |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | private function createController($modelName) |
| 191 | 191 | { |
| 192 | - $filename = ucfirst($modelName) . 'Controller.php'; |
|
| 192 | + $filename = ucfirst($modelName).'Controller.php'; |
|
| 193 | 193 | |
| 194 | - if ($this->files->exists(app_path('Http/' . $filename))) { |
|
| 194 | + if ($this->files->exists(app_path('Http/'.$filename))) { |
|
| 195 | 195 | $this->error('Controller already exists!'); |
| 196 | 196 | return false; |
| 197 | 197 | } |
| 198 | 198 | |
| 199 | - $stub = $this->files->get(__DIR__ . '/../Stubs/controller.stub'); |
|
| 199 | + $stub = $this->files->get(__DIR__.'/../Stubs/controller.stub'); |
|
| 200 | 200 | |
| 201 | 201 | $stub = str_replace('MyModelClass', ucfirst($modelName), $stub); |
| 202 | 202 | $stub = str_replace('myModelInstance', Str::camel($modelName), $stub); |
| 203 | 203 | $stub = str_replace('template', strtolower($modelName), $stub); |
| 204 | 204 | |
| 205 | - $this->files->put(app_path('Http/Controllers/' . $filename), $stub); |
|
| 205 | + $this->files->put(app_path('Http/Controllers/'.$filename), $stub); |
|
| 206 | 206 | |
| 207 | - $this->info('Created controller ' . $filename); |
|
| 207 | + $this->info('Created controller '.$filename); |
|
| 208 | 208 | |
| 209 | 209 | return true; |
| 210 | 210 | } |
@@ -215,27 +215,27 @@ discard block |
||
| 215 | 215 | |
| 216 | 216 | $modelName = strtolower($modelName); |
| 217 | 217 | |
| 218 | - $newRoutes = $this->files->get(__DIR__ . '/../Stubs/routes.stub'); |
|
| 218 | + $newRoutes = $this->files->get(__DIR__.'/../Stubs/routes.stub'); |
|
| 219 | 219 | |
| 220 | 220 | $newRoutes = str_replace('|MODEL_TITLE|', $modelTitle, $newRoutes); |
| 221 | 221 | |
| 222 | 222 | $newRoutes = str_replace('|MODEL_NAME|', $modelName, $newRoutes); |
| 223 | 223 | |
| 224 | - $newRoutes = str_replace('|CONTROLLER_NAME|', $modelTitle . 'Controller', $newRoutes); |
|
| 224 | + $newRoutes = str_replace('|CONTROLLER_NAME|', $modelTitle.'Controller', $newRoutes); |
|
| 225 | 225 | |
| 226 | 226 | $this->files->append( |
| 227 | 227 | app_path('Http/routes.php'), |
| 228 | 228 | $newRoutes |
| 229 | 229 | ); |
| 230 | 230 | |
| 231 | - $this->info('Added routes for ' . $modelTitle); |
|
| 231 | + $this->info('Added routes for '.$modelTitle); |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | protected function buildMigration($name) |
| 235 | 235 | { |
| 236 | - $stub = $this->files->get(__DIR__ . '/../Stubs/migration.stub'); |
|
| 236 | + $stub = $this->files->get(__DIR__.'/../Stubs/migration.stub'); |
|
| 237 | 237 | |
| 238 | - $className = 'Create' . Str::plural($name). 'Table'; |
|
| 238 | + $className = 'Create'.Str::plural($name).'Table'; |
|
| 239 | 239 | |
| 240 | 240 | $stub = str_replace('MIGRATION_CLASS_PLACEHOLDER', $className, $stub); |
| 241 | 241 | |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | |
| 244 | 244 | $stub = str_replace('TABLE_NAME_PLACEHOLDER', $table, $stub); |
| 245 | 245 | |
| 246 | - $class = 'App\\' . $name; |
|
| 246 | + $class = 'App\\'.$name; |
|
| 247 | 247 | $model = new $class; |
| 248 | 248 | |
| 249 | 249 | $stub = str_replace('MIGRATION_COLUMNS_PLACEHOLDER', $this->buildTableColumns($model->migrationAttributes()), $stub); |
@@ -253,7 +253,7 @@ discard block |
||
| 253 | 253 | |
| 254 | 254 | protected function buildModel($name) |
| 255 | 255 | { |
| 256 | - $stub = $this->files->get(__DIR__ . '/../Stubs/model.stub'); |
|
| 256 | + $stub = $this->files->get(__DIR__.'/../Stubs/model.stub'); |
|
| 257 | 257 | |
| 258 | 258 | $stub = $this->replaceClassName($name, $stub); |
| 259 | 259 | |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | { |
| 276 | 276 | $table = $this->convertModelToTableName($model); |
| 277 | 277 | |
| 278 | - return date('Y_m_d_his') . '_create_' . $table . '_table.php'; |
|
| 278 | + return date('Y_m_d_his').'_create_'.$table.'_table.php'; |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | private function replaceClassName($name, $stub) |
@@ -326,7 +326,7 @@ discard block |
||
| 326 | 326 | |
| 327 | 327 | foreach ($array as $name => $properties) { |
| 328 | 328 | $string .= '['; |
| 329 | - $string .= "'name' => '" . $name . "',"; |
|
| 329 | + $string .= "'name' => '".$name."',"; |
|
| 330 | 330 | |
| 331 | 331 | $string .= "'properties' => ["; |
| 332 | 332 | foreach ($properties as $property) { |
@@ -348,15 +348,15 @@ discard block |
||
| 348 | 348 | |
| 349 | 349 | public function addModelAttributes($name, $attributes, $stub) |
| 350 | 350 | { |
| 351 | - $attributes = '[' . collect($this->parseAttributesFromInputString($attributes)) |
|
| 351 | + $attributes = '['.collect($this->parseAttributesFromInputString($attributes)) |
|
| 352 | 352 | ->filter(function($attribute) use ($name) { |
| 353 | 353 | return in_array($name, $attribute); |
| 354 | - })->map(function ($attributes, $name) { |
|
| 355 | - return "'" . $name . "'"; |
|
| 356 | - })->values()->implode(', ') . ']'; |
|
| 354 | + })->map(function($attributes, $name) { |
|
| 355 | + return "'".$name."'"; |
|
| 356 | + })->values()->implode(', ').']'; |
|
| 357 | 357 | |
| 358 | 358 | |
| 359 | - return str_replace(strtoupper($name) . '_PLACEHOLDER', $attributes, $stub); |
|
| 359 | + return str_replace(strtoupper($name).'_PLACEHOLDER', $attributes, $stub); |
|
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | public function buildTableColumns($attributes) |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | |
| 373 | 373 | $properties = $this->extractAttributePropertiesToApply($attribute['properties']); |
| 374 | 374 | |
| 375 | - return $column . $this->buildSchemaColumn($fieldType, $attribute['name'], $length, $properties); |
|
| 375 | + return $column.$this->buildSchemaColumn($fieldType, $attribute['name'], $length, $properties); |
|
| 376 | 376 | |
| 377 | 377 | })); |
| 378 | 378 | |
@@ -393,7 +393,7 @@ discard block |
||
| 393 | 393 | // is no matching data type found, the column |
| 394 | 394 | // should be cast to a string. |
| 395 | 395 | |
| 396 | - if (! $type) { |
|
| 396 | + if (!$type) { |
|
| 397 | 397 | return 'string'; |
| 398 | 398 | } |
| 399 | 399 | |
@@ -450,12 +450,12 @@ discard block |
||
| 450 | 450 | */ |
| 451 | 451 | private function buildSchemaColumn($fieldType, $name, $length = 0, $traits = []) |
| 452 | 452 | { |
| 453 | - return sprintf("\$table->%s('%s'%s)%s;" . PHP_EOL . ' ', |
|
| 453 | + return sprintf("\$table->%s('%s'%s)%s;".PHP_EOL.' ', |
|
| 454 | 454 | $fieldType, |
| 455 | 455 | $name, |
| 456 | 456 | $length > 0 ? ", $length" : '', |
| 457 | - implode('', array_map(function ($trait) { |
|
| 458 | - return '->' . $trait . '()'; |
|
| 457 | + implode('', array_map(function($trait) { |
|
| 458 | + return '->'.$trait.'()'; |
|
| 459 | 459 | }, $traits)) |
| 460 | 460 | ); |
| 461 | 461 | } |