1 | <?php |
||
2 | |||
3 | namespace Raystech\StarterKit; |
||
4 | |||
5 | use Illuminate\Support\ServiceProvider as BaseServiceProvider; |
||
6 | |||
7 | class StarterKitServiceProvider extends BaseServiceProvider |
||
8 | { |
||
9 | /** |
||
10 | * Perform post-registration booting of services. |
||
11 | * |
||
12 | * @return void |
||
13 | */ |
||
14 | public function boot() |
||
15 | { |
||
16 | // $this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'raystech'); |
||
17 | if(config('starter-kit.route_enable', false)) { |
||
18 | $this->loadRoutesFrom(__DIR__.'/Routes/web.php'); |
||
19 | } |
||
20 | $this->loadHelpers(); |
||
21 | $this->loadViewsFrom(__DIR__.'/Resources/views', 'rt-starter-kit'); |
||
22 | |||
23 | // Publishing is only necessary when using the CLI. |
||
24 | if ($this->app->runningInConsole()) { |
||
25 | $this->registerConfig(); |
||
26 | $this->loadMigrationsFrom(__DIR__.'/../database/migrations'); |
||
27 | |||
28 | /* |
||
29 | |||
30 | if (!class_exists('CreateStarterKitTable')) { |
||
31 | $this->publishes([ |
||
32 | __DIR__ . '/../database/migrations/create_starter_kit_table.php.stub' => database_path('migrations/' . date('Y_m_d_His', time()) . '_create_starter_kit_table.php'), |
||
33 | ], 'migrations'); |
||
34 | } |
||
35 | |||
36 | |||
37 | // Publishing the views. |
||
38 | $this->publishes([ |
||
39 | __DIR__.'/../resources/views' => base_path('resources/views/vendor/raystech'), |
||
40 | ], 'views'); |
||
41 | |||
42 | // Publishing assets. |
||
43 | $this->publishes([ |
||
44 | __DIR__.'/../resources/assets' => public_path('vendor/raystech'), |
||
45 | ], 'assets'); |
||
46 | |||
47 | // Publishing the translation files. |
||
48 | $this->publishes([ |
||
49 | __DIR__.'/../resources/lang' => resource_path('lang/vendor/raystech'), |
||
50 | ], 'translation'); |
||
51 | |||
52 | // Registering package commands. |
||
53 | // $this->commands([]); |
||
54 | |||
55 | */ |
||
56 | } |
||
57 | } |
||
58 | |||
59 | /** |
||
60 | * Register config. |
||
61 | * |
||
62 | * @return void |
||
63 | */ |
||
64 | protected function registerConfig() |
||
65 | { |
||
66 | // Publishing the configuration file. |
||
67 | // echo "Publishing StarterKit Config ...\n"; |
||
68 | $this->publishes([ |
||
69 | __DIR__ . '/../config/starter-kit.php' => config_path('starter-kit.php'), |
||
70 | ], 'config'); |
||
71 | |||
72 | $this->mergeConfigFrom(__DIR__ . '/../config/starter-kit.php', 'StarterKit'); |
||
73 | } |
||
74 | |||
75 | /** |
||
76 | * Register any package services. |
||
77 | * |
||
78 | * @return void |
||
79 | */ |
||
80 | public function register() |
||
81 | { |
||
82 | // Register the service the package provides. |
||
83 | $this->app->singleton('StarterKit', function ($app) { |
||
0 ignored issues
–
show
|
|||
84 | return new StarterKit; |
||
85 | }); |
||
86 | |||
87 | $this->app->alias(StarterKit::class, 'starter-kit'); |
||
88 | |||
89 | $this->app->bind( |
||
90 | 'Raystech\StarterKit\Supports\SessionStore', |
||
91 | 'Raystech\StarterKit\Supports\LaravelSessionStore' |
||
92 | ); |
||
93 | |||
94 | // Register Flash Toast |
||
95 | $this->app->singleton('flashtoast', function () { |
||
96 | return $this->app->make('RaysTech\StarterKit\Supports\FlashToast'); |
||
97 | }); |
||
98 | } |
||
99 | |||
100 | /** |
||
101 | * Get the services provided by the provider. |
||
102 | * |
||
103 | * @return array |
||
104 | */ |
||
105 | public function provides() |
||
106 | { |
||
107 | return ['StarterKit']; |
||
108 | } |
||
109 | |||
110 | public function loadHelpers() { |
||
111 | foreach (glob(__DIR__ . '/Helpers/*.php') as $filename) { |
||
112 | require_once($filename); |
||
113 | } |
||
114 | } |
||
115 | } |
||
116 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.