Skip to content

Commit 2159a42

Browse files
authored
Merge pull request #11 from MatviiB/develop
Fix conflicts with core auth routes (L5.5)
2 parents 8d057db + ebc4401 commit 2159a42

File tree

4 files changed

+33
-38
lines changed

4 files changed

+33
-38
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"socketstream"
2626
],
2727
"type": "library",
28-
"version": "v1.2.0",
28+
"version": "v1.2.1",
2929
"license": "MIT",
3030
"authors": [
3131
{

readme.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55
</p>
66

77
### Usage Example
8-
#### Send new values to chart on some page synchronously to each user:
9-
#### `event(new Notify($data, ['chart']));`
10-
#### Or to users with `id` 3 and 5: `event(new Notify($data, ['chart'], [3, 5]));`
8+
Send new values to chart on some page synchronously to each user:
9+
10+
`event(new Notify($data, ['chart']));`
11+
12+
Or to users with `id` 3 and 5: `event(new Notify($data, ['chart'], [3, 5]));`
13+
1114
![laravel socket server](https://gitlab.com/MatviiB/assets/raw/master/ezgif.com-video-to-gif.gif)
1215

1316
### Base concepts

src/Commands/Notifier.php

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22

33
namespace MatviiB\Notifier\Commands;
44

5-
use Cache;
65
use Closure;
6+
77
use Illuminate\Routing\Router;
88
use Illuminate\Console\Command;
9+
use Illuminate\Support\Facades\Cache;
10+
911
use MatviiB\Notifier\SocketServer;
1012

1113
class Notifier extends Command
@@ -52,6 +54,13 @@ class Notifier extends Command
5254
*/
5355
private $headers = ['Method', 'Name', 'Middleware'];
5456

57+
/**
58+
* Available all except Auth routes.
59+
*
60+
* @var array
61+
*/
62+
private $except = ['login', 'register', 'password.request', 'password.reset'];
63+
5564
/**
5665
* Socket connections.
5766
*
@@ -74,28 +83,20 @@ class Notifier extends Command
7483
private $per_users;
7584

7685
/**
77-
* Create a new command instance.
86+
* Execute the console command.
7887
*
7988
* @param \Illuminate\Routing\Router $router
89+
* @param SocketServer $socket
90+
* @return mixed
8091
*/
81-
public function __construct(Router $router)
92+
public function handle(Router $router, SocketServer $socket)
8293
{
83-
parent::__construct();
84-
85-
$this->server = new SocketServer();
94+
$this->server = $socket;
8695
$this->router = $router;
8796
$this->routes = $this->getRoutes();
88-
8997
$this->connects = $this->per_pages = $this->per_users = [];
90-
}
9198

92-
/**
93-
* Execute the console command.
94-
*
95-
* @return mixed
96-
*/
97-
public function handle()
98-
{
99+
99100
if ($this->argument('show')) {
100101
$this->displayRoutes();
101102
}
@@ -243,7 +244,7 @@ private function getRoutes()
243244
}
244245

245246
$name = $route->getName();
246-
if (!$name) {
247+
if (!$name || in_array($name, $this->except)) {
247248
continue;
248249
}
249250

src/NotifierServiceProvider.php

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@
22

33
namespace MatviiB\Notifier;
44

5-
use MatviiB\Notifier\Middleware\InjectConnector;
6-
7-
use App\Http\Kernel;
8-
95
use Illuminate\Support\ServiceProvider;
106
use Illuminate\Contracts\Events\Dispatcher;
117

@@ -20,7 +16,15 @@ class NotifierServiceProvider extends ServiceProvider
2016
*/
2117
public function boot()
2218
{
23-
//
19+
if ($this->app->runningInConsole()) {
20+
$this->commands([
21+
Commands\Notifier::class
22+
]);
23+
24+
$this->publishes([
25+
__DIR__ . '/config/notifier.php' => config_path('notifier.php'),
26+
], 'config');
27+
}
2428
}
2529

2630
/**
@@ -41,18 +45,5 @@ public function register()
4145
}
4246

4347
$this->loadViewsFrom(__DIR__ . '/views', 'notifier');
44-
45-
if ($this->app->runningInConsole()) {
46-
47-
$this->commands([
48-
Commands\Notifier::class,
49-
]);
50-
51-
$this->publishes([
52-
__DIR__ . '/config/notifier.php' => config_path('notifier.php'),
53-
], 'config');
54-
}
55-
56-
5748
}
5849
}

0 commit comments

Comments
 (0)