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

Commit 84ef4ce

Browse files
author
Chaitali Sakhale
committed
Breaking fix for composer update
1 parent 37719bf commit 84ef4ce

File tree

1 file changed

+34
-20
lines changed

1 file changed

+34
-20
lines changed

src/WebSocketsServiceProvider.php

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use BeyondCode\LaravelWebSockets\Statistics\Http\Middleware\Authorize as AuthorizeStatistics;
1414
use BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManager;
1515
use BeyondCode\LaravelWebSockets\WebSockets\Channels\ChannelManagers\ArrayChannelManager;
16+
use Illuminate\Database\QueryException;
1617
use Illuminate\Support\Facades\Gate;
1718
use Illuminate\Support\Facades\Route;
1819
use Illuminate\Support\Facades\Schema;
@@ -23,52 +24,62 @@ class WebSocketsServiceProvider extends ServiceProvider
2324
public function boot()
2425
{
2526
$this->publishes([
26-
__DIR__.'/../config/websockets.php' => base_path('config/websockets.php'),
27+
__DIR__ . '/../config/websockets.php' => base_path('config/websockets.php'),
2728
], 'config');
2829

29-
if (! Schema::hasTable('websockets_statistics_entries')) {
30-
$this->publishes([
31-
__DIR__.'/../database/migrations/create_websockets_statistics_entries_table.php.stub' => database_path('migrations/'.date('Y_m_d_His', time()).'_create_websockets_statistics_entries_table.php'),
32-
], 'migrations');
30+
try {
31+
if (!Schema::hasTable('websockets_statistics_entries')) {
32+
$this->publishes([
33+
__DIR__ . '/../database/migrations/create_websockets_statistics_entries_table.php.stub' => database_path('migrations/' . date('Y_m_d_His', time()) . '_create_websockets_statistics_entries_table.php'),
34+
], 'migrations');
35+
}
36+
37+
$this
38+
->registerRoutes()
39+
->registerDashboardGate();
40+
41+
$this->loadViewsFrom(__DIR__ . '/../resources/views/', 'websockets');
42+
43+
$this->commands([
44+
Console\StartWebSocketServer::class,
45+
Console\CleanStatistics::class,
46+
Console\RestartWebSocketServer::class,
47+
]);
48+
} catch (QueryException $e) {
49+
// Exception raised by composer update
50+
// Usually happens when doing on CI where no DB exists at start
51+
// Either way if DB connection not obtained
52+
// Catching and doing nothing is ignore for composer update
3353
}
34-
35-
$this
36-
->registerRoutes()
37-
->registerDashboardGate();
38-
39-
$this->loadViewsFrom(__DIR__.'/../resources/views/', 'websockets');
40-
41-
$this->commands([
42-
Console\StartWebSocketServer::class,
43-
Console\CleanStatistics::class,
44-
Console\RestartWebSocketServer::class,
45-
]);
4654
}
4755

4856
public function register()
4957
{
50-
$this->mergeConfigFrom(__DIR__.'/../config/websockets.php', 'websockets');
58+
$this->mergeConfigFrom(__DIR__ . '/../config/websockets.php', 'websockets');
5159

5260
$this->app->singleton('websockets.router', function () {
5361
return new Router();
5462
});
5563

5664
$this->app->singleton(ChannelManager::class, function () {
5765
return config('websockets.channel_manager') !== null && class_exists(config('websockets.channel_manager'))
58-
? app(config('websockets.channel_manager')) : new ArrayChannelManager();
66+
? app(config('websockets.channel_manager')) : new ArrayChannelManager();
5967
});
6068

6169
$this->app->singleton(AppProvider::class, function () {
6270
return app(config('websockets.app_provider'));
6371
});
6472
}
6573

74+
/**
75+
* @return mixed
76+
*/
6677
protected function registerRoutes()
6778
{
6879
Route::prefix(config('websockets.path'))->group(function () {
6980
Route::middleware(config('websockets.middleware', [AuthorizeDashboard::class]))->group(function () {
7081
Route::get('/', ShowDashboard::class);
71-
Route::get('/api/{appId}/statistics', [DashboardApiController::class, 'getStatistics']);
82+
Route::get('/api/{appId}/statistics', [DashboardApiController::class, 'getStatistics']);
7283
Route::post('auth', AuthenticateDashboard::class);
7384
Route::post('event', SendMessage::class);
7485
});
@@ -81,6 +92,9 @@ protected function registerRoutes()
8192
return $this;
8293
}
8394

95+
/**
96+
* @return mixed
97+
*/
8498
protected function registerDashboardGate()
8599
{
86100
Gate::define('viewWebSocketsDashboard', function ($user = null) {

0 commit comments

Comments
 (0)