Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Commit 957744d

Browse files
committed
Revert to previous DB configuration structure
1 parent 5127ef4 commit 957744d

File tree

2 files changed

+32
-35
lines changed

2 files changed

+32
-35
lines changed

config/websockets.php

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -42,34 +42,35 @@
4242

4343
'app' => \BeyondCode\LaravelWebSockets\Apps\ConfigAppManager::class,
4444

45-
'database' => [
46-
/*
47-
|--------------------------------------------------------------------------
48-
| SQLite application manager
49-
|--------------------------------------------------------------------------
50-
|
51-
| The SQLite database to use when using the SQLite application manager.
52-
|
53-
*/
54-
'driver' => 'sqlite',
55-
'database' => storage_path('laravel-websockets.sqlite'),
45+
/*
46+
|--------------------------------------------------------------------------
47+
| SQLite application manager
48+
|--------------------------------------------------------------------------
49+
|
50+
| The SQLite database to use when using the SQLite application manager.
51+
|
52+
*/
5653

57-
/*
58-
|--------------------------------------------------------------------------
59-
| MySql application manager
60-
|--------------------------------------------------------------------------
61-
|
62-
| The MySql database to use when using the MySql application manager.
63-
|
64-
*/
65-
// 'driver' => 'mysql',
66-
// 'host' => 'localhost',
67-
// 'port' => 3306,
68-
// 'database' => 'default',
69-
// 'username' => 'root',
70-
// 'password' => 'root',
54+
'sqlite' => [
55+
'database' => storage_path('laravel-websockets.sqlite'),
7156
],
7257

58+
/*
59+
|--------------------------------------------------------------------------
60+
| MySql application manager
61+
|--------------------------------------------------------------------------
62+
|
63+
| The MySql database to use when using the MySql application manager.
64+
|
65+
*/
66+
67+
'mysql' => [
68+
'host' => 'localhost',
69+
'port' => 3306,
70+
'database' => 'default',
71+
'username' => 'root',
72+
'password' => 'root',
73+
]
7374
],
7475

7576
/*

src/WebSocketsServiceProvider.php

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,9 @@ public function boot()
5050

5151
$this->registerEventLoop();
5252

53-
if (config('websockets.managers.database.driver') === 'sqlite') {
54-
$this->registerSQLiteDatabase();
55-
}
53+
$this->registerSQLiteDatabase();
5654

57-
if (config('websockets.managers.database.driver') === 'mysql') {
58-
$this->registerMySqlDatabase();
59-
}
55+
$this->registerMySqlDatabase();
6056

6157
$this->registerAsyncRedisQueueDriver();
6258

@@ -106,7 +102,7 @@ protected function registerSQLiteDatabase()
106102
$factory = new SQLiteFactory($this->app->make(LoopInterface::class));
107103

108104
$database = $factory->openLazy(
109-
config('websockets.managers.database.database', ':memory:')
105+
config('websockets.managers.sqlite.database', ':memory:')
110106
);
111107

112108
$migrations = (new Finder())
@@ -129,9 +125,9 @@ protected function registerMySqlDatabase()
129125
$this->app->singleton(ConnectionInterface::class, function () {
130126
$factory = new MySQLFactory($this->app->make(LoopInterface::class));
131127

132-
$auth = trim(config('websockets.managers.database.username').':'.config('websockets.managers.database.password'), ':');
133-
$connection = trim(config('websockets.managers.database.host').':'.config('websockets.managers.database.port'), ':');
134-
$database = config('websockets.managers.database.database');
128+
$auth = trim(config('websockets.managers.mysql.username').':'.config('websockets.managers.mysql.password'), ':');
129+
$connection = trim(config('websockets.managers.mysql.host').':'.config('websockets.managers.mysql.port'), ':');
130+
$database = config('websockets.managers.mysql.database');
135131

136132
$database = $factory->createLazyConnection(trim("{$auth}@{$connection}/{$database}", '@'));
137133

0 commit comments

Comments
 (0)