TelescopeServiceProvider   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 26
rs 10
c 0
b 0
f 0
wmc 8

3 Methods

Rating   Name   Duplication   Size   Complexity  
A hideSensitiveRequestDetails() 0 5 2
A register() 0 11 5
A gate() 0 3 1
1
<?php
2
3
namespace App\Providers;
4
5
use Illuminate\Support\Facades\Gate;
6
use Laravel\Telescope\IncomingEntry;
7
use Laravel\Telescope\Telescope;
8
use Laravel\Telescope\TelescopeApplicationServiceProvider;
9
10
class TelescopeServiceProvider extends TelescopeApplicationServiceProvider
11
{
12
    public function register()
13
    {
14
        Telescope::night();
15
16
        $this->hideSensitiveRequestDetails();
17
18
        Telescope::filter(fn (IncomingEntry $entry) => $this->app->isLocal()
19
            || $entry->isReportableException()
20
            || $entry->isFailedJob()
21
            || $entry->isScheduledTask()
22
            || $entry->hasMonitoredTag());
23
    }
24
25
    protected function hideSensitiveRequestDetails()
26
    {
27
        if (! $this->app->isLocal()) {
28
            Telescope::hideRequestParameters(['_token']);
29
            Telescope::hideRequestHeaders(['cookie', 'x-csrf-token', 'x-xsrf-token']);
30
        }
31
    }
32
33
    protected function gate()
34
    {
35
        Gate::define('viewTelescope', fn ($user) => $user?->isAdmin());
36
    }
37
}
38