ActivityLogServiceProvider::boot()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 10
nc 2
nop 0
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace LaiVu\ActivityLog;
4
5
use Illuminate\Support\ServiceProvider;
6
use LaiVu\ActivityLog\Commands\CleanActivityLogCommand;
7
8
class ActivityLogServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Perform post-registration booting of services.
12
     *
13
     * @return void
14
     */
15
    public function boot()
16
    {
17
        $this->publishes([
18
            __DIR__.'/../config/activitylog.php' => config_path('activitylog.php'),
19
        ], 'config');
20
21
        $this->mergeConfigFrom(__DIR__.'/../config/activitylog.php', 'activitylog');
22
23
        if (! class_exists('CreateActivityLogTable')) {
24
            $timestamp = date('Y_m_d_His', time());
25
            $this->publishes([
26
                __DIR__.'/../migrations/create_activity_log_table.php.stub' => database_path("/migrations/{$timestamp}_create_activity_log_table.php"),
27
            ], 'migrations');
28
        }
29
    }
30
31
    /**
32
     * Register any package services.
33
     *
34
     * @return void
35
     */
36
    public function register()
37
    {
38
        $this->app->bind(
39
            'activitylog',
40
            ActivityLogger::class
41
        );
42
43
        $this->app->bind('command.activitylog:clean', CleanActivitylogCommand::class);
44
        $this->commands([
45
            'command.activitylog:clean',
46
        ]);
47
    }
48
}