1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Scool\Timetables\Providers; |
4
|
|
|
|
5
|
|
|
use Acacha\Names\Providers\NamesServiceProvider; |
6
|
|
|
use Acacha\Stateful\Providers\StatefulServiceProvider; |
7
|
|
|
use Illuminate\Support\ServiceProvider; |
8
|
|
|
use Scool\Timetables\ScoolTimetables; |
9
|
|
|
use Spatie\Permission\PermissionServiceProvider; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Created by PhpStorm. |
13
|
|
|
* User: alumne |
14
|
|
|
* Date: 22/11/16 |
15
|
|
|
* Time: 17:34 |
16
|
|
|
*/ |
17
|
|
|
class TimetablesServiceProvider extends ServiceProvider |
18
|
|
|
{ |
19
|
|
|
public function register() |
20
|
|
|
{ |
21
|
|
|
if (!defined('SCOOL_TIMETABLES_PATH')) { |
22
|
|
|
define('SCOOL_TIMETABLES_PATH', realpath(__DIR__.'/../../')); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
$this->registerNameServiceProvider(); |
26
|
|
|
$this->registerPermissionServiceProvider(); |
27
|
|
|
$this->registerStatefulEloquentServiceProvider(); |
28
|
|
|
|
29
|
|
|
$this->app->bind(\Scool\Timetables\Repositories\LessonRepository::class, |
30
|
|
|
\Scool\Timetables\Repositories\LessonRepositoryEloquent::class); |
31
|
|
|
//:end-bindings: |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
protected function registerNameServiceProvider() |
35
|
|
|
{ |
36
|
|
|
$this->app->register(NamesServiceProvider::class); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
protected function registerPermissionServiceProvider() |
40
|
|
|
{ |
41
|
|
|
$this->app->register(PermissionServiceProvider::class); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function boot() |
45
|
|
|
{ |
46
|
|
|
$this->defineRoutes(); |
47
|
|
|
$this->loadMigrations(); |
48
|
|
|
$this->loadViews(); |
49
|
|
|
$this->publishFactories(); |
50
|
|
|
$this->publishConfig(); |
51
|
|
|
$this->publishTests(); |
52
|
|
|
$this->publishViews(); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
private function publishTests() |
56
|
|
|
{ |
57
|
|
|
$this->publishes( |
58
|
|
|
[SCOOL_TIMETABLES_PATH.'/tests/TimetablesTest.php' =>'tests/TimetablesTest.php'], |
59
|
|
|
'scool_timetables' |
60
|
|
|
); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Load migrations. |
65
|
|
|
*/ |
66
|
|
|
private function loadMigrations() |
67
|
|
|
{ |
68
|
|
|
$this->loadMigrationsFrom(SCOOL_TIMETABLES_PATH . '/database/migrations'); |
69
|
|
|
} |
70
|
|
|
/** |
71
|
|
|
* Publish factories. |
72
|
|
|
*/ |
73
|
|
|
private function publishFactories() |
74
|
|
|
{ |
75
|
|
|
$this->publishes( |
76
|
|
|
ScoolTimetables::factories(), "scool_timetables" |
77
|
|
|
); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Publish config. |
83
|
|
|
*/ |
84
|
|
|
private function publishConfig() |
85
|
|
|
{ |
86
|
|
|
$this->publishes( |
87
|
|
|
ScoolTimetables::configs(), "scool_timetables" |
88
|
|
|
); |
89
|
|
|
$this->mergeConfigFrom( |
90
|
|
|
SCOOL_TIMETABLES_PATH . '/config/timetables.php', 'scool_timetables' |
91
|
|
|
); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* Define the Timetables routes. |
96
|
|
|
*/ |
97
|
|
|
protected function defineRoutes() |
98
|
|
|
{ |
99
|
|
|
if (!$this->app->routesAreCached()) { |
100
|
|
|
$router = app('router'); |
101
|
|
|
$router->group(['namespace' => 'Scool\Timetables\Http\Controllers'], function () { |
102
|
|
|
require __DIR__.'/../Http/routes.php'; |
103
|
|
|
}); |
104
|
|
|
} |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
private function registerStatefulEloquentServiceProvider() |
108
|
|
|
{ |
109
|
|
|
$this->app->register(StatefulServiceProvider::class); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* Load package views. |
114
|
|
|
*/ |
115
|
|
|
private function loadViews() |
116
|
|
|
{ |
117
|
|
|
$this->loadViewsFrom(SCOOL_TIMETABLES_PATH . '/resources/views', 'timetables'); |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
private function publishViews() |
121
|
|
|
{ |
122
|
|
|
$this->publishes( |
123
|
|
|
[SCOOL_TIMETABLES_PATH.'/resources/views/lessons/index.blade.php' =>'resources/views/vendor/timetables/lessons/index.blade.php'], |
124
|
|
|
'scool_timetables' |
125
|
|
|
); |
126
|
|
|
} |
127
|
|
|
} |
128
|
|
|
|