Completed
Push — master ( 8f2e40...7dcc71 )
by wen
02:45
created

LaravelServiceProvider   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 39
rs 10
c 1
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 10 2
A register() 0 6 1
A publishConfig() 0 6 1
1
<?php
2
3
4
namespace Sco\ActionLog;
5
6
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
7
use Sco\ActionLog\Events\ModelCreatedEvent;
8
use Sco\ActionLog\Events\ModelUpdatedEvent;
9
use Sco\ActionLog\Events\ModelUpdatingEvent;
10
use Sco\ActionLog\Listeners\SaveActionLog;
11
12
class LaravelServiceProvider extends ServiceProvider
13
{
14
    protected $listen = [
15
        ModelCreatedEvent::class  => [
16
            SaveActionLog::class,
17
        ],
18
        ModelUpdatingEvent::class => [
19
            SaveActionLog::class,
20
        ],
21
        ModelUpdatedEvent::class  => [
22
            SaveActionLog::class,
23
        ],
24
    ];
25
26
    public function boot()
27
    {
28
        parent::boot();
29
30
        if ($this->app->runningInConsole()) {
31
            $this->loadMigrationsFrom(__DIR__ . '/../database/migrations');
32
            $this->publishConfig();
33
        }
34
35
    }
36
37
    public function register()
38
    {
39
        $this->app->singleton('actionlog', function () {
40
            
41
        });
42
    }
43
44
    private function publishConfig()
45
    {
46
        $this->publishes([
47
            __DIR__ . '/../config/actionlog.php' => config_path('actionlog.php'),
48
        ], 'config');
49
    }
50
}
51