LaravelBackupPanelApplicationServiceProvider   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 50
rs 10
c 0
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A gate() 0 4 1
A configureAuthorization() 0 7 2
A register() 0 2 1
A boot() 0 3 1
1
<?php
2
3
namespace PavelMironchik\LaravelBackupPanel;
4
5
use Illuminate\Support\Facades\App;
6
use Illuminate\Support\Facades\Gate;
7
use Illuminate\Support\ServiceProvider;
8
9
class LaravelBackupPanelApplicationServiceProvider extends ServiceProvider
10
{
11
    /**
12
     * Bootstrap any application services.
13
     *
14
     * @return void
15
     */
16
    public function boot()
17
    {
18
        $this->configureAuthorization();
19
    }
20
21
    /**
22
     * Configure the Laravel Backup Panel authorization services.
23
     *
24
     * @return void
25
     */
26
    protected function configureAuthorization()
27
    {
28
        $this->gate();
29
30
        LaravelBackupPanel::auth(function ($request) {
31
            return App::environment('local') ||
32
                   Gate::check('viewLaravelBackupPanel', [$request->user()]);
33
        });
34
    }
35
36
    /**
37
     * Register the Laravel Backup Panel gate.
38
     *
39
     * This gate determines who can access Laravel Backup Panel in non-local environments.
40
     *
41
     * @return void
42
     */
43
    protected function gate()
44
    {
45
        Gate::define('viewLaravelBackupPanel', function ($user) {
46
            return in_array($user->email, [
47
                // '[email protected]'
48
            ]);
49
        });
50
    }
51
52
    /**
53
     * Register any application services.
54
     *
55
     * @return void
56
     */
57
    public function register()
58
    {
59
        //
60
    }
61
}
62