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

Commit e738d30

Browse files
committed
wip
1 parent fd2203c commit e738d30

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

src/WebSocketsServiceProvider.php

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,21 @@ class WebSocketsServiceProvider extends ServiceProvider
2222
public function boot()
2323
{
2424
$this->publishes([
25-
__DIR__.'/../config/websockets.php' => base_path('config/websockets.php'),
25+
__DIR__ . '/../config/websockets.php' => base_path('config/websockets.php'),
2626
], 'config');
2727

28-
if (! class_exists('CreateWebSocketsStatisticsEntries')) {
28+
if (!class_exists('CreateWebSocketsStatisticsEntries')) {
2929
$this->publishes([
30-
__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'),
30+
__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'),
3131
], 'migrations');
3232
}
3333

34-
$this->registerRouteMacro();
34+
$this
35+
->registerRouteMacro()
36+
->registerStatisticRoute()
37+
->registerDashboardGate();
3538

36-
$this->registerStatisticRoute();
37-
38-
$this->registerDashboardGate();
39-
40-
$this->loadViewsFrom(__DIR__.'/../resources/views/', 'websockets');
39+
$this->loadViewsFrom(__DIR__ . '/../resources/views/', 'websockets');
4140

4241
$this->commands([
4342
Console\StartWebSocketServer::class,
@@ -46,44 +45,50 @@ public function boot()
4645

4746
public function register()
4847
{
49-
$this->mergeConfigFrom(__DIR__.'/../config/websockets.php', 'websockets');
48+
$this->mergeConfigFrom(__DIR__ . '/../config/websockets.php', 'websockets');
5049

51-
$this->app->singleton('websockets.router', function() {
50+
$this->app->singleton('websockets.router', function () {
5251
return new Router();
5352
});
5453

55-
$this->app->singleton(ChannelManager::class, function() {
54+
$this->app->singleton(ChannelManager::class, function () {
5655
return new ChannelManager();
5756
});
5857

59-
$this->app->singleton(AppProvider::class, function() {
58+
$this->app->singleton(AppProvider::class, function () {
6059
return app(config('websockets.app_provider'));
6160
});
6261
}
6362

6463
protected function registerRouteMacro()
6564
{
66-
Route::macro('webSockets', function($prefix = 'laravel-websockets') {
67-
Route::prefix($prefix)->namespace('\\')->middleware(Authorize::class)->group(function() {
68-
Route::get('/', ShowDashboard::class);
69-
Route::get('/api/{appId}/statistics', DashboardApiController::class.'@getStatistics');
65+
Route::macro('webSockets', function ($prefix = 'laravel-websockets') {
66+
Route::prefix($prefix)->namespace('\\')->middleware(Authorize::class)->group(function () {
67+
Route::get('/', ShowDashboard::class);
68+
Route::get('/api/{appId}/statistics', DashboardApiController::class . '@getStatistics');
7069
Route::post('auth', AuthenticateDashboard::class);
7170
Route::post('event', SendMessage::class);
7271
});
7372
});
73+
74+
return $this;
7475
}
7576

7677
protected function registerStatisticRoute()
7778
{
78-
Route::prefix('/laravel-websockets')->namespace('\\')->group(function() {
79+
Route::prefix('/laravel-websockets')->namespace('\\')->group(function () {
7980
Route::post('statistics', [WebSocketStatisticsEntriesController::class, 'store']);
8081
});
82+
83+
return $this;
8184
}
8285

8386
protected function registerDashboardGate()
8487
{
8588
Gate::define('viewWebSocketsDashboard', function ($user = null) {
8689
return app()->environment('local');
8790
});
91+
92+
return $this;
8893
}
8994
}

0 commit comments

Comments
 (0)