LaravelCardsServiceProvider   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 4
Bugs 0 Features 3
Metric Value
eloc 27
c 4
b 0
f 3
dl 0
loc 67
ccs 28
cts 28
cp 1
rs 10
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 45 4
A register() 0 8 1
1
<?php
2
3
namespace DavideCasiraghi\LaravelCards;
4
5
use Carbon\Carbon;
6
use Illuminate\Support\ServiceProvider;
7
8
class LaravelCardsServiceProvider extends ServiceProvider
9
{
10
    /**
11
     * Bootstrap the application services.
12
     */
13 18
    public function boot()
14
    {
15
        /*
16
         * Optional methods to load your package assets
17
         */
18 18
        $this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'laravel-cards');
19 18
        $this->loadViewsFrom(__DIR__.'/../resources/views', 'laravel-cards');
20 18
        $this->loadMigrationsFrom(__DIR__.'/../database/migrations');
21 18
        $this->loadRoutesFrom(__DIR__.'/../routes/web.php');
22 18
        $this->app['router']->aliasMiddleware('admin', \DavideCasiraghi\LaravelCards\Http\Middleware\Admin::class);
23
24 18
        if (! class_exists('CreateCardsTable')) {
25 1
            $this->publishes([
26 1
                __DIR__.'/../database/migrations/create_cards_table.php.stub' => database_path('migrations/'.Carbon::now()->format('Y_m_d_Hmsu').'_create_cards_table.php'),
27 1
            ], 'migrations');
28
        }
29 18
        if (! class_exists('CreateCardTranslationsTable')) {
30 1
            $this->publishes([
31 1
                __DIR__.'/../database/migrations/create_card_translations_table.php.stub' => database_path('migrations/'.Carbon::now()->format('Y_m_d_Hmsu').'_create_card_translations_table.php'),
32 1
            ], 'migrations');
33
        }
34
35 18
        if ($this->app->runningInConsole()) {
36 18
            $this->publishes([
37 18
                __DIR__.'/../config/config.php' => config_path('laravel-cards.php'),
38 18
            ], 'config');
39
40 18
            $this->publishes([
41 18
                __DIR__.'/../resources/assets/sass' => resource_path('sass/vendor/laravel-cards/'),
42 18
            ], 'sass');
43
44
            // Publishing the views.
45
            /*$this->publishes([
46
                __DIR__.'/../resources/views' => resource_path('views/vendor/laravel-cards'),
47
            ], 'views');*/
48
49
            // Publishing assets.
50
            /*$this->publishes([
51
                __DIR__.'/../resources/assets' => public_path('vendor/laravel-cards'),
52
            ], 'assets');*/
53
54
            // Publishing the translation files.
55 18
            $this->publishes([
56 18
                __DIR__.'/../resources/lang' => resource_path('lang/vendor/laravel-cards'),
57 18
            ], 'lang');
58
59
            // Registering package commands.
60
            // $this->commands([]);
61
        }
62 18
    }
63
64
    /**
65
     * Register the application services.
66
     */
67 18
    public function register()
68
    {
69
        // Automatically apply the package configuration
70 18
        $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'laravel-cards');
71
72
        // Register the main class to use with the facade
73
        $this->app->singleton('laravel-cards', function () {
74 7
            return new LaravelCards;
75 18
        });
76 18
    }
77
}
78