Completed
Push — master ( 6efadf...b20258 )
by Sergi Tur
15:08
created

publishNoGuestForgotPasswordController()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Acacha\AdminLTETemplateLaravel\Providers;
4
5
use Acacha\AdminLTETemplateLaravel\Facades\AdminLTE;
6
use Acacha\User\Providers\GuestUserServiceProvider;
7
use Creativeorange\Gravatar\Facades\Gravatar;
8
use Creativeorange\Gravatar\GravatarServiceProvider;
9
use Illuminate\Console\DetectsApplicationNamespace;
10
use Illuminate\Support\ServiceProvider;
11
12
/**
13
 * Class AdminLTETemplateServiceProvider.
14
 */
15
class AdminLTETemplateServiceProvider extends ServiceProvider
16
{
17
    use DetectsApplicationNamespace;
18
19
    /**
20
     * Register the application services.
21
     */
22
    public function register()
23
    {
24
        if (!defined('ADMINLTETEMPLATE_PATH')) {
25
            define('ADMINLTETEMPLATE_PATH', realpath(__DIR__.'/../../'));
26
        }
27
28
        if ($this->app->runningInConsole()) {
29
            $this->commands([\Acacha\AdminLTETemplateLaravel\Console\PublishAdminLTE::class]);
30
            $this->commands([\Acacha\AdminLTETemplateLaravel\Console\PublishAdminLTEAlt::class]);
31
            $this->commands([\Acacha\AdminLTETemplateLaravel\Console\PublishAdminLTESidebar::class]);
32
            $this->commands([\Acacha\AdminLTETemplateLaravel\Console\PublishAdminLTESidebarAlt::class]);
33
            $this->commands([\Acacha\AdminLTETemplateLaravel\Console\MakeAdminUserSeeder::class]);
34
            $this->commands([\Acacha\AdminLTETemplateLaravel\Console\AdminLTEAdmin::class]);
35
            $this->commands([\Acacha\AdminLTETemplateLaravel\Console\AdminLTEAdminAlt::class]);
36
            $this->commands([\Acacha\AdminLTETemplateLaravel\Console\MakeView::class]);
37
            $this->commands([\Acacha\AdminLTETemplateLaravel\Console\AdminLTEMenu::class]);
38
            $this->commands([\Acacha\AdminLTETemplateLaravel\Console\AdminLTEMenuAlt::class]);
39
            $this->commands([\Acacha\AdminLTETemplateLaravel\Console\MakeRoute::class]);
40
            $this->commands([\Acacha\AdminLTETemplateLaravel\Console\MakeMenu::class]);
41
            $this->commands([\Acacha\AdminLTETemplateLaravel\Console\MakeV::class]);
42
            $this->commands([\Acacha\AdminLTETemplateLaravel\Console\MakeVC::class]);
43
            $this->commands([\Acacha\AdminLTETemplateLaravel\Console\MakeMVC::class]);
44
            $this->commands([\Acacha\AdminLTETemplateLaravel\Console\Username::class]);
45
        }
46
47
        $this->app->bind('AdminLTE', function () {
48
            return new \Acacha\AdminLTETemplateLaravel\AdminLTE();
49
        });
50
51
        if (config('adminlte.gravatar', true)) {
52
            $this->registerGravatarServiceProvider();
53
        }
54
55
        if (config('adminlte.guestuser', true)) {
56
            $this->registerGuestUserProvider();
57
        }
58
        if (config('auth.providers.users.field', 'email') === 'username') {
59
            $this->loadMigrationsFrom(ADMINLTETEMPLATE_PATH .'/database/migrations/username_login');
60
        }
61
    }
62
63
    /**
64
     * Register Guest User Provider.
65
     */
66
    protected function registerGuestUserProvider()
67
    {
68
        $this->app->register(GuestUserServiceProvider::class);
69
    }
70
71
    /**
72
     * Register Gravatar Service Provider.
73
     */
74
    protected function registerGravatarServiceProvider()
75
    {
76
        $this->app->register(GravatarServiceProvider::class);
77
        if (!class_exists('Gravatar')) {
78
            class_alias(Gravatar::class, 'Gravatar');
79
        }
80
    }
81
82
    /**
83
     * Bootstrap the application services.
84
     */
85 View Code Duplication
    public function boot()
0 ignored issues
show
Duplication introduced by Sergi Tur
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
86
    {
87
        $this->defineRoutes();
88
89
        //Publish
90
        $this->publishHomeController();
91
        $this->changeRegisterController();
92
        $this->changeLoginController();
93
        $this->changeForgotPasswordController();
94
        $this->publishNoGuestForgotPasswordController();
95
        $this->changeResetPasswordController();
96
        $this->publishPublicAssets();
97
        $this->publishViews();
98
        $this->publishResourceAssets();
99
        $this->publishTests();
100
        $this->publishLanguages();
101
        $this->publishGravatar();
102
        $this->publishConfig();
103
        $this->publishWebRoutes();
104
        $this->publishApiRoutes();
105
        $this->publishDusk();
106
        $this->publishDatabaseConfig();
107
108
        $this->enableSpatieMenu();
109
    }
110
111
    /**
112
     * Define the AdminLTETemplate routes.
113
     */
114
    protected function defineRoutes()
115
    {
116
        if (!$this->app->routesAreCached()) {
117
            $router = app('router');
118
119
            $router->group(['namespace' => $this->getAppNamespace().'Http\Controllers'], function () {
120
                require __DIR__.'/../Http/routes.php';
121
            });
122
        }
123
    }
124
125
    /**
126
     * Publish Home Controller.
127
     */
128
    private function publishHomeController()
129
    {
130
        $this->publishes(AdminLTE::homeController(), 'adminlte');
131
    }
132
133
    /**
134
     * Change default Laravel RegisterController.
135
     */
136
    private function changeRegisterController()
137
    {
138
        $this->publishes(AdminLTE::registerController(), 'adminlte');
139
    }
140
141
    /**
142
     * Change default Laravel LoginController.
143
     */
144
    private function changeLoginController()
145
    {
146
        $this->publishes(AdminLTE::loginController(), 'adminlte');
147
    }
148
149
    /**
150
     * Change default Laravel forgot password Controller.
151
     */
152
    private function changeForgotPasswordController()
153
    {
154
        $this->publishes(AdminLTE::forgotPasswordController(), 'adminlte');
155
    }
156
157
    /**
158
     * Publish no guest forgot password Controller.
159
     */
160
    private function publishNoGuestForgotPasswordController()
161
    {
162
        $this->publishes(AdminLTE::NoGuestForgotPasswordController(), 'adminlte');
163
    }
164
165
166
167
    /**
168
     * Change default Laravel reset password Controller.
169
     */
170
    private function changeResetPasswordController()
171
    {
172
        $this->publishes(AdminLTE::resetPasswordController(), 'adminlte');
173
    }
174
175
    /**
176
     * Publish public resource assets to Laravel project.
177
     */
178
    private function publishPublicAssets()
179
    {
180
        $this->publishes(AdminLTE::publicAssets(), 'adminlte');
181
    }
182
183
    /**
184
     * Publish package views to Laravel project.
185
     */
186
    private function publishViews()
187
    {
188
        $this->loadViewsFrom(ADMINLTETEMPLATE_PATH.'/resources/views/', 'adminlte');
189
190
        $this->publishes(AdminLTE::views(), 'adminlte');
191
    }
192
193
    /**
194
     * Publish package resource assets to Laravel project.
195
     */
196
    private function publishResourceAssets()
197
    {
198
        $this->publishes(AdminLTE::resourceAssets(), 'adminlte');
199
    }
200
201
    /**
202
     * Publish package tests to Laravel project.
203
     */
204
    private function publishTests()
205
    {
206
        $this->publishes(AdminLTE::tests(), 'adminlte');
207
    }
208
209
    /**
210
     * Publish package language to Laravel project.
211
     */
212
    private function publishLanguages()
213
    {
214
        $this->loadTranslationsFrom(ADMINLTETEMPLATE_PATH.'/resources/lang/', 'adminlte_lang');
215
216
        $this->publishes(AdminLTE::languages(), 'adminlte_lang');
217
    }
218
219
    /**
220
     * Publish config Gravatar file using group.
221
     */
222
    private function publishGravatar()
223
    {
224
        $this->publishes(AdminLTE::gravatar(), 'adminlte');
225
    }
226
227
    /**
228
     * Publish adminlte package config.
229
     */
230
    private function publishConfig()
231
    {
232
        $this->publishes(AdminLTE::config(), 'adminlte');
233
    }
234
235
    /**
236
     * Publish routes/web.php file.
237
     */
238
    private function publishWebRoutes()
239
    {
240
        $this->publishes(AdminLTE::webroutes(), 'adminlte');
241
    }
242
243
    /**
244
     * Publish routes/api.php file.
245
     */
246
    private function publishApiRoutes()
247
    {
248
        $this->publishes(AdminLTE::apiroutes(), 'adminlte');
249
    }
250
251
    /**
252
     * Publish dusk tests files.
253
     */
254
    private function publishDusk()
255
    {
256
        $this->publishDuskEnvironment();
257
        $this->publishAppServiceProvider();
258
    }
259
260
    /**
261
     * Publish dusk environment files.
262
     */
263
    private function publishDuskEnvironment()
264
    {
265
        $this->publishes(AdminLTE::duskEnvironment(), 'adminlte');
266
    }
267
268
    /**
269
     * Publish app/Providers/AppServiceProvider.php file.
270
     */
271
    private function publishAppServiceProvider()
272
    {
273
        $this->publishes(AdminLTE::appServiceProviderClass(), 'adminlte');
274
    }
275
276
    /**
277
     * Publish database config files.
278
     */
279
    private function publishDatabaseConfig()
280
    {
281
        $this->publishes(AdminLTE::databaseConfig(), 'adminlte');
282
    }
283
284
    /**
285
     * Enable (if active) spatie menu.
286
     */
287
    private function enableSpatieMenu()
288
    {
289
        if ($this->app->getProvider('Spatie\Menu\Laravel\MenuServiceProvider')) {
290
            require config_path('menu.php');
291
        }
292
    }
293
}
294