HistoriableModelServiceProvider::boot()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 29

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 29
rs 9.456
c 0
b 0
f 0
cc 3
nc 3
nop 0
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