Completed
Push — main ( a7617a...20a3bd )
by Emmanuel
01:13
created

IncomeExpenseServiceProvider::boot()   B

Complexity

Conditions 7
Paths 3

Size

Total Lines 47

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 47
rs 8.223
c 0
b 0
f 0
cc 7
nc 3
nop 0
1
<?php
2
3
namespace Epmnzava\IncomeExpense;
4
5
use Illuminate\Support\ServiceProvider;
6
7
class IncomeExpenseServiceProvider extends ServiceProvider
8
{
9
    /**
10
     * Bootstrap the application services.
11
     */
12
    public function boot()
13
    {
14
        /*
15
         * Optional methods to load your package assets
16
         */
17
        // $this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'income-expense');
18
        // $this->loadViewsFrom(__DIR__.'/../resources/views', 'income-expense');
19
        // $this->loadMigrationsFrom(__DIR__.'/../database/migrations');
20
        // $this->loadRoutesFrom(__DIR__.'/routes.php');
21
22
        if ($this->app->runningInConsole()) {
23
            $this->publishes([
24
                __DIR__.'/../config/config.php' => config_path('income-expense.php'),
25
            ], 'config');
26
27
28
            if (!class_exists('CreateExpenseCategoryTable') && !class_exists('CreateExpenseTable') && !class_exists('CreateIncomeCategoryTable') && !class_exists('CreateLedgerTable') && !class_exists('CreateIncomeTable')) {
29
                $this->publishes([
30
                    __DIR__ . '/../database/migrations/create_income_category_table.php' => database_path('migrations/' . date('Y_m_d_His', time()) . '_create_income_category_table.php'),
31
                    __DIR__ . '/../database/migrations/create_expense_category_table.php' => database_path('migrations/' . date('Y_m_d_His', time()) . '_create_expense_category_table.php'),
32
                    __DIR__ . '/../database/migrations/create_expense_table.php' => database_path('migrations/' . date('Y_m_d_His', time()) . '_create_expense_table.php'),
33
                    __DIR__ . '/../database/migrations/create_income_table.php' => database_path('migrations/' . date('Y_m_d_His', time()) . '_create_income_table.php')
34
                
35
                ], 'migrations');
36
            }
37
38
39
40
            // Publishing the views.
41
            /*$this->publishes([
42
                __DIR__.'/../resources/views' => resource_path('views/vendor/income-expense'),
43
            ], 'views');*/
44
45
            // Publishing assets.
46
            /*$this->publishes([
47
                __DIR__.'/../resources/assets' => public_path('vendor/income-expense'),
48
            ], 'assets');*/
49
50
            // Publishing the translation files.
51
            /*$this->publishes([
52
                __DIR__.'/../resources/lang' => resource_path('lang/vendor/income-expense'),
53
            ], 'lang');*/
54
55
            // Registering package commands.
56
            // $this->commands([]);
57
        }
58
    }
59
60
    /**
61
     * Register the application services.
62
     */
63
    public function register()
64
    {
65
        // Automatically apply the package configuration
66
        $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'income-expense');
67
68
        // Register the main class to use with the facade
69
        $this->app->singleton('income-expense', function () {
70
            return new IncomeExpense;
71
        });
72
    }
73
}
74