AuthServiceProvider::boot()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.2559

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 1
nop 0
dl 0
loc 8
ccs 3
cts 5
cp 0.6
crap 2.2559
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Providers;
4
5
use App\Models\User;
6
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
7
use Illuminate\Support\Facades\Gate;
8
9
class AuthServiceProvider extends ServiceProvider
10
{
11
    /**
12
     * The policy mappings for the application.
13
     *
14
     * @var array
15
     */
16
    protected $policies = [
17
        // 'App\Models\Model' => 'App\Policies\ModelPolicy',
18
    ];
19
20
    /**
21
     * Register any authentication / authorization services.
22
     *
23
     * @return void
24
     */
25 118
    public function boot()
26
    {
27 118
        $this->registerPolicies();
28
29
        // Give the admin full authorization to this resource
30 118
        Gate::before(function (User $user){
31
            if($user->isAdmin()){
32
                return true;
33
            }
34 118
        });
35 118
    }
36
}
37