WalletServiceProvider::boot()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 20
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 12
c 1
b 0
f 0
nc 3
nop 0
dl 0
loc 20
rs 9.8666
1
<?php
2
3
namespace Moecasts\Laravel\Wallet;
4
5
use Illuminate\Support\ServiceProvider;
6
7
class WalletServiceProvider extends ServiceProvider
8
{
9
    public function boot()
10
    {
11
        $this->loadTranslationsFrom(
12
            __DIR__ . '/../resources/lang',
13
            'wallet'
14
        );
15
16
        if (!$this->app->runningInConsole()) {
17
            return;
18
        }
19
20
        if (\function_exists('config_path')) {
21
            $this->publishes([
22
              __DIR__ . '/../config/wallet.php' => config_path('wallet.php')
23
            ], 'wallet-config');
24
        }
25
26
        $this->publishes([
27
            __DIR__ . '/../database/migrations' => database_path('migrations'),
28
        ], 'wallet-migrations');
29
    }
30
31
    public function register()
32
    {
33
        $this->mergeConfigFrom(
34
            \dirname(__DIR__) . '/config/wallet.php',
35
            'wallet'
36
        );
37
38
        // Bind eloquent models to IoC container
39
        $this->app->singleton('moecasts.wallet::transaction', config('wallet.transaction.model'));
40
        $this->app->singleton('moecasts.wallet::transfer', config('wallet.transfer.model'));
41
        $this->app->singleton('moecasts.wallet::wallet', config('wallet.wallet.model'));
42
    }
43
}
44