Completed
Push — main ( 749ed9...26a1a5 )
by Emmanuel
05:22
created

BillMeServiceProvider   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 3
dl 0
loc 70
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B boot() 0 50 7
A register() 0 10 1
1
<?php
2
3
/**
4
 * Author: Emmanuel Paul Mnzava
5
 * Twitter: @epmnzava
6
 * Github:https://github.com/dbrax/tigopesa-tanzania
7
 * Email: [email protected]
8
 * 
9
 */
10
11
namespace Epmnzava\BillMe;
12
13
use Illuminate\Support\ServiceProvider;
14
15
class BillMeServiceProvider extends ServiceProvider
16
{
17
    /**
18
     * Bootstrap the application services.
19
     */
20
    public function boot()
21
    {
22
        /*
23
         * Optional methods to load your package assets
24
         */
25
        // $this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'bill-me');
26
        // $this->loadViewsFrom(__DIR__.'/../resources/views', 'bill-me');
27
        // $this->loadMigrationsFrom(__DIR__.'/../database/migrations');
28
        // $this->loadRoutesFrom(__DIR__.'/routes.php');
29
30
        if ($this->app->runningInConsole()) {
31
            $this->publishes([
32
                __DIR__ . '/../config/config.php' => config_path('bill-me.php'),
33
            ], 'config');
34
35
36
           //publishing migrations here..
37
        if (! class_exists('CreateOrdersTable') && ! class_exists('CreateOrderItemsTable') && ! class_exists('CreateInvoicesTable') && ! class_exists('CreatePaymentMethodTable') && ! class_exists('CreatePaymentsTable')) {
38
                $this->publishes([
39
                  __DIR__ . '/../database/migrations/create_orders_table.php.stub' => database_path('migrations/' . date('Y_m_d_His', time()) . '_create_orders_table.php'),
40
                  __DIR__ . '/../database/migrations/create_order_items_table.php.stub' => database_path('migrations/' . date('Y_m_d_His', time()) . '_create_order_items_table.php'),
41
                  __DIR__ . '/../database/migrations/create_invoices_table.php.stub' => database_path('migrations/' . date('Y_m_d_His', time()) . '_create_invoices_table.php'),
42
                  __DIR__ . '/../database/migrations/create_payment_method_table.php.stub' => database_path('migrations/' . date('Y_m_d_His', time()) . '_create_payment_method_table.php'),
43
                  __DIR__ . '/../database/migrations/create_payments_table.php.stub' => database_path('migrations/' . date('Y_m_d_His', time()) . '_create_payments_table.php'),
44
45
                ], 'migrations');
46
              }
47
48
        
49
50
51
            // Publishing the views.
52
            /*$this->publishes([
53
                __DIR__.'/../resources/views' => resource_path('views/vendor/bill-me'),
54
            ], 'views');*/
55
56
            // Publishing assets.
57
            /*$this->publishes([
58
                __DIR__.'/../resources/assets' => public_path('vendor/bill-me'),
59
            ], 'assets');*/
60
61
            // Publishing the translation files.
62
            /*$this->publishes([
63
                __DIR__.'/../resources/lang' => resource_path('lang/vendor/bill-me'),
64
            ], 'lang');*/
65
66
            // Registering package commands.
67
            // $this->commands([]);
68
        }
69
    }
70
71
    /**
72
     * Register the application services.
73
     */
74
    public function register()
75
    {
76
        // Automatically apply the package configuration
77
        $this->mergeConfigFrom(__DIR__ . '/../config/config.php', 'bill-me');
78
79
        // Register the main class to use with the facade
80
        $this->app->singleton('bill-me', function () {
81
            return new BillMe;
82
        });
83
    }
84
}
85