AppServiceProvider::boot()   A
last analyzed

Complexity

Conditions 3
Paths 1

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 7
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 14
rs 10
1
<?php
2
3
namespace App\Providers;
4
5
use App\Models\Script;
6
use App\Observers\ScriptObserver;
7
use App\Observers\SettingObserver;
8
use App\Setting;
9
use Gate;
10
use Illuminate\Support\Facades\Schema;
11
use Illuminate\Support\ServiceProvider;
12
13
class AppServiceProvider extends ServiceProvider
14
{
15
    /**
16
     * Register any application services.
17
     *
18
     * @return void
19
     */
20
    public function register()
21
    {
22
        //
23
    }
24
25
    /**
26
     * Bootstrap any application services.
27
     *
28
     * @return void
29
     */
30
    public function boot()
31
    {
32
        Schema::defaultStringLength(191);
33
34
        //Observers
35
        Script::observe(ScriptObserver::class);
36
        Setting::observe(SettingObserver::class);
37
38
        Gate::define('admin-only', function ($user) {
39
            if ($user->isAdmin() || $user->isModerator()) {
40
                return true;
41
            }
42
43
            return false;
44
        });
45
    }
46
}
47