SimpleRolesServiceProvider::boot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 1.0002

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 21
ccs 14
cts 15
cp 0.9333
rs 9.3142
cc 1
eloc 13
nc 1
nop 0
crap 1.0002
1
<?php
2
3
namespace Merodiro\SimpleRoles;
4
5
use Illuminate\Support\ServiceProvider;
6
use Illuminate\Support\Facades\Blade;
7
use Illuminate\Support\Facades\Auth;
8
9
class SimpleRolesServiceProvider extends ServiceProvider
10
{
11
    /**
12
     * Perform post-registration booting of services.
13
     *
14
     * @return void
15
     */
16 10
    public function boot()
17
    {
18 10
        $this->publishes([
19 10
            __DIR__ . '/migrations/' => database_path('migrations')
20 10
        ], 'migrations');
21
22 10
        $this->publishes([
23 10
            __DIR__.'/config/simple_roles.php' => config_path('simple_roles.php'),
24 10
        ], 'config');
25
26 10
        $this->loadMigrationsFrom(__DIR__ . '/migrations');
27
28 10
        $this->mergeConfigFrom(
29 10
            __DIR__.'/config/simple_roles.php',
30 10
            'simple_roles'
31
        );
32
33 10
        Blade::if('role', function ($role) {
34
            return optional(Auth::user())->hasRole($role);
35 10
        });
36 10
    }
37
38
    /**
39
     * Register any package services.
40
     *
41
     * @return void
42
     */
43 10
    public function register()
44
    {
45
        //
46 10
    }
47
}
48