MultilingualServiceProvider::boot()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 8
rs 10
1
<?php
2
3
namespace mindtwo\LaravelMultilingual\Providers;
4
5
use Illuminate\Support\Facades\View;
6
use Illuminate\Support\ServiceProvider;
7
use mindtwo\LaravelMultilingual\Services\Locale;
8
9
class MultilingualServiceProvider extends ServiceProvider
10
{
11
    /**
12
     * Bootstrap the application services.
13
     *
14
     * @return void
15
     */
16
    public function boot()
17
    {
18
        if ($this->app->runningInConsole()) {
19
            $this->registerPublishing();
20
            $this->loadMigrationsFrom(__DIR__.'/../../migrations');
21
        }
22
23
        View::share('locale', $this->app->make(Locale::class));
24
    }
25
26
    /**
27
     * Register the application services.
28
     *
29
     * @return void
30
     */
31
    public function register()
32
    {
33
        $this->mergeConfigFrom(__DIR__.'/../../config/config.php', 'laravel-multilingual');
34
    }
35
36
    /**
37
     * Register the package's publishable resources.
38
     *
39
     * @return void
40
     */
41
    protected function registerPublishing()
42
    {
43
        $this->publishes([
44
            __DIR__.'/../../config/config.php' => config_path('laravel-multilingual.php'),
45
        ], 'laravel-multilingual-config');
46
        $this->publishes([
47
            __DIR__.'/../../migrations' => database_path('migrations'),
48
        ], 'laravel-multilingual-migrations');
49
    }
50
}
51