Issues (350)

app/Providers/TelescopeServiceProvider.php (2 issues)

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
The parameter $user is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

64
        Gate::define('viewTelescope', fn (/** @scrutinizer ignore-unused */ $user = null) => backpack_user() && backpack_user()->email === config('app.admin_email'));

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Accessing email on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
65
    }
66
}
67