1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Bantenprov\Prestasi; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\ServiceProvider; |
6
|
|
|
use Bantenprov\Prestasi\Console\Commands\PrestasiCommand; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* The PrestasiServiceProvider class |
10
|
|
|
* |
11
|
|
|
* @package Bantenprov\Prestasi |
12
|
|
|
* @author bantenprov <[email protected]> |
13
|
|
|
*/ |
14
|
|
|
class PrestasiServiceProvider extends ServiceProvider |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* Indicates if loading of the provider is deferred. |
18
|
|
|
* |
19
|
|
|
* @var bool |
20
|
|
|
*/ |
21
|
|
|
protected $defer = false; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Bootstrap the application events. |
25
|
|
|
* |
26
|
|
|
* @return void |
27
|
|
|
*/ |
28
|
|
|
public function boot() |
29
|
|
|
{ |
30
|
|
|
$this->routeHandle(); |
31
|
|
|
$this->configHandle(); |
32
|
|
|
$this->langHandle(); |
33
|
|
|
$this->viewHandle(); |
34
|
|
|
$this->assetHandle(); |
35
|
|
|
$this->migrationHandle(); |
36
|
|
|
$this->publicHandle(); |
37
|
|
|
$this->seedHandle(); |
38
|
|
|
$this->publishHandle(); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* Register the service provider. |
43
|
|
|
* |
44
|
|
|
* @return void |
45
|
|
|
*/ |
46
|
|
|
public function register() |
47
|
|
|
{ |
48
|
|
|
$this->app->singleton('prestasi', function ($app) { |
|
|
|
|
49
|
|
|
return new Prestasi; |
50
|
|
|
}); |
51
|
|
|
|
52
|
|
|
$this->app->singleton('command.prestasi', function ($app) { |
|
|
|
|
53
|
|
|
return new PrestasiCommand; |
54
|
|
|
}); |
55
|
|
|
|
56
|
|
|
$this->commands('command.prestasi'); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* Get the services provided by the provider. |
61
|
|
|
* |
62
|
|
|
* @return array |
63
|
|
|
*/ |
64
|
|
|
public function provides() |
65
|
|
|
{ |
66
|
|
|
return [ |
67
|
|
|
'prestasi', |
68
|
|
|
'command.prestasi', |
69
|
|
|
]; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Loading and publishing package's config |
74
|
|
|
* |
75
|
|
|
* @return void |
76
|
|
|
*/ |
77
|
|
|
protected function configHandle($publish = '') |
78
|
|
|
{ |
79
|
|
|
$packageConfigPath = __DIR__.'/config'; |
80
|
|
|
$appConfigPath = config_path('bantenprov/prestasi'); |
81
|
|
|
|
82
|
|
|
$this->mergeConfigFrom($packageConfigPath.'/prestasi.php', 'prestasi'); |
83
|
|
|
$this->mergeConfigFrom($packageConfigPath.'/master-prestasi.php', 'master-prestasi'); |
84
|
|
|
$this->mergeConfigFrom($packageConfigPath.'/jenis-prestasi.php', 'jenis-prestasi'); |
85
|
|
|
|
86
|
|
|
$this->publishes([ |
87
|
|
|
$packageConfigPath.'/prestasi.php' => $appConfigPath.'/prestasi.php', |
88
|
|
|
$packageConfigPath.'/master-prestasi.php' => $appConfigPath.'/master-prestasi.php', |
89
|
|
|
$packageConfigPath.'/jenis-prestasi.php' => $appConfigPath.'/jenis-prestasi.php', |
90
|
|
|
], $publish ? $publish : 'prestasi-config'); |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* Loading package routes |
95
|
|
|
* |
96
|
|
|
* @return void |
97
|
|
|
*/ |
98
|
|
|
protected function routeHandle() |
99
|
|
|
{ |
100
|
|
|
$this->loadRoutesFrom(__DIR__.'/routes/routes.php'); |
101
|
|
|
} |
102
|
|
|
|
103
|
|
|
/** |
104
|
|
|
* Loading and publishing package's translations |
105
|
|
|
* |
106
|
|
|
* @return void |
107
|
|
|
*/ |
108
|
|
View Code Duplication |
protected function langHandle($publish = '') |
|
|
|
|
109
|
|
|
{ |
110
|
|
|
$packageTranslationsPath = __DIR__.'/resources/lang'; |
111
|
|
|
|
112
|
|
|
$this->loadTranslationsFrom($packageTranslationsPath, 'prestasi'); |
113
|
|
|
|
114
|
|
|
$this->publishes([ |
115
|
|
|
$packageTranslationsPath => resource_path('lang/vendor/prestasi'), |
116
|
|
|
], $publish ? $publish : 'prestasi-lang'); |
117
|
|
|
} |
118
|
|
|
|
119
|
|
|
/** |
120
|
|
|
* Loading and publishing package's views |
121
|
|
|
* |
122
|
|
|
* @return void |
123
|
|
|
*/ |
124
|
|
View Code Duplication |
protected function viewHandle($publish = '') |
|
|
|
|
125
|
|
|
{ |
126
|
|
|
$packageViewsPath = __DIR__.'/resources/views'; |
127
|
|
|
|
128
|
|
|
$this->loadViewsFrom($packageViewsPath, 'prestasi'); |
129
|
|
|
|
130
|
|
|
$this->publishes([ |
131
|
|
|
$packageViewsPath => resource_path('views/vendor/prestasi'), |
132
|
|
|
], $publish ? $publish : 'prestasi-views'); |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
/** |
136
|
|
|
* Publishing package's assets (JavaScript, CSS, images...) |
137
|
|
|
* |
138
|
|
|
* @return void |
139
|
|
|
*/ |
140
|
|
|
protected function assetHandle($publish = '') |
141
|
|
|
{ |
142
|
|
|
$packageAssetsPath = __DIR__.'/resources/assets'; |
143
|
|
|
|
144
|
|
|
$this->publishes([ |
145
|
|
|
$packageAssetsPath => resource_path('assets'), |
146
|
|
|
], $publish ? $publish : 'prestasi-assets'); |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* Publishing package's migrations |
151
|
|
|
* |
152
|
|
|
* @return void |
153
|
|
|
*/ |
154
|
|
|
protected function migrationHandle($publish = '') |
155
|
|
|
{ |
156
|
|
|
$packageMigrationsPath = __DIR__.'/database/migrations'; |
157
|
|
|
|
158
|
|
|
$this->loadMigrationsFrom($packageMigrationsPath); |
159
|
|
|
|
160
|
|
|
$this->publishes([ |
161
|
|
|
$packageMigrationsPath => database_path('migrations') |
162
|
|
|
], $publish ? $publish : 'prestasi-migrations'); |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* Publishing package's publics (JavaScript, CSS, images...) |
167
|
|
|
* |
168
|
|
|
* @return void |
169
|
|
|
*/ |
170
|
|
|
public function publicHandle($publish = '') |
171
|
|
|
{ |
172
|
|
|
$packagePublicPath = __DIR__.'/public'; |
173
|
|
|
|
174
|
|
|
$this->publishes([ |
175
|
|
|
$packagePublicPath => base_path('public') |
176
|
|
|
], $publish ? $publish : 'prestasi-public'); |
177
|
|
|
} |
178
|
|
|
|
179
|
|
|
/** |
180
|
|
|
* Publishing package's seeds |
181
|
|
|
* |
182
|
|
|
* @return void |
183
|
|
|
*/ |
184
|
|
|
public function seedHandle($publish = '') |
185
|
|
|
{ |
186
|
|
|
$packageSeedPath = __DIR__.'/database/seeds'; |
187
|
|
|
|
188
|
|
|
$this->publishes([ |
189
|
|
|
$packageSeedPath => base_path('database/seeds') |
190
|
|
|
], $publish ? $publish : 'prestasi-seeds'); |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
/** |
194
|
|
|
* Publishing package's all files |
195
|
|
|
* |
196
|
|
|
* @return void |
197
|
|
|
*/ |
198
|
|
|
public function publishHandle() |
199
|
|
|
{ |
200
|
|
|
$publish = 'prestasi-publish'; |
201
|
|
|
|
202
|
|
|
$this->routeHandle($publish); |
|
|
|
|
203
|
|
|
$this->configHandle($publish); |
204
|
|
|
$this->langHandle($publish); |
205
|
|
|
$this->viewHandle($publish); |
206
|
|
|
$this->assetHandle($publish); |
207
|
|
|
// $this->migrationHandle($publish); |
|
|
|
|
208
|
|
|
$this->publicHandle($publish); |
209
|
|
|
$this->seedHandle($publish); |
210
|
|
|
} |
211
|
|
|
} |
212
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.