Completed
Push — master ( f425bf...6f685c )
by Manu
03:14 queued 01:07
created

InventoryServiceProvider::loadMigrations()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 3
Bugs 1 Features 0
Metric Value
c 3
b 1
f 0
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Scool\Inventory\Providers;
4
5
use Acacha\Names\Providers\NamesServiceProvider;
6
use Illuminate\Support\ServiceProvider;
7
use Acacha\Stateful\Providers\StatatefulServiceProvider;
8
use Scool\Inventory\ScoolInventory;
9
10
/**
11
 * Class InventoryServiceProvider.
12
 */
13
class InventoryServiceProvider extends ServiceProvider
14
{
15
    /**
16
     * Register package services.
17
     */
18
    public function register()
19
    {
20
        if (!defined('SCOOL_INVENTORY_PATH')) {
21
            define('SCOOL_INVENTORY_PATH', realpath(__DIR__.'/../../'));
22
        }
23
        $this->app->register(NamesServiceProvider::class);
24
        $this->app->bind(\Scool\Inventory\Repositories\StudyRepository::class, \Scool\Inventory\Repositories\StudyRepositoryEloquent::class);
25
        $this->app->bind(StatsRepositoryInterface::class,function() {
26
            return new CacheableStatsRepository(new StatsRepository());
27
        });
28
    }
29
    /**
30
     * Bootstrap package services.
31
     *
32
     * @return void
33
     */
34
    public function boot()
35
    {
36
        $this->defineRoutes();
37
        $this->loadMigrations();
38
        $this->publishFactories();
39
        $this->publishConfig();
40
        $this->publishTests();
41
    }
42
    /**
43
     * Load migrations.
44
     */
45
    private function loadMigrations()
46
    {
47
        $this->loadMigrationsFrom(SCOOL_INVENTORY_PATH.'/database/migrations');
48
    }
49
    /**
50
     * Publish factories.
51
     */
52
    private function publishFactories()
53
    {
54
        $this->publishes(
55
            ScoolInventory::factories(), 'scool_inventory'
56
        );
57
    }
58
    /**
59
     * Publish config.
60
     */
61
    private function publishConfig()
62
    {
63
        $this->publishes(
64
            ScoolInventory::configs(), 'scool_inventory'
65
        );
66
        $this->mergeConfigFrom(
67
            SCOOL_INVENTORY_PATH.'/config/inventory.php', 'scool_inventory'
68
        );
69
    }
70
    private function publishTests()
71
    {
72
        $this->publishes(
73
            [SCOOL_INVENTORY_PATH.'/tests/InventoryTest.php' => 'tests/InventoryTest.php'],
74
75
            'scool_inventory'
76
77
        );
78
    }
79
80
    protected function defineRoutes()
81
    {
82
        if (!$this->app->routesAreCached()) {
83
            $router = app('router');
84
            $router->group(['namespace' => 'Scool\Inventory\Http\Controllers'], function () {
85
            require __DIR__.'/../Http/routes.php';
86
            });
87
        }
88
    }
89
90
    private function registerStatefulEloquentServiceProvider()
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
91
    {
92
        $this->app->register(StatefulServiceProvider::class);
93
    }
94
}
95