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() |
|
|
|
|
91
|
|
|
{ |
92
|
|
|
$this->app->register(StatefulServiceProvider::class); |
93
|
|
|
} |
94
|
|
|
} |
95
|
|
|
|