Skip to content

Commit 889bb44

Browse files
authored
Allow ignoring route registration (#80)
Signed-off-by: Tobias Oitzinger <[email protected]>
1 parent 3d88255 commit 889bb44

File tree

2 files changed

+34
-9
lines changed

2 files changed

+34
-9
lines changed

src/Pulse.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ class Pulse
8282
*/
8383
protected bool $runsMigrations = true;
8484

85+
/**
86+
* Indicates if Pulse routes will be registered.
87+
*/
88+
protected bool $registersRoutes = true;
89+
8590
/**
8691
* Handle exceptions using the given callback.
8792
*
@@ -469,6 +474,24 @@ public function ignoreMigrations(): self
469474
return $this;
470475
}
471476

477+
/**
478+
* Determine if Pulse may register routes.
479+
*/
480+
public function registersRoutes(): bool
481+
{
482+
return $this->registersRoutes;
483+
}
484+
485+
/**
486+
* Configure Pulse to not register its routes.
487+
*/
488+
public function ignoreRoutes(): self
489+
{
490+
$this->registersRoutes = false;
491+
492+
return $this;
493+
}
494+
472495
/**
473496
* Handle exceptions using the given callback.
474497
*

src/PulseServiceProvider.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,17 @@ protected function registerAuthorization(): void
9696
protected function registerRoutes(): void
9797
{
9898
$this->callAfterResolving('router', function (Router $router, Application $app) {
99-
$router->group([
100-
'domain' => $app->make('config')->get('pulse.domain', null),
101-
'prefix' => $app->make('config')->get('pulse.path'),
102-
'middleware' => $app->make('config')->get('pulse.middleware', 'web'),
103-
], function (Router $router) {
104-
$router->get('/', function (Pulse $pulse, ViewFactory $view) {
105-
return $view->make('pulse::dashboard');
106-
})->name('pulse');
107-
});
99+
if ($app->make(Pulse::class)->registersRoutes()) {
100+
$router->group([
101+
'domain' => $app->make('config')->get('pulse.domain', null),
102+
'prefix' => $app->make('config')->get('pulse.path'),
103+
'middleware' => $app->make('config')->get('pulse.middleware', 'web'),
104+
], function (Router $router) {
105+
$router->get('/', function (Pulse $pulse, ViewFactory $view) {
106+
return $view->make('pulse::dashboard');
107+
})->name('pulse');
108+
});
109+
}
108110
});
109111
}
110112

0 commit comments

Comments
 (0)