@@ -42,41 +42,24 @@ protected function getPackageAliases($app): array
4242 */
4343 protected function getEnvironmentSetUp ($ app ): void
4444 {
45- $ host = env ('DB_HOST ' , 'db_migration ' );
46- $ app ['config ' ]->set ('database.connections.mysql.host ' , $ host );
47- $ app ['config ' ]->set ('database.default ' , env ('DB_CONNECTION ' , 'mysql ' ));
48- $ app ['config ' ]->set (
49- 'database.connections.mysql ' ,
50- [
51- 'host ' => env ('DB_HOST ' , 'db_migration ' ),
52- 'driver ' => 'mysql ' ,
53- 'database ' => 'testing ' ,
54- 'username ' => 'root ' ,
55- 'password ' => '' ,
56- 'prefix ' => '' ,
57- ]
58- );
59- $ app ['config ' ]->set (
60- 'database.connections.pgsql ' ,
61- [
62- 'host ' => env ('DB_HOST ' , 'db_migration ' ),
63- 'driver ' => 'pgsql ' ,
64- 'database ' => 'testing ' ,
65- 'username ' => env ('DB_USERNAME ' , 'postgres ' ),
66- 'password ' => env ('DB_PASSWORD ' , '! ' ),
67- 'prefix ' => '' ,
68- ]
69- );
70- $ app ['config ' ]->set (
71- 'database.connections.sqlsrv ' ,
72- [
73- 'host ' => env ('DB_HOST ' , 'db_migration ' ),
74- 'driver ' => 'sqlsrv ' ,
75- 'database ' => 'testing ' ,
76- 'username ' => env ('DB_USERNAME ' , 'SA ' ),
77- 'password ' => env ('DB_PASSWORD ' , 'Passw0rd1234! ' ),
78- 'prefix ' => '' ,
79- ]
80- );
45+ $ defaultConnection = env ('DB_CONNECTION ' , 'mysql ' );
46+ $ host = env ('DB_HOST ' , '127.0.0.1 ' );
47+
48+ $ credentials = [
49+ 'mysql ' => ['username ' => 'root ' , 'password ' => '' ],
50+ 'pgsql ' => ['username ' => env ('DB_USERNAME ' , 'postgres ' ), 'password ' => env ('DB_PASSWORD ' , '' )],
51+ 'sqlsrv ' => ['username ' => env ('DB_USERNAME ' , 'SA ' ), 'password ' => env ('DB_PASSWORD ' , 'Passw0rd1234! ' )],
52+ ];
53+
54+ $ app ['config ' ]->set ('database.default ' , $ defaultConnection );
55+
56+ $ app ['config ' ]->set ("database.connections. $ defaultConnection " , [
57+ 'host ' => $ host ,
58+ 'driver ' => $ defaultConnection ,
59+ 'database ' => 'testing ' ,
60+ 'username ' => $ credentials [$ defaultConnection ]['username ' ] ?? 'root ' ,
61+ 'password ' => $ credentials [$ defaultConnection ]['password ' ] ?? '' ,
62+ 'prefix ' => '' ,
63+ ]);
8164 }
8265}
0 commit comments