Skip to content

Commit

Permalink
Add the ability to disable routes
Browse files Browse the repository at this point in the history
  • Loading branch information
KABBOUCHI committed Nov 22, 2019
1 parent 70748f7 commit b634661
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
4 changes: 4 additions & 0 deletions config/nova-impersonate.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
* To inject the 'nova-impersonate::reverse' view in every route when impersonating
*/
'enable_middleware' => true,
/*
* Enable nova routes
*/
'enable_routes' => true,
/*
* false (nova path), true or <url>
*/
Expand Down
24 changes: 14 additions & 10 deletions src/ToolServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,17 @@ class ToolServiceProvider extends ServiceProvider
*/
public function boot()
{
Nova::script('nova-impersonate', __DIR__.'/../dist/js/field.js');
Nova::style('nova-impersonate', __DIR__.'/../dist/css/field.css');
Nova::script('nova-impersonate', __DIR__ . '/../dist/js/field.js');
Nova::style('nova-impersonate', __DIR__ . '/../dist/css/field.css');

$this->loadViewsFrom(__DIR__.'/../resources/views', 'nova-impersonate');
$this->loadViewsFrom(__DIR__ . '/../resources/views', 'nova-impersonate');

$this->publishes([__DIR__.'/../resources/views' => base_path('resources/views/vendor/nova-impersonate'),
$this->publishes([
__DIR__ . '/../resources/views' => base_path('resources/views/vendor/nova-impersonate'),
], 'nova-impersonate-views');

$this->publishes([__DIR__.'/../config/nova-impersonate.php' => config_path('nova-impersonate.php'),
$this->publishes([
__DIR__ . '/../config/nova-impersonate.php' => config_path('nova-impersonate.php'),
], 'nova-impersonate-config');

$this->app->booted(function () {
Expand All @@ -51,10 +53,12 @@ protected function routes()
return;
}

Route::middleware(Arr::wrap(config('nova-impersonate.middleware.base')))
->prefix('nova-impersonate')
->name('nova.impersonate.')
->group(__DIR__.'/../routes/api.php');
if (config('nova-impersonate.enable_routes', true)) {
Route::middleware(Arr::wrap(config('nova-impersonate.middleware.base')))
->prefix('nova-impersonate')
->name('nova.impersonate.')
->group(__DIR__ . '/../routes/api.php');
}
}

/**
Expand All @@ -64,6 +68,6 @@ protected function routes()
*/
public function register()
{
$this->mergeConfigFrom(__DIR__.'/../config/nova-impersonate.php', 'nova-impersonate');
$this->mergeConfigFrom(__DIR__ . '/../config/nova-impersonate.php', 'nova-impersonate');
}
}

0 comments on commit b634661

Please sign in to comment.