@@ -18,16 +18,14 @@ discard block |
||
| 18 | 18 | * |
| 19 | 19 | * @author tony |
| 20 | 20 | */ |
| 21 | -class ConfigCommand extends Command |
|
| 22 | -{ |
|
| 21 | +class ConfigCommand extends Command { |
|
| 23 | 22 | |
| 24 | 23 | protected Application $application; |
| 25 | 24 | |
| 26 | 25 | /** |
| 27 | 26 | * |
| 28 | 27 | */ |
| 29 | - public function __construct(Application $application) |
|
| 30 | - { |
|
| 28 | + public function __construct(Application $application) { |
|
| 31 | 29 | parent::__construct('config', 'Command to manage configuration'); |
| 32 | 30 | |
| 33 | 31 | $this->addOption('-l|--list', 'List the configuration', '', false); |
@@ -36,8 +34,7 @@ discard block |
||
| 36 | 34 | $this->application = $application; |
| 37 | 35 | } |
| 38 | 36 | |
| 39 | - public function execute() |
|
| 40 | - { |
|
| 37 | + public function execute() { |
|
| 41 | 38 | if ($this->getOptionValue('list')) { |
| 42 | 39 | $this->showConfigList(); |
| 43 | 40 | } |
@@ -20,16 +20,14 @@ discard block |
||
| 20 | 20 | * |
| 21 | 21 | * @author tony |
| 22 | 22 | */ |
| 23 | -class RouteCommand extends Command |
|
| 24 | -{ |
|
| 23 | +class RouteCommand extends Command { |
|
| 25 | 24 | protected Application $application; |
| 26 | 25 | protected Router $router; |
| 27 | 26 | |
| 28 | 27 | /** |
| 29 | 28 | * |
| 30 | 29 | */ |
| 31 | - public function __construct(Application $application, Router $router) |
|
| 32 | - { |
|
| 30 | + public function __construct(Application $application, Router $router) { |
|
| 33 | 31 | parent::__construct('route', 'Command to manage route'); |
| 34 | 32 | |
| 35 | 33 | $this->addOption('-l|--list', 'Show route list', null, false); |
@@ -38,8 +36,7 @@ discard block |
||
| 38 | 36 | $this->application = $application; |
| 39 | 37 | } |
| 40 | 38 | |
| 41 | - public function execute() |
|
| 42 | - { |
|
| 39 | + public function execute() { |
|
| 43 | 40 | if ($this->getOptionValue('list')) { |
| 44 | 41 | $this->showRouteList(); |
| 45 | 42 | } |
@@ -73,7 +73,7 @@ |
||
| 73 | 73 | ) { |
| 74 | 74 | parent::__construct($app, $repository, $schema, $config, $filesystem); |
| 75 | 75 | $this->setName('migration:migrate') |
| 76 | - ->setDescription('Upgrade migration to latest'); |
|
| 76 | + ->setDescription('Upgrade migration to latest'); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /** |
@@ -73,7 +73,7 @@ |
||
| 73 | 73 | ) { |
| 74 | 74 | parent::__construct($app, $repository, $schema, $config, $filesystem); |
| 75 | 75 | $this->setName('migration:reset') |
| 76 | - ->setDescription('Rollback all migration done before'); |
|
| 76 | + ->setDescription('Rollback all migration done before'); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /** |
@@ -57,8 +57,7 @@ discard block |
||
| 57 | 57 | * class MigrationResetCommand |
| 58 | 58 | * @package Platine\Framework\Migration\Command |
| 59 | 59 | */ |
| 60 | -class MigrationResetCommand extends AbstractCommand |
|
| 61 | -{ |
|
| 60 | +class MigrationResetCommand extends AbstractCommand { |
|
| 62 | 61 | |
| 63 | 62 | /** |
| 64 | 63 | * Create new instance |
@@ -79,8 +78,7 @@ discard block |
||
| 79 | 78 | /** |
| 80 | 79 | * {@inheritodc} |
| 81 | 80 | */ |
| 82 | - public function execute() |
|
| 83 | - { |
|
| 81 | + public function execute() { |
|
| 84 | 82 | $io = $this->io(); |
| 85 | 83 | $writer = $io->writer(); |
| 86 | 84 | $writer->boldYellow('ALL MIGRATION ROLLBACK', true)->eol(); |
@@ -176,10 +176,10 @@ discard block |
||
| 176 | 176 | $tableName = $this->config->get('migration.table', 'migrations'); |
| 177 | 177 | $this->schema->create($tableName, function (CreateTable $table) { |
| 178 | 178 | $table->string('version', 20) |
| 179 | - ->description('The migration version') |
|
| 180 | - ->primary(); |
|
| 179 | + ->description('The migration version') |
|
| 180 | + ->primary(); |
|
| 181 | 181 | $table->string('description') |
| 182 | - ->description('The migration description'); |
|
| 182 | + ->description('The migration description'); |
|
| 183 | 183 | $table->datetime('created_at') |
| 184 | 184 | ->description('Migration run time'); |
| 185 | 185 | |
@@ -261,9 +261,9 @@ discard block |
||
| 261 | 261 | $this->checkMigrationTable(); |
| 262 | 262 | |
| 263 | 263 | $migrations = $this->repository |
| 264 | - ->query() |
|
| 265 | - ->orderBy('version', $orderDir) |
|
| 266 | - ->all(); |
|
| 264 | + ->query() |
|
| 265 | + ->orderBy('version', $orderDir) |
|
| 266 | + ->all(); |
|
| 267 | 267 | $result = []; |
| 268 | 268 | |
| 269 | 269 | foreach ($migrations as $entity) { |
@@ -282,7 +282,7 @@ discard block |
||
| 282 | 282 | protected function getMigrationClassName(string $description, string $version): string |
| 283 | 283 | { |
| 284 | 284 | return Str::camel($description, false) |
| 285 | - . Str::replaceFirst('_', '', $version); |
|
| 285 | + . Str::replaceFirst('_', '', $version); |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | 288 | /** |
@@ -74,7 +74,7 @@ discard block |
||
| 74 | 74 | ) { |
| 75 | 75 | parent::__construct($app, $repository, $schema, $config, $filesystem); |
| 76 | 76 | $this->setName('migration:exec') |
| 77 | - ->setDescription('Execute the migration up/down for one version'); |
|
| 77 | + ->setDescription('Execute the migration up/down for one version'); |
|
| 78 | 78 | |
| 79 | 79 | $this->addArgument('type', 'type of migration [up|down]', 'up', true, true, false, function ($val) { |
| 80 | 80 | if (!in_array($val, ['up', 'down'])) { |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | )); |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - return $val; |
|
| 87 | + return $val; |
|
| 88 | 88 | }); |
| 89 | 89 | } |
| 90 | 90 | |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | $this->setName('migration:exec') |
| 77 | 77 | ->setDescription('Execute the migration up/down for one version'); |
| 78 | 78 | |
| 79 | - $this->addArgument('type', 'type of migration [up|down]', 'up', true, true, false, function ($val) { |
|
| 79 | + $this->addArgument('type', 'type of migration [up|down]', 'up', true, true, false, function($val) { |
|
| 80 | 80 | if (!in_array($val, ['up', 'down'])) { |
| 81 | 81 | throw new RuntimeException(sprintf( |
| 82 | 82 | 'Invalid argument type [%s], must be one of [up, down]', |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | } else { |
| 119 | 119 | $data = []; |
| 120 | 120 | foreach ($executed as $version => $entity) { |
| 121 | - $data[(string)$version] = $entity->description; |
|
| 121 | + $data[(string) $version] = $entity->description; |
|
| 122 | 122 | } |
| 123 | 123 | $version = $io->choice('Choose which version to rollback', $data); |
| 124 | 124 | $description = str_replace('_', ' ', $data[$version]); |
@@ -58,8 +58,7 @@ discard block |
||
| 58 | 58 | * class MigrationExecuteCommand |
| 59 | 59 | * @package Platine\Framework\Migration\Command |
| 60 | 60 | */ |
| 61 | -class MigrationExecuteCommand extends AbstractCommand |
|
| 62 | -{ |
|
| 61 | +class MigrationExecuteCommand extends AbstractCommand { |
|
| 63 | 62 | |
| 64 | 63 | /** |
| 65 | 64 | * Create new instance |
@@ -91,8 +90,7 @@ discard block |
||
| 91 | 90 | /** |
| 92 | 91 | * {@inheritodc} |
| 93 | 92 | */ |
| 94 | - public function execute() |
|
| 95 | - { |
|
| 93 | + public function execute() { |
|
| 96 | 94 | //$version = $this->getArgumentValue('migrationVersion'); |
| 97 | 95 | $type = $this->getArgumentValue('type'); |
| 98 | 96 | |
@@ -60,8 +60,7 @@ discard block |
||
| 60 | 60 | * class MigrationCreateCommand |
| 61 | 61 | * @package Platine\Framework\Migration\Command |
| 62 | 62 | */ |
| 63 | -class MigrationCreateCommand extends AbstractCommand |
|
| 64 | -{ |
|
| 63 | +class MigrationCreateCommand extends AbstractCommand { |
|
| 65 | 64 | |
| 66 | 65 | /** |
| 67 | 66 | * The migration name |
@@ -88,8 +87,7 @@ discard block |
||
| 88 | 87 | /** |
| 89 | 88 | * {@inheritodc} |
| 90 | 89 | */ |
| 91 | - public function execute() |
|
| 92 | - { |
|
| 90 | + public function execute() { |
|
| 93 | 91 | $writer = $this->io()->writer(); |
| 94 | 92 | |
| 95 | 93 | $version = date('Ymd_His'); |
@@ -155,26 +153,3 @@ discard block |
||
| 155 | 153 | private function getTemplateClass(): string |
| 156 | 154 | { |
| 157 | 155 | return <<<EOF |
| 158 | - <?php |
|
| 159 | - namespace Platine\Framework\Migration; |
|
| 160 | - |
|
| 161 | - use Platine\Framework\Migration\AbstractMigration; |
|
| 162 | - |
|
| 163 | - class %classname% extends AbstractMigration |
|
| 164 | - { |
|
| 165 | - |
|
| 166 | - public function up(): void |
|
| 167 | - { |
|
| 168 | - //Action when migrate up |
|
| 169 | - |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - public function down(): void |
|
| 173 | - { |
|
| 174 | - //Action when migrate down |
|
| 175 | - |
|
| 176 | - } |
|
| 177 | - } |
|
| 178 | - EOF; |
|
| 179 | - } |
|
| 180 | -} |
|
@@ -9,26 +9,26 @@ |
||
| 9 | 9 | |
| 10 | 10 | public function up(): void |
| 11 | 11 | { |
| 12 | - //Action when migrate up |
|
| 13 | - $this->create('roles', function (CreateTable $table) { |
|
| 14 | - $table->integer('id') |
|
| 15 | - ->autoincrement() |
|
| 16 | - ->primary(); |
|
| 17 | - $table->string('description') |
|
| 18 | - ->description('The role description'); |
|
| 19 | - $table->datetime('created_at') |
|
| 20 | - ->description('role created at') |
|
| 21 | - ->notNull(); |
|
| 22 | - $table->datetime('updated_at') |
|
| 23 | - ->description('role updated at'); |
|
| 12 | + //Action when migrate up |
|
| 13 | + $this->create('roles', function (CreateTable $table) { |
|
| 14 | + $table->integer('id') |
|
| 15 | + ->autoincrement() |
|
| 16 | + ->primary(); |
|
| 17 | + $table->string('description') |
|
| 18 | + ->description('The role description'); |
|
| 19 | + $table->datetime('created_at') |
|
| 20 | + ->description('role created at') |
|
| 21 | + ->notNull(); |
|
| 22 | + $table->datetime('updated_at') |
|
| 23 | + ->description('role updated at'); |
|
| 24 | 24 | |
| 25 | - $table->engine('INNODB'); |
|
| 26 | - }); |
|
| 25 | + $table->engine('INNODB'); |
|
| 26 | + }); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | public function down(): void |
| 30 | 30 | { |
| 31 | - //Action when migrate down |
|
| 32 | - $this->drop('roles'); |
|
| 31 | + //Action when migrate down |
|
| 32 | + $this->drop('roles'); |
|
| 33 | 33 | } |
| 34 | 34 | } |
| 35 | 35 | \ No newline at end of file |
@@ -10,7 +10,7 @@ |
||
| 10 | 10 | public function up(): void |
| 11 | 11 | { |
| 12 | 12 | //Action when migrate up |
| 13 | - $this->create('roles', function (CreateTable $table) { |
|
| 13 | + $this->create('roles', function(CreateTable $table) { |
|
| 14 | 14 | $table->integer('id') |
| 15 | 15 | ->autoincrement() |
| 16 | 16 | ->primary(); |
@@ -4,8 +4,7 @@ |
||
| 4 | 4 | use Platine\Database\Schema\CreateTable; |
| 5 | 5 | use Platine\Framework\Migration\AbstractMigration; |
| 6 | 6 | |
| 7 | -class AddRolesTable20210705065247 extends AbstractMigration |
|
| 8 | -{ |
|
| 7 | +class AddRolesTable20210705065247 extends AbstractMigration { |
|
| 9 | 8 | |
| 10 | 9 | public function up(): void |
| 11 | 10 | { |
@@ -9,18 +9,18 @@ |
||
| 9 | 9 | |
| 10 | 10 | public function up(): void |
| 11 | 11 | { |
| 12 | - //Action when migrate up |
|
| 13 | - $this->alter('roles', function (AlterTable $table) { |
|
| 14 | - $table->string('code')->notNull(); |
|
| 15 | - $table->unique('code'); |
|
| 16 | - }); |
|
| 12 | + //Action when migrate up |
|
| 13 | + $this->alter('roles', function (AlterTable $table) { |
|
| 14 | + $table->string('code')->notNull(); |
|
| 15 | + $table->unique('code'); |
|
| 16 | + }); |
|
| 17 | 17 | } |
| 18 | 18 | |
| 19 | 19 | public function down(): void |
| 20 | 20 | { |
| 21 | - //Action when migrate down |
|
| 22 | - $this->alter('roles', function (AlterTable $table) { |
|
| 23 | - $table->dropColumn('code'); |
|
| 24 | - }); |
|
| 21 | + //Action when migrate down |
|
| 22 | + $this->alter('roles', function (AlterTable $table) { |
|
| 23 | + $table->dropColumn('code'); |
|
| 24 | + }); |
|
| 25 | 25 | } |
| 26 | 26 | } |
| 27 | 27 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | public function up(): void |
| 11 | 11 | { |
| 12 | 12 | //Action when migrate up |
| 13 | - $this->alter('roles', function (AlterTable $table) { |
|
| 13 | + $this->alter('roles', function(AlterTable $table) { |
|
| 14 | 14 | $table->string('code')->notNull(); |
| 15 | 15 | $table->unique('code'); |
| 16 | 16 | }); |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | public function down(): void |
| 20 | 20 | { |
| 21 | 21 | //Action when migrate down |
| 22 | - $this->alter('roles', function (AlterTable $table) { |
|
| 22 | + $this->alter('roles', function(AlterTable $table) { |
|
| 23 | 23 | $table->dropColumn('code'); |
| 24 | 24 | }); |
| 25 | 25 | } |
@@ -4,8 +4,7 @@ |
||
| 4 | 4 | use Platine\Database\Schema\AlterTable; |
| 5 | 5 | use Platine\Framework\Migration\AbstractMigration; |
| 6 | 6 | |
| 7 | -class AddRolesCodeField20210705065339 extends AbstractMigration |
|
| 8 | -{ |
|
| 7 | +class AddRolesCodeField20210705065339 extends AbstractMigration { |
|
| 9 | 8 | |
| 10 | 9 | public function up(): void |
| 11 | 10 | { |