1 | <?php |
||
2 | |||
3 | namespace Mongi\Mongicommerce; |
||
4 | |||
5 | use Illuminate\Routing\Router; |
||
6 | use Illuminate\Support\Facades\File; |
||
7 | use Illuminate\Support\Facades\View; |
||
8 | use Illuminate\Support\Facades\Blade; |
||
9 | use Illuminate\Foundation\Http\Kernel; |
||
10 | use Illuminate\Support\Facades\Schema; |
||
11 | use Illuminate\Support\ServiceProvider; |
||
12 | use Mongi\Mongicommerce\Models\Category; |
||
13 | use Mongi\Mongicommerce\Libraries\Template; |
||
14 | use Mongi\Mongicommerce\Models\AdminSetting; |
||
15 | use Mongi\Mongicommerce\Console\UpdatePackage; |
||
16 | use Mongi\Mongicommerce\Console\InstallPackage; |
||
17 | use Mongi\Mongicommerce\Http\Middleware\AdminMiddleware; |
||
18 | |||
19 | class MongicommerceServiceProvider extends ServiceProvider |
||
20 | { |
||
21 | /** |
||
22 | * Bootstrap the application services. |
||
23 | */ |
||
24 | public function boot(Router $router, Kernel $kernel) |
||
0 ignored issues
–
show
|
|||
25 | { |
||
26 | |||
27 | Blade::directive('money', function ($amount) { |
||
28 | #return $fmt->formatCurrency($amount,"EUR"); |
||
29 | /*return "<?= $fmt->formatCurrency($amount,'EUR'); ?>";*/ |
||
30 | return "<?= abs($amount) > 1000 ? '€ ' .number_format($amount, 0, ',', '.') : '€ ' . number_format($amount, 2, ',', '.') ?>"; |
||
31 | }); |
||
32 | /* |
||
33 | * Optional methods to load your package assets |
||
34 | */ |
||
35 | // $this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'mongicommerce'); |
||
36 | $this->loadViewsFrom(__DIR__ . '/../resources/views', 'mongicommerce'); |
||
37 | $this->loadMigrationsFrom(__DIR__ . '/../database/migrations'); |
||
38 | $this->loadRoutesFrom(__DIR__ . '/routes.php'); |
||
39 | |||
40 | if (Schema::hasTable('admin_settings')) { |
||
41 | //inject global information into views |
||
42 | View::share('mongicommerce', AdminSetting::first()); |
||
43 | } |
||
44 | |||
45 | if (Schema::hasTable('categories')) { |
||
46 | //inject global information into views |
||
47 | View::share('categories', Template::getCategoryTree()); |
||
48 | } |
||
49 | |||
50 | #$router->middleware(AdminMiddleware::class); |
||
51 | $router->aliasMiddleware('admin',AdminMiddleware::class); |
||
52 | |||
53 | |||
54 | if ($this->app->runningInConsole()) { |
||
55 | |||
56 | |||
57 | // Publishing the config file. |
||
58 | $this->publishes([ |
||
59 | __DIR__ . '/../config/config.php' => config_path('mongicommerce.php'), |
||
60 | ], 'config'); |
||
61 | |||
62 | |||
63 | // Publishing the views. |
||
64 | $this->publishes([ |
||
65 | __DIR__ . '/../resources/views/shop' => resource_path('/views/mongicommerce'), |
||
66 | ], 'views'); |
||
67 | |||
68 | |||
69 | // Publishing assets. |
||
70 | $this->publishes([ |
||
71 | __DIR__ . '/../resources/assets' => public_path('/mongicommerce/template'), |
||
72 | ], 'assets'); |
||
73 | |||
74 | // Registering package commands. |
||
75 | $this->commands([ |
||
76 | InstallPackage::class, |
||
77 | UpdatePackage::class |
||
78 | ]); |
||
79 | |||
80 | // Publishing the translation files. |
||
81 | /*$this->publishes([ |
||
82 | __DIR__.'/../resources/lang' => resource_path('lang/vendor/mongicommerce'), |
||
83 | ], 'lang');*/ |
||
84 | } |
||
85 | } |
||
86 | |||
87 | /** |
||
88 | * Register the application services. |
||
89 | */ |
||
90 | public function register() |
||
91 | { |
||
92 | // Automatically apply the package configuration |
||
93 | $this->mergeConfigFrom(__DIR__ . '/../config/config.php', 'mongicommerce'); |
||
94 | |||
95 | // Register the main class to use with the facade |
||
96 | $this->app->singleton('mongicommerce', function () { |
||
97 | return new Mongicommerce; |
||
98 | }); |
||
99 | } |
||
100 | } |
||
101 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.