GamerProvider::provides()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * | Events
4
 * | ---------------------------------
5
 * | Illuminate\Auth\Events\Attempting
6
 * | Illuminate\Auth\Events\Login
7
 * | Illuminate\Auth\Events\Logout
8
 * |
9
 * | Illuminate\Cache\Events\CacheMissed
10
 * | Illuminate\Cache\Events\CacheHit
11
 * | Illuminate\Cache\Events\KeyWritten
12
 * | Illuminate\Cache\Events\KeyForgotten
13
 * |
14
 * | Illuminate\Database\Events\TransactionBeginning
15
 * | Illuminate\Database\Events\TransactionCommitted
16
 * | Illuminate\Database\Events\TransactionRolledBack
17
 * | Illuminate\Database\Events\QueryExecuted
18
 * |
19
 * | Illuminate\Queue\Events\JobProcessed
20
 * | Illuminate\Queue\Events\JobFailed
21
 * | Illuminate\Queue\Events\WorkerStopping
22
 * |
23
 * | Illuminate\Mail\Events\MessageSending
24
 * | Illuminate\Routing\Events\RouteMatched
25
 * |
26
 * | eloquent.booting
27
 * | eloquent.booted
28
 * | eloquent.deleting
29
 * | eloquent.deleted
30
 * | eloquent.saving
31
 * | eloquent.saved
32
 * | eloquent.updating
33
 * | eloquent.updated
34
 * | eloquent.creating
35
 * | eloquent.created
36
 * | eloquent.restoring
37
 * | eloquent.restored
38
 * |
39
 * | kernel.handled
40
 * | locale.changed
41
 */
