@@ -61,8 +61,7 @@ |
||
61 | 61 | * class UserServiceProvider |
62 | 62 | * @package Platine\Framework |
63 | 63 | */ |
64 | -class UserServiceProvider extends ServiceProvider |
|
65 | -{ |
|
64 | +class UserServiceProvider extends ServiceProvider { |
|
66 | 65 | |
67 | 66 | /** |
68 | 67 | * {@inheritdoc} |
@@ -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 | $type = $this->getArgumentValue('type'); |
97 | 95 | |
98 | 96 | $io = $this->io(); |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | ) { |
73 | 73 | parent::__construct($app, $repository, $config, $filesystem); |
74 | 74 | $this->setName('migration:exec') |
75 | - ->setDescription('Execute the migration up/down for one version'); |
|
75 | + ->setDescription('Execute the migration up/down for one version'); |
|
76 | 76 | |
77 | 77 | $this->addArgument('type', 'type of migration [up|down]', 'up', true, true, false, function ($val) { |
78 | 78 | if (!in_array($val, ['up', 'down'])) { |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | )); |
83 | 83 | } |
84 | 84 | |
85 | - return $val; |
|
85 | + return $val; |
|
86 | 86 | }); |
87 | 87 | |
88 | 88 | $this->addOption('-i|--id', 'the migration version', null, false, true); |
@@ -74,7 +74,7 @@ |
||
74 | 74 | $this->setName('migration:exec') |
75 | 75 | ->setDescription('Execute the migration up/down for one version'); |
76 | 76 | |
77 | - $this->addArgument('type', 'type of migration [up|down]', 'up', true, true, false, function ($val) { |
|
77 | + $this->addArgument('type', 'type of migration [up|down]', 'up', true, true, false, function($val) { |
|
78 | 78 | if (!in_array($val, ['up', 'down'])) { |
79 | 79 | throw new RuntimeException(sprintf( |
80 | 80 | 'Invalid argument type [%s], must be one of [up, down]', |
@@ -54,8 +54,7 @@ discard block |
||
54 | 54 | * class DbConfig |
55 | 55 | * @package Platine\Framework\Config |
56 | 56 | */ |
57 | -class DbConfig extends Config |
|
58 | -{ |
|
57 | +class DbConfig extends Config { |
|
59 | 58 | |
60 | 59 | /** |
61 | 60 | * The Query Builder instance |
@@ -68,8 +67,7 @@ discard block |
||
68 | 67 | * @param QueryBuilder $queryBuilder |
69 | 68 | * @param string $env |
70 | 69 | */ |
71 | - public function __construct(QueryBuilder $queryBuilder, string $env = '') |
|
72 | - { |
|
70 | + public function __construct(QueryBuilder $queryBuilder, string $env = '') { |
|
73 | 71 | $this->queryBuilder = $queryBuilder; |
74 | 72 | parent::__construct(new DatabaseConfigLoader($queryBuilder, 'config'), $env); |
75 | 73 | } |
@@ -9,44 +9,44 @@ |
||
9 | 9 | |
10 | 10 | public function up(): void |
11 | 11 | { |
12 | - //Action when migrate up |
|
13 | - $this->create('config', function (CreateTable $table) { |
|
14 | - $table->integer('id') |
|
15 | - ->autoincrement() |
|
16 | - ->primary(); |
|
17 | - $table->string('env') |
|
18 | - ->description('The config environment') |
|
19 | - ->index(); |
|
20 | - $table->string('module') |
|
21 | - ->description('The module') |
|
22 | - ->index(); |
|
23 | - $table->string('code') |
|
24 | - ->description('The config code') |
|
25 | - ->notNull() |
|
26 | - ->index(); |
|
27 | - $table->string('value') |
|
28 | - ->description('The config value'); |
|
29 | - $table->string('type') |
|
30 | - ->description('The config data type'); |
|
31 | - $table->text('comment') |
|
32 | - ->description('The config description'); |
|
33 | - $table->integer('status') |
|
34 | - ->description('The config status') |
|
35 | - ->defaultValue(0) |
|
36 | - ->notNull(); |
|
37 | - $table->datetime('created_at') |
|
38 | - ->description('role created at') |
|
39 | - ->notNull(); |
|
40 | - $table->datetime('updated_at') |
|
41 | - ->description('role updated at'); |
|
12 | + //Action when migrate up |
|
13 | + $this->create('config', function (CreateTable $table) { |
|
14 | + $table->integer('id') |
|
15 | + ->autoincrement() |
|
16 | + ->primary(); |
|
17 | + $table->string('env') |
|
18 | + ->description('The config environment') |
|
19 | + ->index(); |
|
20 | + $table->string('module') |
|
21 | + ->description('The module') |
|
22 | + ->index(); |
|
23 | + $table->string('code') |
|
24 | + ->description('The config code') |
|
25 | + ->notNull() |
|
26 | + ->index(); |
|
27 | + $table->string('value') |
|
28 | + ->description('The config value'); |
|
29 | + $table->string('type') |
|
30 | + ->description('The config data type'); |
|
31 | + $table->text('comment') |
|
32 | + ->description('The config description'); |
|
33 | + $table->integer('status') |
|
34 | + ->description('The config status') |
|
35 | + ->defaultValue(0) |
|
36 | + ->notNull(); |
|
37 | + $table->datetime('created_at') |
|
38 | + ->description('role created at') |
|
39 | + ->notNull(); |
|
40 | + $table->datetime('updated_at') |
|
41 | + ->description('role updated at'); |
|
42 | 42 | |
43 | - $table->engine('INNODB'); |
|
44 | - }); |
|
43 | + $table->engine('INNODB'); |
|
44 | + }); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | public function down(): void |
48 | 48 | { |
49 | - //Action when migrate down |
|
50 | - $this->drop('config'); |
|
49 | + //Action when migrate down |
|
50 | + $this->drop('config'); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | \ 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('config', function (CreateTable $table) { |
|
13 | + $this->create('config', 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 AddConfigTable20210708043103 extends AbstractMigration |
|
8 | -{ |
|
7 | +class AddConfigTable20210708043103 extends AbstractMigration { |
|
9 | 8 | |
10 | 9 | public function up(): void |
11 | 10 | { |
@@ -157,13 +157,13 @@ |
||
157 | 157 | foreach ($results as $cfg) { |
158 | 158 | if ($cfg->parent) { |
159 | 159 | $results = $this->queryBuilder |
160 | - ->from($this->table) |
|
161 | - ->where('env')->is($cfg->env) |
|
162 | - ->where('module')->is($cfg->parent) |
|
163 | - ->where('status')->is(1) |
|
164 | - ->select() |
|
165 | - ->fetchObject() |
|
166 | - ->all(); |
|
160 | + ->from($this->table) |
|
161 | + ->where('env')->is($cfg->env) |
|
162 | + ->where('module')->is($cfg->parent) |
|
163 | + ->where('status')->is(1) |
|
164 | + ->select() |
|
165 | + ->fetchObject() |
|
166 | + ->all(); |
|
167 | 167 | |
168 | 168 | foreach ($results as $cfg) { |
169 | 169 | $config[$cfg->name] = $cfg->value ?? $cfg->default_value; |
@@ -129,7 +129,7 @@ discard block |
||
129 | 129 | */ |
130 | 130 | protected function parse(string $env): array |
131 | 131 | { |
132 | - $environments = array_filter((array)preg_split('/(\/|\.)/', $env)); |
|
132 | + $environments = array_filter((array) preg_split('/(\/|\.)/', $env)); |
|
133 | 133 | array_unshift($environments, ''); |
134 | 134 | |
135 | 135 | return $environments; |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | { |
184 | 184 | $results = $this->queryBuilder |
185 | 185 | ->from($this->table) |
186 | - ->where('id')->in(function (SubQuery $q) use ($env, $group) { |
|
186 | + ->where('id')->in(function(SubQuery $q) use ($env, $group) { |
|
187 | 187 | $query = $q->from($this->table) |
188 | 188 | ->where('module')->is($group) |
189 | 189 | ->where('status')->is(1) |
@@ -194,8 +194,8 @@ discard block |
||
194 | 194 | $query->where('env')->is($env); |
195 | 195 | } |
196 | 196 | |
197 | - $query->select(function (ColumnExpression $cexp) { |
|
198 | - $cexp->column(function (Expression $exp) { |
|
197 | + $query->select(function(ColumnExpression $cexp) { |
|
198 | + $cexp->column(function(Expression $exp) { |
|
199 | 199 | $exp->op('COALESCE'); |
200 | 200 | }); |
201 | 201 | }); |
@@ -57,8 +57,7 @@ discard block |
||
57 | 57 | * class DatabaseConfigLoader |
58 | 58 | * @package Platine\Framework\Config |
59 | 59 | */ |
60 | -class DatabaseConfigLoader implements LoaderInterface |
|
61 | -{ |
|
60 | +class DatabaseConfigLoader implements LoaderInterface { |
|
62 | 61 | |
63 | 62 | /** |
64 | 63 | * The QueryBuilder instance |
@@ -179,8 +178,7 @@ discard block |
||
179 | 178 | * @param string|null $env |
180 | 179 | * @return mixed |
181 | 180 | */ |
182 | - public function getConfigurations(string $group, ?string $env = null) |
|
183 | - { |
|
181 | + public function getConfigurations(string $group, ?string $env = null) { |
|
184 | 182 | $results = $this->queryBuilder |
185 | 183 | ->from($this->table) |
186 | 184 | ->where('id')->in(function (SubQuery $q) use ($env, $group) { |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | ) { |
81 | 81 | parent::__construct($app, $repository, $config, $filesystem); |
82 | 82 | $this->setName('migration:init') |
83 | - ->setDescription("Initialize the migration data. Note this command\n" |
|
84 | - . "is run only at the first time to create migration table"); |
|
83 | + ->setDescription("Initialize the migration data. Note this command\n" |
|
84 | + . "is run only at the first time to create migration table"); |
|
85 | 85 | |
86 | 86 | $this->schema = $schema; |
87 | 87 | } |
@@ -119,10 +119,10 @@ discard block |
||
119 | 119 | $tableName = $this->table; |
120 | 120 | $this->schema->create($tableName, function (CreateTable $table) { |
121 | 121 | $table->string('version', 20) |
122 | - ->description('The migration version') |
|
123 | - ->primary(); |
|
122 | + ->description('The migration version') |
|
123 | + ->primary(); |
|
124 | 124 | $table->string('description') |
125 | - ->description('The migration description'); |
|
125 | + ->description('The migration description'); |
|
126 | 126 | $table->datetime('created_at') |
127 | 127 | ->description('Migration run time'); |
128 | 128 |
@@ -117,7 +117,7 @@ |
||
117 | 117 | protected function createMigrationTable(): void |
118 | 118 | { |
119 | 119 | $tableName = $this->table; |
120 | - $this->schema->create($tableName, function (CreateTable $table) { |
|
120 | + $this->schema->create($tableName, function(CreateTable $table) { |
|
121 | 121 | $table->string('version', 20) |
122 | 122 | ->description('The migration version') |
123 | 123 | ->primary(); |
@@ -58,8 +58,7 @@ discard block |
||
58 | 58 | * class MigrationInitCommand |
59 | 59 | * @package Platine\Framework\Migration\Command |
60 | 60 | */ |
61 | -class MigrationInitCommand extends AbstractCommand |
|
62 | -{ |
|
61 | +class MigrationInitCommand extends AbstractCommand { |
|
63 | 62 | |
64 | 63 | /** |
65 | 64 | * The schema to use |
@@ -89,8 +88,7 @@ discard block |
||
89 | 88 | /** |
90 | 89 | * {@inheritodc} |
91 | 90 | */ |
92 | - public function execute() |
|
93 | - { |
|
91 | + public function execute() { |
|
94 | 92 | $io = $this->io(); |
95 | 93 | $writer = $io->writer(); |
96 | 94 | $writer->boldYellow('MIGRATION INITIALIZATION', true); |