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 | /** |
||
13 | * Register any application services. |
||
14 | * |
||
15 | * @return void |
||
16 | */ |
||
17 | public function register() |
||
18 | { |
||
19 | // Telescope::night(); |
||
20 | |||
21 | $this->hideSensitiveRequestDetails(); |
||
22 | |||
23 | Telescope::filter(function (IncomingEntry $entry) { |
||
24 | if ($this->app->isLocal()) { |
||
25 | return true; |
||
26 | } |
||
27 | |||
28 | return $entry->isReportableException() || |
||
29 | $entry->isFailedJob() || |
||
30 | $entry->isScheduledTask() || |
||
31 | $entry->hasMonitoredTag(); |
||
32 | }); |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * Prevent sensitive request details from being logged by Telescope. |
||
37 | * |
||
38 | * @return void |
||
39 | */ |
||
40 | protected function hideSensitiveRequestDetails() |
||
41 | { |
||
42 | if ($this->app->isLocal()) { |
||
43 | return; |
||
44 | } |
||
45 | |||
46 | Telescope::hideRequestParameters(['_token']); |
||
47 | |||
48 | Telescope::hideRequestHeaders([ |
||
49 | 'cookie', |
||
50 | 'x-csrf-token', |
||
51 | 'x-xsrf-token', |
||
52 | ]); |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * Register the Telescope gate. |
||
57 | * |
||
58 | * This gate determines who can access Telescope in non-local environments. |
||
59 | * |
||
60 | * @return void |
||
61 | */ |
||
62 | protected function gate() |
||
63 | { |
||
64 | Gate::define('viewTelescope', fn ($user = null) => backpack_user() && backpack_user()->email === config('app.admin_email')); |
||
0 ignored issues
–
show
|
|||
65 | } |
||
66 | } |
||
67 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.