Skip to content

Instantly share code, notes, and snippets.

@nissicreative
Created February 18, 2019 20:33
Show Gist options
  • Save nissicreative/1c0175192801123c71b8a87ac5d2ee06 to your computer and use it in GitHub Desktop.
Save nissicreative/1c0175192801123c71b8a87ac5d2ee06 to your computer and use it in GitHub Desktop.
Laravel TelescopeServiceProvider
<?php
namespace App\Providers;
use Laravel\Telescope\EntryType;
use Laravel\Telescope\Telescope;
use Illuminate\Support\Facades\Gate;
use Laravel\Telescope\IncomingEntry;
use Laravel\Telescope\TelescopeApplicationServiceProvider;
class TelescopeServiceProvider extends TelescopeApplicationServiceProvider
{
/**
* Register any application services.
*
* @return void
*/
public function register()
{
Telescope::night();
Telescope::filter(function (IncomingEntry $entry) {
if ($entry->type === EntryType::REQUEST
&& isset($entry->content['uri'])
&& str_contains($entry->content['uri'], 'debugbar')) {
return false;
}
if ($this->app->environment('local')) {
return true;
}
return true;
return $entry->isReportableException() ||
$entry->isFailedJob() ||
$entry->isScheduledTask() ||
$entry->hasMonitoredTag();
});
}
/**
* Register the Telescope gate.
*
* This gate determines who can access Telescope in non-local environments.
*
* @return void
*/
protected function gate()
{
Gate::define('viewTelescope', function ($user) {
return $user->isSysAdmin();
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment