Completed
Push — master ( 0e0e56...2367a7 )
by Pavel
05:22
created

register()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 0
nc 1
nop 0
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace PavelMironchik\LaravelBackupPanel;
4
5
use Illuminate\Support\Facades\Gate;
6
use Illuminate\Support\ServiceProvider;
7
8
class LaravelBackupPanelApplicationServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Bootstrap any application services.
12
     *
13
     * @return void
14
     */
15
    public function boot()
16
    {
17
        $this->configureAuthorization();
18
    }
19
20
    /**
21
     * Configure the Laravel Backup Panel authorization services.
22
     *
23
     * @return void
24
     */
25
    protected function configureAuthorization()
26
    {
27
        $this->gate();
28
29
        LaravelBackupPanel::auth(function ($request) {
30
            return app()->environment('local') ||
0 ignored issues
show
introduced by
The method environment() does not exist on Illuminate\Container\Container. Are you sure you never get this type here, but always one of the subclasses? ( Ignorable by Annotation )

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

30
            return app()->/** @scrutinizer ignore-call */ environment('local') ||
Loading history...
31
                   Gate::check('viewLaravelBackupPanel', [$request->user()]);
32
        });
33
    }
34
35
    /**
36
     * Register the Laravel Backup Panel gate.
37
     *
38
     * This gate determines who can access Laravel Backup Panel in non-local environments.
39
     *
40
     * @return void
41
     */
42
    protected function gate()
43
    {
44
        Gate::define('viewLaravelBackupPanel', function ($user) {
45
            return in_array($user->email, [
46
                // '[email protected]'
47
            ]);
48
        });
49
    }
50
51
    /**
52
     * Register any application services.
53
     *
54
     * @return void
55
     */
56
    public function register()
57
    {
58
        //
59
    }
60
}
61