MasterServiceProvider   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 17
dl 0
loc 42
c 0
b 0
f 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A registerRoutes() 0 4 1
A boot() 0 19 2
A register() 0 9 1
1
<?php
2
3
namespace Turahe\Master;
4
5
use Illuminate\Foundation\Application;
6
use Illuminate\Support\ServiceProvider;
7
use Turahe\Master\Commands\SeedCommand;
8
use Turahe\Master\Commands\SyncCoordinateCommand;
9
10
class MasterServiceProvider extends ServiceProvider
11
{
12
    public function register()
13
    {
14
        $this->app->bind('master', function () {
15
            return new MasterService();
16
        });
17
18
        $this->commands([
19
            SeedCommand::class,
20
            SyncCoordinateCommand::class,
21
        ]);
22
    }
23
24
    /*
25
        for lumen version <=5.2, just copy the migrations from the package directory
26
    */
27
    public function boot()
28
    {
29
        $this->mergeConfigFrom(__DIR__.'/../config/master.php', 'master-data');
30
31
        $databasePath = __DIR__.'/../database/migrations';
32
        $this->loadMigrationsFrom($databasePath);
33
34
        if (class_exists(Application::class)) {
35
            $this->publishes(
36
                [
37
                    __DIR__.'/../config/master.php' => config_path('master-data.php'),
38
                ],
39
                'config'
40
            );
41
        }
42
43
        $this->loadViewsFrom(realpath(__DIR__.'/../resources/views'), 'master');
44
45
        $this->registerRoutes();
46
    }
47
48
    protected function registerRoutes()
49
    {
50
        $router = $this->app['router'];
51
        require __DIR__.'/../routes/web.php';
52
    }
53
}
54