HistoriableModelServiceProvider   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 29 3
A register() 0 10 1
1
<?php
2
3
namespace Iferas93\HistoriableModel;
4
5
use Iferas93\HistoriableModel\Console\Commands\InstallPackage;
6
use Illuminate\Pagination\Paginator;
7
use Illuminate\Support\ServiceProvider;
8
9
class HistoriableModelServiceProvider extends ServiceProvider
10
{
11
    /**
12
     * Bootstrap the application services.
13
     */
14
    public function boot()
15
    {
16
        if ($this->app->runningInConsole()) {
17
            $this->publishes([
18
                __DIR__.'/../config/historiable.php' => config_path('historiable.php'),
19
            ], 'config');
20
21
            $this->commands([
22
                InstallPackage::class,
23
            ]);
24
25
            if (! class_exists('CreateHistoriesTable')) {
26
                $this->publishes([
27
                    __DIR__.'/../src/migrations/create_histories_table.php.stub.php' => database_path('migrations/'.date('Y_m_d_His', time()).'_create_histories_table.php'),
28
                ], 'migrations');
29
            }
30
31
            /*if (!class_exists("History")) {
32
                // Publishing the models.
33
                $this->publishes([
34
                    __DIR__ . '/../src/Models/History.php' => app_path('Models/History.php'),
35
                ], 'models');
36
            }*/
37
        }
38
39
        $this->loadRoutesFrom(__DIR__.'../../routes/web.php');
40
        $this->loadViewsFrom(__DIR__.'/../resources/views', 'historiable');
41
        Paginator::useTailwind();
42
    }
43
44
    /**
45
     * Register the application services.
46
     */
47
    public function register()
48
    {
49
        // Automatically apply the package configuration
50
        $this->mergeConfigFrom(__DIR__.'/../config/historiable.php', 'historiable');
51
52
        // Register the main class to use with the facade
53
        $this->app->bind('historiable', function () {
54
            return new History();
55
        });
56
    }
57
}
58