Completed
Push — main ( 68334c...8a5ea4 )
by Emmanuel
01:14
created

IncomeExpenseServiceProvider::boot()   B

Complexity

Conditions 7
Paths 3

Size

Total Lines 49

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 49
rs 8.1793
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
                    __DIR__ . '/../database/migrations/create_ledger_table.php' => database_path('migrations/' . date('Y_m_d_His', time()) . '_create_ledger_table.php')
35
36
                
37
                ], 'migrations');
38
            }
39
40
41
42
            // Publishing the views.
43
            /*$this->publishes([
44
                __DIR__.'/../resources/views' => resource_path('views/vendor/income-expense'),
45
            ], 'views');*/
46
47
            // Publishing assets.
48
            /*$this->publishes([
49
                __DIR__.'/../resources/assets' => public_path('vendor/income-expense'),
50
            ], 'assets');*/
51
52
            // Publishing the translation files.
53
            /*$this->publishes([
54
                __DIR__.'/../resources/lang' => resource_path('lang/vendor/income-expense'),
55
            ], 'lang');*/
56
57
            // Registering package commands.
58
            // $this->commands([]);
59
        }
60
    }
61
62
    /**
63
     * Register the application services.
64
     */
65
    public function register()
66
    {
67
        // Automatically apply the package configuration
68
        $this->mergeConfigFrom(__DIR__.'/../config/config.php', 'income-expense');
69
70
        // Register the main class to use with the facade
71
        $this->app->singleton('income-expense', function () {
72
            return new IncomeExpense;
73
        });
74
    }
75
}
76