@@ -11,7 +11,7 @@ |
||
| 11 | 11 | | |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -$app = require __DIR__.'/../bootstrap/app.php'; |
|
| 14 | +$app = require __DIR__ . '/../bootstrap/app.php'; |
|
| 15 | 15 | |
| 16 | 16 | /* |
| 17 | 17 | |-------------------------------------------------------------------------- |
@@ -3,41 +3,41 @@ |
||
| 3 | 3 | |
| 4 | 4 | class ArgumentFormat { |
| 5 | 5 | |
| 6 | - /** |
|
| 7 | - * Argument name |
|
| 8 | - * |
|
| 9 | - * @var string |
|
| 10 | - */ |
|
| 11 | - public $name; |
|
| 6 | + /** |
|
| 7 | + * Argument name |
|
| 8 | + * |
|
| 9 | + * @var string |
|
| 10 | + */ |
|
| 11 | + public $name; |
|
| 12 | 12 | |
| 13 | - /** |
|
| 14 | - * One of the types: array, object, string, boolean, number |
|
| 15 | - * |
|
| 16 | - * @var string |
|
| 17 | - */ |
|
| 18 | - public $type; |
|
| 13 | + /** |
|
| 14 | + * One of the types: array, object, string, boolean, number |
|
| 15 | + * |
|
| 16 | + * @var string |
|
| 17 | + */ |
|
| 18 | + public $type; |
|
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * The default value |
|
| 22 | - * |
|
| 23 | - * @var string |
|
| 24 | - */ |
|
| 25 | - public $default; |
|
| 20 | + /** |
|
| 21 | + * The default value |
|
| 22 | + * |
|
| 23 | + * @var string |
|
| 24 | + */ |
|
| 25 | + public $default; |
|
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * The separator, by default ":" for object and "," for array. |
|
| 29 | - * |
|
| 30 | - * @var string |
|
| 31 | - */ |
|
| 32 | - public $separator; |
|
| 27 | + /** |
|
| 28 | + * The separator, by default ":" for object and "," for array. |
|
| 29 | + * |
|
| 30 | + * @var string |
|
| 31 | + */ |
|
| 32 | + public $separator; |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Specify the format of fields for object |
|
| 36 | - * [ field_name => Format, field_name => Format, ... ] |
|
| 37 | - * Specify the format of an element of array |
|
| 38 | - * |
|
| 39 | - * @var mixed |
|
| 40 | - */ |
|
| 41 | - public $format; |
|
| 34 | + /** |
|
| 35 | + * Specify the format of fields for object |
|
| 36 | + * [ field_name => Format, field_name => Format, ... ] |
|
| 37 | + * Specify the format of an element of array |
|
| 38 | + * |
|
| 39 | + * @var mixed |
|
| 40 | + */ |
|
| 41 | + public $format; |
|
| 42 | 42 | |
| 43 | 43 | } |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -$factory->define(App\User::class, function ($faker) { |
|
| 3 | +$factory->define(App\User::class, function($faker) { |
|
| 4 | 4 | return [ |
| 5 | 5 | 'name' => $faker->name, |
| 6 | 6 | 'email' => $faker->email, |
@@ -1,5 +1,5 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -$app->get("/", function () use ($app) { |
|
| 3 | +$app->get("/", function() use ($app) { |
|
| 4 | 4 | return $app->welcome(); |
| 5 | 5 | }); |
@@ -21,85 +21,85 @@ |
||
| 21 | 21 | // registerTestCommand |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - protected function registerModelCommand(){ |
|
| 25 | - $this->app->singleton('command.wn.model', function($app){ |
|
| 24 | + protected function registerModelCommand() { |
|
| 25 | + $this->app->singleton('command.wn.model', function($app) { |
|
| 26 | 26 | return $app['Wn\Generators\Commands\ModelCommand']; |
| 27 | 27 | }); |
| 28 | 28 | $this->commands('command.wn.model'); |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - protected function registerControllerRestActionsCommand(){ |
|
| 32 | - $this->app->singleton('command.wn.controller.rest-actions', function($app){ |
|
| 31 | + protected function registerControllerRestActionsCommand() { |
|
| 32 | + $this->app->singleton('command.wn.controller.rest-actions', function($app) { |
|
| 33 | 33 | return $app['Wn\Generators\Commands\ControllerRestActionsCommand']; |
| 34 | 34 | }); |
| 35 | 35 | $this->commands('command.wn.controller.rest-actions'); |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - protected function registerControllerCommand(){ |
|
| 39 | - $this->app->singleton('command.wn.controller', function($app){ |
|
| 38 | + protected function registerControllerCommand() { |
|
| 39 | + $this->app->singleton('command.wn.controller', function($app) { |
|
| 40 | 40 | return $app['Wn\Generators\Commands\ControllerCommand']; |
| 41 | 41 | }); |
| 42 | 42 | $this->commands('command.wn.controller'); |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - protected function registerMigrationCommand(){ |
|
| 46 | - $this->app->singleton('command.wn.migration', function($app){ |
|
| 45 | + protected function registerMigrationCommand() { |
|
| 46 | + $this->app->singleton('command.wn.migration', function($app) { |
|
| 47 | 47 | return $app['Wn\Generators\Commands\MigrationCommand']; |
| 48 | 48 | }); |
| 49 | 49 | $this->commands('command.wn.migration'); |
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - protected function registerRouteCommand(){ |
|
| 53 | - $this->app->singleton('command.wn.route', function($app){ |
|
| 52 | + protected function registerRouteCommand() { |
|
| 53 | + $this->app->singleton('command.wn.route', function($app) { |
|
| 54 | 54 | return $app['Wn\Generators\Commands\RouteCommand']; |
| 55 | 55 | }); |
| 56 | 56 | $this->commands('command.wn.route'); |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - protected function registerTestCommand(){ |
|
| 60 | - $this->app->singleton('command.wn.test', function($app){ |
|
| 59 | + protected function registerTestCommand() { |
|
| 60 | + $this->app->singleton('command.wn.test', function($app) { |
|
| 61 | 61 | return $app['Wn\Generators\Commands\TestCommand']; |
| 62 | 62 | }); |
| 63 | 63 | $this->commands('command.wn.test'); |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - protected function registerResourceCommand(){ |
|
| 67 | - $this->app->singleton('command.wn.resource', function($app){ |
|
| 66 | + protected function registerResourceCommand() { |
|
| 67 | + $this->app->singleton('command.wn.resource', function($app) { |
|
| 68 | 68 | return $app['Wn\Generators\Commands\ResourceCommand']; |
| 69 | 69 | }); |
| 70 | 70 | $this->commands('command.wn.resource'); |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - protected function registerResourcesCommand(){ |
|
| 74 | - $this->app->singleton('command.wn.resources', function($app){ |
|
| 73 | + protected function registerResourcesCommand() { |
|
| 74 | + $this->app->singleton('command.wn.resources', function($app) { |
|
| 75 | 75 | return $app['Wn\Generators\Commands\ResourcesCommand']; |
| 76 | 76 | }); |
| 77 | 77 | $this->commands('command.wn.resources'); |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - protected function registerPivotTableCommand(){ |
|
| 81 | - $this->app->singleton('command.wn.pivot-table', function($app){ |
|
| 80 | + protected function registerPivotTableCommand() { |
|
| 81 | + $this->app->singleton('command.wn.pivot-table', function($app) { |
|
| 82 | 82 | return $app['Wn\Generators\Commands\PivotTableCommand']; |
| 83 | 83 | }); |
| 84 | 84 | $this->commands('command.wn.pivot-table'); |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - protected function registerFactoryCommand(){ |
|
| 88 | - $this->app->singleton('command.wn.factory', function($app){ |
|
| 87 | + protected function registerFactoryCommand() { |
|
| 88 | + $this->app->singleton('command.wn.factory', function($app) { |
|
| 89 | 89 | return $app['Wn\Generators\Commands\FactoryCommand']; |
| 90 | 90 | }); |
| 91 | 91 | $this->commands('command.wn.factory'); |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - protected function registerSeederCommand(){ |
|
| 95 | - $this->app->singleton('command.wn.seeder', function($app){ |
|
| 94 | + protected function registerSeederCommand() { |
|
| 95 | + $this->app->singleton('command.wn.seeder', function($app) { |
|
| 96 | 96 | return $app['Wn\Generators\Commands\SeederCommand']; |
| 97 | 97 | }); |
| 98 | 98 | $this->commands('command.wn.seeder'); |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - protected function registerPivotSeederCommand(){ |
|
| 102 | - $this->app->singleton('command.wn.pivot.seeder', function($app){ |
|
| 101 | + protected function registerPivotSeederCommand() { |
|
| 102 | + $this->app->singleton('command.wn.pivot.seeder', function($app) { |
|
| 103 | 103 | return $app['Wn\Generators\Commands\PivotSeederCommand']; |
| 104 | 104 | }); |
| 105 | 105 | $this->commands('command.wn.pivot.seeder'); |
@@ -1,8 +1,6 @@ |
||
| 1 | 1 | <?php namespace Wn\Generators\Commands; |
| 2 | 2 | |
| 3 | 3 | |
| 4 | -use InvalidArgumentException; |
|
| 5 | - |
|
| 6 | 4 | class ControllerCommand extends BaseCommand { |
| 7 | 5 | |
| 8 | 6 | protected $signature = 'wn:controller |
@@ -5,33 +5,33 @@ |
||
| 5 | 5 | |
| 6 | 6 | class ControllerCommand extends BaseCommand { |
| 7 | 7 | |
| 8 | - protected $signature = 'wn:controller |
|
| 8 | + protected $signature = 'wn:controller |
|
| 9 | 9 | {model : Name of the model (with namespace if not App)} |
| 10 | 10 | {--no-routes= : without routes} |
| 11 | 11 | {--force= : override the existing files} |
| 12 | 12 | {--laravel : Use Laravel style route definitions} |
| 13 | 13 | '; |
| 14 | 14 | |
| 15 | - protected $description = 'Generates RESTful controller using the RESTActions trait'; |
|
| 15 | + protected $description = 'Generates RESTful controller using the RESTActions trait'; |
|
| 16 | 16 | |
| 17 | 17 | public function handle() |
| 18 | 18 | { |
| 19 | - $model = $this->argument('model'); |
|
| 20 | - $name = ''; |
|
| 21 | - if(strrpos($model, "\\") === false){ |
|
| 22 | - $name = $model; |
|
| 23 | - $model = "App\\" . $model; |
|
| 24 | - } else { |
|
| 25 | - $name = explode("\\", $model); |
|
| 26 | - $name = $name[count($name) - 1]; |
|
| 27 | - } |
|
| 19 | + $model = $this->argument('model'); |
|
| 20 | + $name = ''; |
|
| 21 | + if(strrpos($model, "\\") === false){ |
|
| 22 | + $name = $model; |
|
| 23 | + $model = "App\\" . $model; |
|
| 24 | + } else { |
|
| 25 | + $name = explode("\\", $model); |
|
| 26 | + $name = $name[count($name) - 1]; |
|
| 27 | + } |
|
| 28 | 28 | $controller = ucwords(str_plural($name)) . 'Controller'; |
| 29 | 29 | $content = $this->getTemplate('controller') |
| 30 | - ->with([ |
|
| 31 | - 'name' => $controller, |
|
| 32 | - 'model' => $model |
|
| 33 | - ]) |
|
| 34 | - ->get(); |
|
| 30 | + ->with([ |
|
| 31 | + 'name' => $controller, |
|
| 32 | + 'model' => $model |
|
| 33 | + ]) |
|
| 34 | + ->get(); |
|
| 35 | 35 | |
| 36 | 36 | $this->save($content, "./app/Http/Controllers/{$controller}.php", "{$controller}"); |
| 37 | 37 | if(! $this->option('no-routes')){ |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | { |
| 19 | 19 | $model = $this->argument('model'); |
| 20 | 20 | $name = ''; |
| 21 | - if(strrpos($model, "\\") === false){ |
|
| 21 | + if (strrpos($model, "\\") === false) { |
|
| 22 | 22 | $name = $model; |
| 23 | 23 | $model = "App\\" . $model; |
| 24 | 24 | } else { |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | ->get(); |
| 35 | 35 | |
| 36 | 36 | $this->save($content, "./app/Http/Controllers/{$controller}.php", "{$controller}"); |
| 37 | - if(! $this->option('no-routes')){ |
|
| 37 | + if (!$this->option('no-routes')) { |
|
| 38 | 38 | $options = [ |
| 39 | 39 | 'resource' => snake_case($name, '-'), |
| 40 | 40 | '--controller' => $controller, |
@@ -1,8 +1,6 @@ |
||
| 1 | 1 | <?php namespace Wn\Generators\Commands; |
| 2 | 2 | |
| 3 | 3 | |
| 4 | -use InvalidArgumentException; |
|
| 5 | - |
|
| 6 | 4 | class RouteCommand extends BaseCommand { |
| 7 | 5 | |
| 8 | 6 | protected $signature = 'wn:route |
@@ -67,7 +67,7 @@ |
||
| 67 | 67 | protected function getController() |
| 68 | 68 | { |
| 69 | 69 | $controller = $this->option('controller'); |
| 70 | - if(! $controller){ |
|
| 70 | + if (!$controller) { |
|
| 71 | 71 | $controller = ucwords(str_plural(camel_case($this->argument('resource')))) . 'Controller'; |
| 72 | 72 | } |
| 73 | 73 | return $controller; |
@@ -5,13 +5,13 @@ |
||
| 5 | 5 | |
| 6 | 6 | class RouteCommand extends BaseCommand { |
| 7 | 7 | |
| 8 | - protected $signature = 'wn:route |
|
| 8 | + protected $signature = 'wn:route |
|
| 9 | 9 | {resource : Name of the resource.} |
| 10 | 10 | {--controller= : Name of the RESTful controller.} |
| 11 | 11 | {--laravel= : Use Laravel style route definitions} |
| 12 | 12 | '; |
| 13 | 13 | |
| 14 | - protected $description = 'Generates RESTful routes.'; |
|
| 14 | + protected $description = 'Generates RESTful routes.'; |
|
| 15 | 15 | |
| 16 | 16 | public function handle() |
| 17 | 17 | { |
@@ -62,7 +62,7 @@ |
||
| 62 | 62 | |
| 63 | 63 | |
| 64 | 64 | $I->wantTo('run wn:routes in Lumen 5.3+'); |
| 65 | -if(!file_exists('./routes')) { |
|
| 65 | +if (!file_exists('./routes')) { |
|
| 66 | 66 | mkdir('./routes'); |
| 67 | 67 | } |
| 68 | 68 | $I->writeToFile('./routes/web.php', '<?php |
@@ -14,10 +14,10 @@ discard block |
||
| 14 | 14 | $I->seeInThisFile('protected $fillable = ["name", "descr", "due", "project_id", "user_id"];'); |
| 15 | 15 | $I->seeInThisFile('protected $dates = ["due"];'); |
| 16 | 16 | $I->seeInThisFile( |
| 17 | -"public static \$rules = [\n". |
|
| 17 | +"public static \$rules = [\n" . |
|
| 18 | 18 | " \"name\" => \"requied\"," . PHP_EOL . |
| 19 | 19 | " \"project_id\" => \"required|numeric\"," . PHP_EOL . |
| 20 | -" \"user_id\" => \"required|numeric\",\n". |
|
| 20 | +" \"user_id\" => \"required|numeric\",\n" . |
|
| 21 | 21 | " ];"); |
| 22 | 22 | $I->seeInThisFile( |
| 23 | 23 | ' public function tags() |
@@ -47,15 +47,15 @@ discard block |
||
| 47 | 47 | $I->openFile('./database/migrations/create_task_categories.php'); |
| 48 | 48 | |
| 49 | 49 | $I->seeInThisFile('class CreateTaskCategoriesTable extends Migration'); |
| 50 | -$I->seeInThisFile("Schema::create('task_categories', function(Blueprint \$table) {\n". |
|
| 51 | -" \$table->increments('id');\n". |
|
| 50 | +$I->seeInThisFile("Schema::create('task_categories', function(Blueprint \$table) {\n" . |
|
| 51 | +" \$table->increments('id');\n" . |
|
| 52 | 52 | " \$table->string('name')->unique();" . PHP_EOL . |
| 53 | 53 | " \$table->text('descr')->nullable();" . PHP_EOL . |
| 54 | 54 | " \$table->timestamp('due');" . PHP_EOL . |
| 55 | -" \$table->integer('project_id')->unsigned();" . PHP_EOL. |
|
| 55 | +" \$table->integer('project_id')->unsigned();" . PHP_EOL . |
|
| 56 | 56 | " \$table->integer('user_id')->unsigned();" . PHP_EOL . |
| 57 | 57 | " \$table->foreign('project_id')->references('id')->on('projects');" . PHP_EOL . |
| 58 | -" \$table->foreign('user_id')->references('id')->on('users');". PHP_EOL . |
|
| 58 | +" \$table->foreign('user_id')->references('id')->on('users');" . PHP_EOL . |
|
| 59 | 59 | " \$table->timestamps();"); |
| 60 | 60 | |
| 61 | 61 | $I->deleteFile('./database/migrations/create_task_categories.php'); |