Level 37
You have to do this in the AppServiceProvider. There in the register method you can check if the environment is production and hide it.
if ($this->app->isLocal()) {
$this->app->register(\Barryvdh\Debugbar\ServiceProvider::class);
}
Similarly you can check if you're on a specific view:
if (! Route::is('some.route', 'another.route')) {
$this->app->register(\Barryvdh\Debugbar\ServiceProvider::class);
}
I'll leave the optimization to you tho ;)