Skip to content

Commit 1e64211

Browse files
committed
Rearranging service provider
1 parent c65a97e commit 1e64211

File tree

1 file changed

+9
-21
lines changed

1 file changed

+9
-21
lines changed

src/ServiceProvider.php

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Georgeboot\LaravelEchoApiGateway;
44

55
use Georgeboot\LaravelEchoApiGateway\Commands\VaporHandle;
6-
use Illuminate\Broadcasting\Broadcasters\Broadcaster;
76
use Illuminate\Broadcasting\BroadcastManager;
87
use Illuminate\Support\Facades\Config;
98
use Illuminate\Support\ServiceProvider as LaravelServiceProvider;
@@ -20,33 +19,22 @@ public function register()
2019
'driver' => 'laravel-echo-api-gateway',
2120
]);
2221

23-
if ($this->app->runningInConsole()) {
24-
$this->publishes([
25-
__DIR__ . '/../config/laravel-echo-api-gateway.php' => config_path('laravel-echo-api-gateway.php'),
26-
], 'laravel-echo-api-gateway-config');
27-
}
28-
29-
$this->app->bind(ConnectionRepository::class, function () {
30-
return new ConnectionRepository(
31-
config('laravel-echo-api-gateway')
32-
);
33-
});
34-
35-
$this->app->bind(SubscriptionRepository::class, function () {
36-
return new SubscriptionRepository(
37-
config('laravel-echo-api-gateway')
38-
);
39-
});
22+
$config = config('laravel-echo-api-gateway');
23+
24+
$this->app->bind(ConnectionRepository::class, fn () => new ConnectionRepository($config));
25+
$this->app->bind(SubscriptionRepository::class, fn () => new SubscriptionRepository($config));
4026
}
4127

4228
public function boot(BroadcastManager $broadcastManager): void
4329
{
44-
$broadcastManager->extend('laravel-echo-api-gateway', function (): Broadcaster {
45-
return $this->app->make(Driver::class);
46-
});
30+
$broadcastManager->extend('laravel-echo-api-gateway', fn () => $this->app->make(Driver::class));
4731

4832
$this->commands([
4933
VaporHandle::class,
5034
]);
35+
36+
$this->publishes([
37+
__DIR__ . '/../config/laravel-echo-api-gateway.php' => config_path('laravel-echo-api-gateway.php'),
38+
], 'laravel-echo-api-gateway-config');
5139
}
5240
}

0 commit comments

Comments
 (0)