|
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\AttendanceRepository::class, \Scool\Timetables\Repositories\AttendanceRepositoryEloquent::class); |
|
30
|
|
|
$this->app->bind(\Scool\Timetables\Repositories\DesiratumRepository::class, \Scool\Timetables\Repositories\DesiratumRepositoryEloquent::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
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
private function publishTests() |
|
55
|
|
|
{ |
|
56
|
|
|
$this->publishes( |
|
57
|
|
|
[SCOOL_TIMETABLES_PATH.'/tests/TimetablesTest.php' =>'tests/TimetablesTest.php'], |
|
58
|
|
|
'scool_timetables' |
|
59
|
|
|
); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Load migrations. |
|
64
|
|
|
*/ |
|
65
|
|
|
private function loadMigrations() |
|
66
|
|
|
{ |
|
67
|
|
|
$this->loadMigrationsFrom(SCOOL_TIMETABLES_PATH . '/database/migrations'); |
|
68
|
|
|
} |
|
69
|
|
|
/** |
|
70
|
|
|
* Publish factories. |
|
71
|
|
|
*/ |
|
72
|
|
|
private function publishFactories() |
|
73
|
|
|
{ |
|
74
|
|
|
$this->publishes( |
|
75
|
|
|
ScoolTimetables::factories(), "scool_timetables" |
|
76
|
|
|
); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
|
|
80
|
|
|
/** |
|
81
|
|
|
* Publish config. |
|
82
|
|
|
*/ |
|
83
|
|
|
private function publishConfig() |
|
84
|
|
|
{ |
|
85
|
|
|
$this->publishes( |
|
86
|
|
|
ScoolTimetables::configs(), "scool_timetables" |
|
87
|
|
|
); |
|
88
|
|
|
$this->mergeConfigFrom( |
|
89
|
|
|
SCOOL_TIMETABLES_PATH . '/config/timetables.php', 'scool_timetables' |
|
90
|
|
|
); |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
/** |
|
94
|
|
|
* Define the Timetables routes. |
|
95
|
|
|
*/ |
|
96
|
|
|
protected function defineRoutes() |
|
97
|
|
|
{ |
|
98
|
|
|
if (!$this->app->routesAreCached()) { |
|
99
|
|
|
$router = app('router'); |
|
100
|
|
|
$router->group(['namespace' => 'Scool\Timetables\Http\Controllers'], function () { |
|
101
|
|
|
require __DIR__.'/../Http/routes.php'; |
|
102
|
|
|
}); |
|
103
|
|
|
} |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
private function registerStatefulEloquentServiceProvider() |
|
107
|
|
|
{ |
|
108
|
|
|
$this->app->register(StatefulServiceProvider::class); |
|
109
|
|
|
|
|
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
|
|
|
|