-
Notifications
You must be signed in to change notification settings - Fork 510
/
AdminLTETemplateServiceProvider.php
257 lines (224 loc) · 7.48 KB
/
AdminLTETemplateServiceProvider.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
<?php
namespace Acacha\AdminLTETemplateLaravel\Providers;
use Illuminate\Routing\Router;
use Illuminate\Support\ServiceProvider;
use Creativeorange\Gravatar\Facades\Gravatar;
use Acacha\AdminLTETemplateLaravel\Facades\AdminLTE;
use Creativeorange\Gravatar\GravatarServiceProvider;
use Acacha\AdminLTETemplateLaravel\Http\Middleware\GuestUser;
/**
* Class AdminLTETemplateServiceProvider.
*/
class AdminLTETemplateServiceProvider extends ServiceProvider
{
/**
* Register the application services.
*/
public function register()
{
if (!defined('ADMINLTETEMPLATE_PATH')) {
define('ADMINLTETEMPLATE_PATH', realpath(__DIR__.'/../../'));
}
if ($this->app->runningInConsole()) {
$this->commands([\Acacha\AdminLTETemplateLaravel\Console\PublishAdminLTE::class]);
$this->commands([\Acacha\AdminLTETemplateLaravel\Console\PublishAdminLTEAlt::class]);
$this->commands([\Acacha\AdminLTETemplateLaravel\Console\PublishAdminLTESidebar::class]);
$this->commands([\Acacha\AdminLTETemplateLaravel\Console\PublishAdminLTESidebarAlt::class]);
$this->commands([\Acacha\AdminLTETemplateLaravel\Console\MakeAdminUserSeeder::class]);
$this->commands([\Acacha\AdminLTETemplateLaravel\Console\AdminLTEAdmin::class]);
$this->commands([\Acacha\AdminLTETemplateLaravel\Console\AdminLTEAdminAlt::class]);
$this->commands([\Acacha\AdminLTETemplateLaravel\Console\MakeView::class]);
$this->commands([\Acacha\AdminLTETemplateLaravel\Console\AdminLTEMenu::class]);
$this->commands([\Acacha\AdminLTETemplateLaravel\Console\AdminLTEMenuAlt::class]);
$this->commands([\Acacha\AdminLTETemplateLaravel\Console\MakeRoute::class]);
$this->commands([\Acacha\AdminLTETemplateLaravel\Console\MakeMenu::class]);
$this->commands([\Acacha\AdminLTETemplateLaravel\Console\MakeV::class]);
$this->commands([\Acacha\AdminLTETemplateLaravel\Console\MakeVC::class]);
$this->commands([\Acacha\AdminLTETemplateLaravel\Console\MakeMVC::class]);
$this->commands([\Acacha\AdminLTETemplateLaravel\Console\Username::class]);
}
$this->app->bind('AdminLTE', function () {
return new \Acacha\AdminLTETemplateLaravel\AdminLTE();
});
if (config('adminlte.gravatar', true)) {
$this->registerGravatarServiceProvider();
}
if (config('auth.providers.users.field', 'email') === 'username' &&
config('adminlte.add_nullable_username', true)) {
$this->loadMigrationsFrom(ADMINLTETEMPLATE_PATH .'/database/migrations/username_login');
}
}
/**
* Register Gravatar Service Provider.
*/
protected function registerGravatarServiceProvider()
{
$this->app->register(GravatarServiceProvider::class);
if (!class_exists('Gravatar')) {
class_alias(Gravatar::class, 'Gravatar');
}
}
/**
* Bootstrap the application services.
*/
public function boot(Router $router)
{
$router->pushMiddlewareToGroup('web', GuestUser::class);
//Publish
$this->publishHomeController();
$this->changeRegisterController();
$this->changeLoginController();
$this->changeForgotPasswordController();
$this->publishNoGuestForgotPasswordController();
$this->changeResetPasswordController();
$this->publishPublicAssets();
$this->publishViews();
$this->publishResourceAssets();
$this->publishTests();
$this->publishLanguages();
$this->publishGravatar();
$this->publishConfig();
$this->publishWebRoutes();
$this->publishApiRoutes();
$this->publishDusk();
$this->publishDatabaseConfig();
$this->enableSpatieMenu();
}
/**
* Publish Home Controller.
*/
private function publishHomeController()
{
$this->publishes(AdminLTE::homeController(), 'adminlte');
}
/**
* Change default Laravel RegisterController.
*/
private function changeRegisterController()
{
$this->publishes(AdminLTE::registerController(), 'adminlte');
}
/**
* Change default Laravel LoginController.
*/
private function changeLoginController()
{
$this->publishes(AdminLTE::loginController(), 'adminlte');
}
/**
* Change default Laravel forgot password Controller.
*/
private function changeForgotPasswordController()
{
$this->publishes(AdminLTE::forgotPasswordController(), 'adminlte');
}
/**
* Publish no guest forgot password Controller.
*/
private function publishNoGuestForgotPasswordController()
{
$this->publishes(AdminLTE::noGuestForgotPasswordController(), 'adminlte');
}
/**
* Change default Laravel reset password Controller.
*/
private function changeResetPasswordController()
{
$this->publishes(AdminLTE::resetPasswordController(), 'adminlte');
}
/**
* Publish public resource assets to Laravel project.
*/
private function publishPublicAssets()
{
$this->publishes(AdminLTE::publicAssets(), 'adminlte');
}
/**
* Publish package views to Laravel project.
*/
private function publishViews()
{
$this->loadViewsFrom(ADMINLTETEMPLATE_PATH.'/resources/views/', 'adminlte');
$this->publishes(AdminLTE::views(), 'adminlte');
}
/**
* Publish package resource assets to Laravel project.
*/
private function publishResourceAssets()
{
$this->publishes(AdminLTE::resourceAssets(), 'adminlte');
}
/**
* Publish package tests to Laravel project.
*/
private function publishTests()
{
$this->publishes(AdminLTE::tests(), 'adminlte');
}
/**
* Publish package language to Laravel project.
*/
private function publishLanguages()
{
$this->loadTranslationsFrom(ADMINLTETEMPLATE_PATH.'/resources/lang/', 'adminlte_lang');
$this->publishes(AdminLTE::languages(), 'adminlte_lang');
}
/**
* Publish config Gravatar file using group.
*/
private function publishGravatar()
{
$this->publishes(AdminLTE::gravatar(), 'adminlte');
}
/**
* Publish adminlte package config.
*/
private function publishConfig()
{
$this->publishes(AdminLTE::config(), 'adminlte');
}
/**
* Publish routes/web.php file.
*/
private function publishWebRoutes()
{
$this->publishes(AdminLTE::webroutes(), 'adminlte');
}
/**
* Publish routes/api.php file.
*/
private function publishApiRoutes()
{
$this->publishes(AdminLTE::apiroutes(), 'adminlte');
}
/**
* Publish dusk tests files.
*/
private function publishDusk()
{
$this->publishDuskEnvironment();
}
/**
* Publish dusk environment files.
*/
private function publishDuskEnvironment()
{
$this->publishes(AdminLTE::duskEnvironment(), 'adminlte');
}
/**
* Publish database config files.
*/
private function publishDatabaseConfig()
{
$this->publishes(AdminLTE::databaseConfig(), 'adminlte');
}
/**
* Enable (if active) spatie menu.
*/
private function enableSpatieMenu()
{
if ($this->app->getProvider('Spatie\Menu\Laravel\MenuServiceProvider')) {
require config_path('menu.php');
}
}
}