@@ -22,22 +22,21 @@ class WebSocketsServiceProvider extends ServiceProvider
22
22
public function boot ()
23
23
{
24
24
$ this ->publishes ([
25
- __DIR__ . '/../config/websockets.php ' => base_path ('config/websockets.php ' ),
25
+ __DIR__ . '/../config/websockets.php ' => base_path ('config/websockets.php ' ),
26
26
], 'config ' );
27
27
28
- if (! class_exists ('CreateWebSocketsStatisticsEntries ' )) {
28
+ if (!class_exists ('CreateWebSocketsStatisticsEntries ' )) {
29
29
$ 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 ' ),
31
31
], 'migrations ' );
32
32
}
33
33
34
- $ this ->registerRouteMacro ();
34
+ $ this
35
+ ->registerRouteMacro ()
36
+ ->registerStatisticRoute ()
37
+ ->registerDashboardGate ();
35
38
36
- $ this ->registerStatisticRoute ();
37
-
38
- $ this ->registerDashboardGate ();
39
-
40
- $ this ->loadViewsFrom (__DIR__ .'/../resources/views/ ' , 'websockets ' );
39
+ $ this ->loadViewsFrom (__DIR__ . '/../resources/views/ ' , 'websockets ' );
41
40
42
41
$ this ->commands ([
43
42
Console \StartWebSocketServer::class,
@@ -46,44 +45,50 @@ public function boot()
46
45
47
46
public function register ()
48
47
{
49
- $ this ->mergeConfigFrom (__DIR__ . '/../config/websockets.php ' , 'websockets ' );
48
+ $ this ->mergeConfigFrom (__DIR__ . '/../config/websockets.php ' , 'websockets ' );
50
49
51
- $ this ->app ->singleton ('websockets.router ' , function () {
50
+ $ this ->app ->singleton ('websockets.router ' , function () {
52
51
return new Router ();
53
52
});
54
53
55
- $ this ->app ->singleton (ChannelManager::class, function () {
54
+ $ this ->app ->singleton (ChannelManager::class, function () {
56
55
return new ChannelManager ();
57
56
});
58
57
59
- $ this ->app ->singleton (AppProvider::class, function () {
58
+ $ this ->app ->singleton (AppProvider::class, function () {
60
59
return app (config ('websockets.app_provider ' ));
61
60
});
62
61
}
63
62
64
63
protected function registerRouteMacro ()
65
64
{
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 ' );
70
69
Route::post ('auth ' , AuthenticateDashboard::class);
71
70
Route::post ('event ' , SendMessage::class);
72
71
});
73
72
});
73
+
74
+ return $ this ;
74
75
}
75
76
76
77
protected function registerStatisticRoute ()
77
78
{
78
- Route::prefix ('/laravel-websockets ' )->namespace ('\\' )->group (function () {
79
+ Route::prefix ('/laravel-websockets ' )->namespace ('\\' )->group (function () {
79
80
Route::post ('statistics ' , [WebSocketStatisticsEntriesController::class, 'store ' ]);
80
81
});
82
+
83
+ return $ this ;
81
84
}
82
85
83
86
protected function registerDashboardGate ()
84
87
{
85
88
Gate::define ('viewWebSocketsDashboard ' , function ($ user = null ) {
86
89
return app ()->environment ('local ' );
87
90
});
91
+
92
+ return $ this ;
88
93
}
89
94
}
0 commit comments