Created
February 18, 2019 20:33
-
-
Save nissicreative/1c0175192801123c71b8a87ac5d2ee06 to your computer and use it in GitHub Desktop.
Laravel TelescopeServiceProvider
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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