@@ -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,7 +5,7 @@ discard block |
||
| 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 | {--controller-namespace= : Namespace of the RESTful controller if not default.} |
@@ -13,22 +13,22 @@ discard block |
||
| 13 | 13 | {--laravel= : Use Laravel style route definitions} |
| 14 | 14 | '; |
| 15 | 15 | |
| 16 | - protected $description = 'Generates RESTful routes.'; |
|
| 16 | + protected $description = 'Generates RESTful routes.'; |
|
| 17 | 17 | |
| 18 | 18 | public function handle() |
| 19 | 19 | { |
| 20 | 20 | $resource = $this->argument('resource'); |
| 21 | 21 | $laravelRoutes = $this->option('laravel'); |
| 22 | - $templateFile = 'routes'; |
|
| 22 | + $templateFile = 'routes'; |
|
| 23 | 23 | $routesPath = $this->option('path') ?: 'routes/web.php'; |
| 24 | 24 | if ($laravelRoutes) { |
| 25 | 25 | $templateFile = 'routes-laravel'; |
| 26 | 26 | $routesPath = $this->option('path') ?: 'routes/api.php'; |
| 27 | - if (!$this->fs->isFile($routesPath)) { |
|
| 28 | - if (!$this->fs->isDirectory(\dirname($routesPath))) { |
|
| 29 | - $this->fs->makeDirectory(\dirname($routesPath)); |
|
| 30 | - } |
|
| 31 | - $this->fs->put($routesPath, " |
|
| 27 | + if (!$this->fs->isFile($routesPath)) { |
|
| 28 | + if (!$this->fs->isDirectory(\dirname($routesPath))) { |
|
| 29 | + $this->fs->makeDirectory(\dirname($routesPath)); |
|
| 30 | + } |
|
| 31 | + $this->fs->put($routesPath, " |
|
| 32 | 32 | <?php |
| 33 | 33 | |
| 34 | 34 | use Illuminate\Http\Request; |
@@ -49,11 +49,11 @@ discard block |
||
| 49 | 49 | }); |
| 50 | 50 | |
| 51 | 51 | "); |
| 52 | - } |
|
| 52 | + } |
|
| 53 | + } |
|
| 54 | + if ($this->option('controller-namespace')) { |
|
| 55 | + $templateFile .= '-namespace'; |
|
| 53 | 56 | } |
| 54 | - if ($this->option('controller-namespace')) { |
|
| 55 | - $templateFile .= '-namespace'; |
|
| 56 | - } |
|
| 57 | 57 | |
| 58 | 58 | if (!$this->fs->isFile($routesPath)) { |
| 59 | 59 | $routesPath = 'app/Http/routes.php'; |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | ->with([ |
| 65 | 65 | 'resource' => $resource, |
| 66 | 66 | 'controller' => $this->getController(), |
| 67 | - 'namespace' => $this->option('controller-namespace'), |
|
| 67 | + 'namespace' => $this->option('controller-namespace'), |
|
| 68 | 68 | ]) |
| 69 | 69 | ->get(); |
| 70 | 70 | $this->save($content, $routesPath, "{$resource} routes", true); |
@@ -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 |
@@ -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 | const DEFAULT_PATH = "app/Http/Controllers"; |
@@ -5,9 +5,9 @@ discard block |
||
| 5 | 5 | |
| 6 | 6 | class ControllerCommand extends BaseCommand { |
| 7 | 7 | |
| 8 | - const DEFAULT_PATH = "app/Http/Controllers"; |
|
| 8 | + const DEFAULT_PATH = "app/Http/Controllers"; |
|
| 9 | 9 | |
| 10 | - protected $signature = 'wn:controller |
|
| 10 | + protected $signature = 'wn:controller |
|
| 11 | 11 | {model : Name of the model (with namespace if not App)} |
| 12 | 12 | {--path='.ControllerCommand::DEFAULT_PATH.' : where to store the controllers file.} |
| 13 | 13 | {--no-routes= : without routes} |
@@ -16,28 +16,28 @@ discard block |
||
| 16 | 16 | {--laravel : Use Laravel style route definitions} |
| 17 | 17 | '; |
| 18 | 18 | |
| 19 | - protected $description = 'Generates RESTful controller using the RESTActions trait'; |
|
| 19 | + protected $description = 'Generates RESTful controller using the RESTActions trait'; |
|
| 20 | 20 | |
| 21 | 21 | public function handle() |
| 22 | 22 | { |
| 23 | - $model = $this->argument('model'); |
|
| 24 | - $name = ''; |
|
| 25 | - if(strrpos($model, "\\") === false){ |
|
| 26 | - $name = $model; |
|
| 27 | - $model = "App\\" . $model; |
|
| 28 | - } else { |
|
| 29 | - $name = explode("\\", $model); |
|
| 30 | - $name = $name[count($name) - 1]; |
|
| 31 | - } |
|
| 23 | + $model = $this->argument('model'); |
|
| 24 | + $name = ''; |
|
| 25 | + if(strrpos($model, "\\") === false){ |
|
| 26 | + $name = $model; |
|
| 27 | + $model = "App\\" . $model; |
|
| 28 | + } else { |
|
| 29 | + $name = explode("\\", $model); |
|
| 30 | + $name = $name[count($name) - 1]; |
|
| 31 | + } |
|
| 32 | 32 | $controller = ucwords(str_plural($name)) . 'Controller'; |
| 33 | 33 | $content = $this->getTemplate('controller') |
| 34 | - ->with([ |
|
| 35 | - 'name' => $controller, |
|
| 36 | - 'model' => $model, |
|
| 37 | - 'namespace' => $this->getNamespace(), |
|
| 38 | - 'use' => ($this->getNamespace() != $this->getDefaultNamespace()?'use '.$this->getDefaultNamespace().'\Controller;'.PHP_EOL.'use '.$this->getDefaultNamespace().'\RESTActions;'.PHP_EOL:'') |
|
| 39 | - ]) |
|
| 40 | - ->get(); |
|
| 34 | + ->with([ |
|
| 35 | + 'name' => $controller, |
|
| 36 | + 'model' => $model, |
|
| 37 | + 'namespace' => $this->getNamespace(), |
|
| 38 | + 'use' => ($this->getNamespace() != $this->getDefaultNamespace()?'use '.$this->getDefaultNamespace().'\Controller;'.PHP_EOL.'use '.$this->getDefaultNamespace().'\RESTActions;'.PHP_EOL:'') |
|
| 39 | + ]) |
|
| 40 | + ->get(); |
|
| 41 | 41 | |
| 42 | 42 | $this->save($content, "./{$this->option('path')}/{$controller}.php", "{$controller}"); |
| 43 | 43 | |
@@ -61,8 +61,8 @@ discard block |
||
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - protected function getDefaultNamespace() { |
|
| 65 | - return $this->getNamespace(ControllerCommand::DEFAULT_PATH); |
|
| 66 | - } |
|
| 64 | + protected function getDefaultNamespace() { |
|
| 65 | + return $this->getNamespace(ControllerCommand::DEFAULT_PATH); |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | 68 | } |
@@ -9,7 +9,7 @@ discard block |
||
| 9 | 9 | |
| 10 | 10 | protected $signature = 'wn:controller |
| 11 | 11 | {model : Name of the model (with namespace if not App)} |
| 12 | - {--path='.ControllerCommand::DEFAULT_PATH.' : where to store the controllers file.} |
|
| 12 | + {--path='.ControllerCommand::DEFAULT_PATH . ' : where to store the controllers file.} |
|
| 13 | 13 | {--no-routes= : without routes} |
| 14 | 14 | {--routes= : where to store the routes.} |
| 15 | 15 | {--force= : override the existing files} |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | { |
| 23 | 23 | $model = $this->argument('model'); |
| 24 | 24 | $name = ''; |
| 25 | - if(strrpos($model, "\\") === false){ |
|
| 25 | + if (strrpos($model, "\\") === false) { |
|
| 26 | 26 | $name = $model; |
| 27 | 27 | $model = "App\\" . $model; |
| 28 | 28 | } else { |
@@ -35,13 +35,13 @@ discard block |
||
| 35 | 35 | 'name' => $controller, |
| 36 | 36 | 'model' => $model, |
| 37 | 37 | 'namespace' => $this->getNamespace(), |
| 38 | - 'use' => ($this->getNamespace() != $this->getDefaultNamespace()?'use '.$this->getDefaultNamespace().'\Controller;'.PHP_EOL.'use '.$this->getDefaultNamespace().'\RESTActions;'.PHP_EOL:'') |
|
| 38 | + 'use' => ($this->getNamespace() != $this->getDefaultNamespace() ? 'use ' . $this->getDefaultNamespace() . '\Controller;' . PHP_EOL . 'use ' . $this->getDefaultNamespace() . '\RESTActions;' . PHP_EOL : '') |
|
| 39 | 39 | ]) |
| 40 | 40 | ->get(); |
| 41 | 41 | |
| 42 | 42 | $this->save($content, "./{$this->option('path')}/{$controller}.php", "{$controller}"); |
| 43 | 43 | |
| 44 | - if(! $this->option('no-routes')){ |
|
| 44 | + if (!$this->option('no-routes')) { |
|
| 45 | 45 | $options = [ |
| 46 | 46 | 'resource' => snake_case($name, '-'), |
| 47 | 47 | '--controller' => $controller, |
@@ -11,6 +11,6 @@ |
||
| 11 | 11 | | |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | -$router->get("/", function () use ($router) { |
|
| 14 | +$router->get("/", function() use ($router) { |
|
| 15 | 15 | return 'Hello World'; |
| 16 | 16 | }); |
@@ -1,9 +1,9 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -require_once __DIR__.'/../vendor/autoload.php'; |
|
| 3 | +require_once __DIR__ . '/../vendor/autoload.php'; |
|
| 4 | 4 | |
| 5 | 5 | try { |
| 6 | - (new Dotenv\Dotenv(__DIR__.'/../'))->load(); |
|
| 6 | + (new Dotenv\Dotenv(__DIR__ . '/../'))->load(); |
|
| 7 | 7 | } catch (Dotenv\Exception\InvalidPathException $e) { |
| 8 | 8 | // |
| 9 | 9 | } |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | */ |
| 21 | 21 | |
| 22 | 22 | $app = new Laravel\Lumen\Application( |
| 23 | - realpath(__DIR__.'/../') |
|
| 23 | + realpath(__DIR__ . '/../') |
|
| 24 | 24 | ); |
| 25 | 25 | |
| 26 | 26 | $app->withFacades(); |
@@ -98,8 +98,8 @@ discard block |
||
| 98 | 98 | |
| 99 | 99 | $app->router->group([ |
| 100 | 100 | 'namespace' => 'App\Http\Controllers', |
| 101 | -], function ($router) { |
|
| 102 | - require __DIR__.'/../app/Http/routes.php'; |
|
| 101 | +], function($router) { |
|
| 102 | + require __DIR__ . '/../app/Http/routes.php'; |
|
| 103 | 103 | }); |
| 104 | 104 | |
| 105 | 105 | return $app; |
@@ -14,10 +14,10 @@ discard block |
||
| 14 | 14 | $I->seeInThisFile('protected $fillable = ["name", "descr", "due", "project_id", "creator_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 | -" \"creator_id\" => \"required|numeric\",\n". |
|
| 20 | +" \"creator_id\" => \"required|numeric\",\n" . |
|
| 21 | 21 | " ];"); |
| 22 | 22 | $I->seeInThisFile( |
| 23 | 23 | ' public function tags() |
@@ -47,19 +47,19 @@ 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('creator_id')->unsigned();\n" . |
| 57 | -" \$table->foreign('project_id')\n". |
|
| 58 | -" ->references('id')\n". |
|
| 57 | +" \$table->foreign('project_id')\n" . |
|
| 58 | +" ->references('id')\n" . |
|
| 59 | 59 | " ->on('projects');" . PHP_EOL . |
| 60 | -" \$table->foreign('creator_id')\n". |
|
| 61 | -" ->references('id')\n". |
|
| 62 | -" ->on('users');\n". |
|
| 60 | +" \$table->foreign('creator_id')\n" . |
|
| 61 | +" ->references('id')\n" . |
|
| 62 | +" ->on('users');\n" . |
|
| 63 | 63 | " \$table->timestamps();"); |
| 64 | 64 | |
| 65 | 65 | $I->deleteFile('./database/migrations/create_task_categories.php'); |
@@ -22,92 +22,92 @@ |
||
| 22 | 22 | // registerTestCommand |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - protected function registerModelCommand(){ |
|
| 26 | - $this->app->singleton('command.wn.model', function($app){ |
|
| 25 | + protected function registerModelCommand() { |
|
| 26 | + $this->app->singleton('command.wn.model', function($app) { |
|
| 27 | 27 | return $app['Wn\Generators\Commands\ModelCommand']; |
| 28 | 28 | }); |
| 29 | 29 | $this->commands('command.wn.model'); |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - protected function registerControllerRestActionsCommand(){ |
|
| 33 | - $this->app->singleton('command.wn.controller.rest-actions', function($app){ |
|
| 32 | + protected function registerControllerRestActionsCommand() { |
|
| 33 | + $this->app->singleton('command.wn.controller.rest-actions', function($app) { |
|
| 34 | 34 | return $app['Wn\Generators\Commands\ControllerRestActionsCommand']; |
| 35 | 35 | }); |
| 36 | 36 | $this->commands('command.wn.controller.rest-actions'); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - protected function registerControllerCommand(){ |
|
| 40 | - $this->app->singleton('command.wn.controller', function($app){ |
|
| 39 | + protected function registerControllerCommand() { |
|
| 40 | + $this->app->singleton('command.wn.controller', function($app) { |
|
| 41 | 41 | return $app['Wn\Generators\Commands\ControllerCommand']; |
| 42 | 42 | }); |
| 43 | 43 | $this->commands('command.wn.controller'); |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | - protected function registerMigrationCommand(){ |
|
| 47 | - $this->app->singleton('command.wn.migration', function($app){ |
|
| 46 | + protected function registerMigrationCommand() { |
|
| 47 | + $this->app->singleton('command.wn.migration', function($app) { |
|
| 48 | 48 | return $app['Wn\Generators\Commands\MigrationCommand']; |
| 49 | 49 | }); |
| 50 | 50 | $this->commands('command.wn.migration'); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - protected function registerRouteCommand(){ |
|
| 54 | - $this->app->singleton('command.wn.route', function($app){ |
|
| 53 | + protected function registerRouteCommand() { |
|
| 54 | + $this->app->singleton('command.wn.route', function($app) { |
|
| 55 | 55 | return $app['Wn\Generators\Commands\RouteCommand']; |
| 56 | 56 | }); |
| 57 | 57 | $this->commands('command.wn.route'); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - protected function registerTestCommand(){ |
|
| 61 | - $this->app->singleton('command.wn.test', function($app){ |
|
| 60 | + protected function registerTestCommand() { |
|
| 61 | + $this->app->singleton('command.wn.test', function($app) { |
|
| 62 | 62 | return $app['Wn\Generators\Commands\TestCommand']; |
| 63 | 63 | }); |
| 64 | 64 | $this->commands('command.wn.test'); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | - protected function registerResourceCommand(){ |
|
| 68 | - $this->app->singleton('command.wn.resource', function($app){ |
|
| 67 | + protected function registerResourceCommand() { |
|
| 68 | + $this->app->singleton('command.wn.resource', function($app) { |
|
| 69 | 69 | return $app['Wn\Generators\Commands\ResourceCommand']; |
| 70 | 70 | }); |
| 71 | 71 | $this->commands('command.wn.resource'); |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - protected function registerResourcesCommand(){ |
|
| 75 | - $this->app->singleton('command.wn.resources', function($app){ |
|
| 74 | + protected function registerResourcesCommand() { |
|
| 75 | + $this->app->singleton('command.wn.resources', function($app) { |
|
| 76 | 76 | return $app['Wn\Generators\Commands\ResourcesCommand']; |
| 77 | 77 | }); |
| 78 | 78 | $this->commands('command.wn.resources'); |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - protected function registerPivotTableCommand(){ |
|
| 82 | - $this->app->singleton('command.wn.pivot-table', function($app){ |
|
| 81 | + protected function registerPivotTableCommand() { |
|
| 82 | + $this->app->singleton('command.wn.pivot-table', function($app) { |
|
| 83 | 83 | return $app['Wn\Generators\Commands\PivotTableCommand']; |
| 84 | 84 | }); |
| 85 | 85 | $this->commands('command.wn.pivot-table'); |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - protected function registerMorphTableCommand(){ |
|
| 89 | - $this->app->singleton('command.wn.morph-table', function($app){ |
|
| 88 | + protected function registerMorphTableCommand() { |
|
| 89 | + $this->app->singleton('command.wn.morph-table', function($app) { |
|
| 90 | 90 | return $app['Wn\Generators\Commands\MorphTableCommand']; |
| 91 | 91 | }); |
| 92 | 92 | $this->commands('command.wn.morph-table'); |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - protected function registerFactoryCommand(){ |
|
| 96 | - $this->app->singleton('command.wn.factory', function($app){ |
|
| 95 | + protected function registerFactoryCommand() { |
|
| 96 | + $this->app->singleton('command.wn.factory', function($app) { |
|
| 97 | 97 | return $app['Wn\Generators\Commands\FactoryCommand']; |
| 98 | 98 | }); |
| 99 | 99 | $this->commands('command.wn.factory'); |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | - protected function registerSeederCommand(){ |
|
| 103 | - $this->app->singleton('command.wn.seeder', function($app){ |
|
| 102 | + protected function registerSeederCommand() { |
|
| 103 | + $this->app->singleton('command.wn.seeder', function($app) { |
|
| 104 | 104 | return $app['Wn\Generators\Commands\SeederCommand']; |
| 105 | 105 | }); |
| 106 | 106 | $this->commands('command.wn.seeder'); |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - protected function registerPivotSeederCommand(){ |
|
| 110 | - $this->app->singleton('command.wn.pivot.seeder', function($app){ |
|
| 109 | + protected function registerPivotSeederCommand() { |
|
| 110 | + $this->app->singleton('command.wn.pivot.seeder', function($app) { |
|
| 111 | 111 | return $app['Wn\Generators\Commands\PivotSeederCommand']; |
| 112 | 112 | }); |
| 113 | 113 | $this->commands('command.wn.pivot.seeder'); |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | |
| 4 | 4 | class MorphTableCommand extends BaseCommand { |
| 5 | 5 | |
| 6 | - protected $signature = 'wn:morph-table |
|
| 6 | + protected $signature = 'wn:morph-table |
|
| 7 | 7 | {model : Name of the persistant model or table} |
| 8 | 8 | {morphable : Name of the morphable identifier} |
| 9 | 9 | {--add= : specifies additional columns like timestamps, softDeletes, rememberToken and nullableTimestamps.} |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | {--force= : override the existing files} |
| 12 | 12 | '; |
| 13 | 13 | |
| 14 | - protected $description = 'Generates creation migration for a morphable pivot table'; |
|
| 14 | + protected $description = 'Generates creation migration for a morphable pivot table'; |
|
| 15 | 15 | |
| 16 | 16 | protected $fields; |
| 17 | 17 | |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | protected function keys() |
| 49 | 49 | { |
| 50 | 50 | // return implode(' ', $this->fields); |
| 51 | - return snake_case(str_singular($this->argument('model')))."_id"; |
|
| 51 | + return snake_case(str_singular($this->argument('model')))."_id"; |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | } |
@@ -33,14 +33,14 @@ discard block |
||
| 33 | 33 | protected function parseFields() |
| 34 | 34 | { |
| 35 | 35 | $this->fields = array_map(function($arg, $app) { |
| 36 | - return snake_case(str_singular($this->argument($arg)))."_".$app; |
|
| 36 | + return snake_case(str_singular($this->argument($arg))) . "_" . $app; |
|
| 37 | 37 | }, ['model', 'morphable', 'morphable'], ['id', 'id', 'type']); |
| 38 | 38 | |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | protected function schema() |
| 42 | 42 | { |
| 43 | - return implode(' ', array_map(function($field){ |
|
| 43 | + return implode(' ', array_map(function($field) { |
|
| 44 | 44 | return $field . ':' . (substr($field, -3) == '_id' ? 'integer:unsigned' : 'string.50') . ':index'; |
| 45 | 45 | }, $this->fields)); |
| 46 | 46 | } |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | protected function keys() |
| 49 | 49 | { |
| 50 | 50 | // return implode(' ', $this->fields); |
| 51 | - return snake_case(str_singular($this->argument('model')))."_id"; |
|
| 51 | + return snake_case(str_singular($this->argument('model'))) . "_id"; |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | } |
@@ -21,6 +21,9 @@ discard block |
||
| 21 | 21 | $this->argumentFormatLoader = new ArgumentFormatLoader($fs); |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | + /** |
|
| 25 | + * @param string $name |
|
| 26 | + */ |
|
| 24 | 27 | protected function getTemplate($name) |
| 25 | 28 | { |
| 26 | 29 | return $this->templates->load($name); |
@@ -31,6 +34,9 @@ discard block |
||
| 31 | 34 | return new ArgumentParser($format); |
| 32 | 35 | } |
| 33 | 36 | |
| 37 | + /** |
|
| 38 | + * @param string $content |
|
| 39 | + */ |
|
| 34 | 40 | protected function save($content, $path, $name, $force = false) |
| 35 | 41 | { |
| 36 | 42 | if (!$force && $this->fs->exists($path) && $this->input->hasOption('force') && !$this->option('force')) { |
@@ -49,6 +55,9 @@ discard block |
||
| 49 | 55 | } |
| 50 | 56 | } |
| 51 | 57 | |
| 58 | + /** |
|
| 59 | + * @param integer $n |
|
| 60 | + */ |
|
| 52 | 61 | protected function spaces($n) |
| 53 | 62 | { |
| 54 | 63 | return str_repeat(' ', $n); |
@@ -65,6 +74,9 @@ discard block |
||
| 65 | 74 | }))); |
| 66 | 75 | } |
| 67 | 76 | |
| 77 | + /** |
|
| 78 | + * @param string $parser |
|
| 79 | + */ |
|
| 68 | 80 | protected function parseValue($value, $parser) |
| 69 | 81 | { |
| 70 | 82 | if(! $value){ |
@@ -78,6 +90,9 @@ discard block |
||
| 78 | 90 | return $value; |
| 79 | 91 | } |
| 80 | 92 | |
| 93 | + /** |
|
| 94 | + * @return string |
|
| 95 | + */ |
|
| 81 | 96 | protected function prependNamespace($value, $path = false) |
| 82 | 97 | { |
| 83 | 98 | if (strpos($value, '\\') === false) { |
@@ -87,6 +102,9 @@ discard block |
||
| 87 | 102 | return $value; |
| 88 | 103 | } |
| 89 | 104 | |
| 105 | + /** |
|
| 106 | + * @return string |
|
| 107 | + */ |
|
| 90 | 108 | protected function extractClassName($fqClassName) { |
| 91 | 109 | $names = array_reverse(explode("\\", $fqClassName)); |
| 92 | 110 | return $names[0]; |
@@ -10,10 +10,10 @@ discard block |
||
| 10 | 10 | class BaseCommand extends Command { |
| 11 | 11 | |
| 12 | 12 | protected $fs; |
| 13 | - protected $templates; |
|
| 13 | + protected $templates; |
|
| 14 | 14 | |
| 15 | - public function __construct(Filesystem $fs) |
|
| 16 | - { |
|
| 15 | + public function __construct(Filesystem $fs) |
|
| 16 | + { |
|
| 17 | 17 | parent::__construct(); |
| 18 | 18 | |
| 19 | 19 | $this->fs = $fs; |
@@ -56,11 +56,11 @@ discard block |
||
| 56 | 56 | |
| 57 | 57 | protected function getNamespace($path = false) |
| 58 | 58 | { |
| 59 | - if (! $path) { |
|
| 60 | - $path = $this->option('path'); |
|
| 61 | - } |
|
| 59 | + if (! $path) { |
|
| 60 | + $path = $this->option('path'); |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - return implode('\\', array_map('studly_case', array_filter(array_map('trim', explode('/', $path)), function($value) { |
|
| 63 | + return implode('\\', array_map('studly_case', array_filter(array_map('trim', explode('/', $path)), function($value) { |
|
| 64 | 64 | return !empty($value); |
| 65 | 65 | }))); |
| 66 | 66 | } |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | return $this->templates->load($name); |
| 27 | 27 | } |
| 28 | 28 | |
| 29 | - protected function getArgumentParser($name){ |
|
| 29 | + protected function getArgumentParser($name) { |
|
| 30 | 30 | $format = $this->argumentFormatLoader->load($name); |
| 31 | 31 | return new ArgumentParser($format); |
| 32 | 32 | } |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | |
| 57 | 57 | protected function getNamespace($path = false) |
| 58 | 58 | { |
| 59 | - if (! $path) { |
|
| 59 | + if (!$path) { |
|
| 60 | 60 | $path = $this->option('path'); |
| 61 | 61 | } |
| 62 | 62 | |
@@ -67,11 +67,11 @@ discard block |
||
| 67 | 67 | |
| 68 | 68 | protected function parseValue($value, $parser) |
| 69 | 69 | { |
| 70 | - if(! $value){ |
|
| 70 | + if (!$value) { |
|
| 71 | 71 | return false; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - if(! $this->option('parsed')){ |
|
| 74 | + if (!$this->option('parsed')) { |
|
| 75 | 75 | return $this->getArgumentParser($parser)->parse($value); |
| 76 | 76 | } |
| 77 | 77 | |