42
namespace Gamer;
43
44
use App;
45
use Config;
46
use Gamer\Facades\Gamer as GamerFacade;
47
use Gamer\Services\GamerService;
48
use Illuminate\Foundation\AliasLoader;
49
50
use Illuminate\Routing\Router;
51
use Illuminate\Support\Collection;
52
use Illuminate\Support\Facades\View;
53
use Illuminate\Support\ServiceProvider;
54
use JeroenNoten\LaravelAdminLte\Events\BuildingMenu;
55
56
use Log;
57
58
use Muleta\Traits\Providers\ConsoleTools;
59
use Route;
60
61
class GamerProvider extends ServiceProvider
62
{
63
    use ConsoleTools;
64
65
    public static $aliasProviders = [
66
        'Gamer' => \Gamer\Facades\Gamer::class,
67
    ];
68
69
    public static $providers = [
70
        \Tracking\TrackingProvider::class,
71
        \Finder\FinderProvider::class,
72
    ];
73
74
    /**
75
     * Rotas do Menu
76
     */
77
    public static $menuItens = [
78
        // 'Painel' => [
79
        //     'Gamer' => [
80
        //         [
81
        //             'text'        => 'Profile',
82
        //             'route'       => 'gamer.profile.home',
83
        //             'icon'        => 'fas fa-fw fa-gamepad',
84
        //             'icon_color'  => 'blue',
85
        //             'label_color' => 'success',
86
        //             // 'access' => \App\Models\Role::$ADMIN
87
        //         ],
88
        //         [
89
        //             'text'        => 'Root',
90
        //             'route'       => 'gamer.root.home',
91
        //             'icon'        => 'fas fa-fw fa-flag',
92
        //             'icon_color'  => 'blue',
93
        //             'label_color' => 'success',
94
        //             // 'access' => \App\Models\Role::$ADMIN
95
        //         ],
96
        //     ],
97
        // ],
98
    ];
99
100
    /**
101
     * Alias the services in the boot.
102
     */
103
    public function boot()
104
    {
105
        
106
        // Register configs, migrations, etc
107
        $this->registerDirectories();
108
109
        // // COloquei no register pq nao tava reconhecendo as rotas para o adminlte
110
        // $this->app->booted(function () {
111
        //     $this->routes();
112
        // });
113
114
        //
115
        $this->app['events']->listen(
116
            'eloquent.*',
117
            'Gamer\Observers\ModelCallbacks'
118
        );
119
        $this->app['events']->listen(
120
            'Illuminate\Auth\Events\Login',
121
            'Gamer\Observers\LoginObserver'
122
        );
123
    }
124
125
    /**
126
     * Register the tool's routes.
127
     *
128
     * @return void
129
     */
130
    protected function routes()
131
    {
132
        if ($this->app->routesAreCached()) {
133
            return;
134
        }
135
136
        /**
137
         * Gamer Routes
138
         */
139
        Route::group(
140
            [
141
            'namespace' => '\Gamer\Http\Controllers',
142
            ], function ($router) {
143
                include __DIR__.'/Routes/web.php';
144
            }
145
        );
146
    }
147
148
    /**
149
     * Register the services.
150
     */
151
    public function register()
152
    {
153
        $this->mergeConfigFrom($this->getPublishesPath('config/sitec/gamer.php'), 'sitec.gamer');
154
        
155
156
        $this->setProviders();
157
        $this->routes();
158
159
160
161
        // Register Migrations
162
        $this->loadMigrationsFrom(__DIR__.'/../database/migrations');
163
164
        $loader = AliasLoader::getInstance();
165
        $loader->alias('Gamer', GamerFacade::class);
166
167
        $this->app->singleton(
168
            'gamer', function () {
169
                return new Gamer();
170
            }
171
        );
172
        
173
        /*
174
        |--------------------------------------------------------------------------
175
        | Register the Utilities
176
        |--------------------------------------------------------------------------
177
        */
178
        /**
179
         * Singleton Gamer
180
         */
181
        $this->app->singleton(
182
            GamerService::class, function ($app) {
0 ignored issues
show
Unused Code introduced by
The parameter $app is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
183
                Log::info('Singleton Gamer');
184
                return new GamerService(\Illuminate\Support\Facades\Config::get('sitec.gamer'));
0 ignored issues
show
Unused Code introduced by
The call to GamerService::__construct() has too many arguments starting with \Illuminate\Support\Faca...fig::get('sitec.gamer').

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
185
            }
186
        );
187
188
        // Register commands
189
        $this->registerCommandFolders(
190
            [
191
            base_path('vendor/sierratecnologia/gamer/src/Console/Commands') => '\Gamer\Console\Commands',
192
            ]
193
        );
194
    }
195
196
    /**
197
     * Get the services provided by the provider.
198
     *
199
     * @return array
200
     */
201
    public function provides()
202
    {
203
        return [
204
            'gamer',
205
        ];
206
    }
207
208
    /**
209
     * Register configs, migrations, etc
210
     *
211
     * @return void
212
     */
213
    public function registerDirectories()
214
    {
215
        // Publish config files
216
        $this->publishes(
217
            [
218
            // Paths
219
            $this->getPublishesPath('config/sitec') => config_path('sitec'),
220
            ], ['config',  'sitec', 'sitec-config']
221
        );
222
223
        // // Publish gamer css and js to public directory
224
        // $this->publishes([
225
        //     $this->getDistPath('gamer') => public_path('assets/gamer')
226
        // ], ['public',  'sitec', 'sitec-public']);
227
228
        $this->loadViews();
229
        $this->loadTranslations();
230
    }
231
232
    private function loadViews()
233
    {
234
        // View namespace
235
        $viewsPath = $this->getResourcesPath('views');
236
        $this->loadViewsFrom($viewsPath, 'gamer');
237
        $this->publishes(
238
            [
239
            $viewsPath => base_path('resources/views/vendor/gamer'),
240
            ], ['views',  'sitec', 'sitec-views']
241
        );
242
    }
243
    
244
    private function loadTranslations()
245
    {
246
        // Publish lanaguage files
247
        $this->publishes(
248
            [
249
            $this->getResourcesPath('lang') => resource_path('lang/vendor/gamer')
250
            ], ['lang',  'sitec', 'sitec-lang', 'translations']
251
        );
252
253
        // Load translations
254
        $this->loadTranslationsFrom($this->getResourcesPath('lang'), 'gamer');
255
    }
256
}
257