Passed
Push — master ( f51c1b...16736d )
by Arthur
05:36
created

TelescopeServiceProvider::gate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Foundation\Providers;
4
5
use Laravel\Telescope\Telescope;
6
use Illuminate\Support\Facades\Gate;
7
use Laravel\Telescope\IncomingEntry;
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
        Telescope::filter(function (IncomingEntry $entry) {
22
            if ($this->app->environment('local')) {
23
                return true;
24
            }
25
26
            return $entry->isReportableException() ||
27
                   $entry->isFailedJob() ||
28
                   $entry->isScheduledTask() ||
29
                   $entry->hasMonitoredTag();
30
        });
31
    }
32
33
    /**
34
     * Register the Telescope gate.
35
     *
36
     * This gate determines who can access Telescope in non-local environments.
37
     *
38
     * @return void
39
     */
40
    protected function gate()
41
    {
42
        Gate::define('viewTelescope', function ($user) {
43
            return in_array($user->email, [
44
                //
45
            ]);
46
        });
47
    }
48
}
49