sarga/packages/Webkul/Shop/src/Providers/ShopServiceProvider.php

94 lines
2.4 KiB
PHP
Raw Normal View History

2018-07-12 07:12:48 +00:00
<?php
namespace Webkul\Shop\Providers;
2021-03-16 05:03:42 +00:00
use Webkul\Core\Tree;
use Illuminate\Routing\Router;
use Illuminate\Pagination\Paginator;
2018-10-17 13:57:51 +00:00
use Webkul\Shop\Http\Middleware\Theme;
2021-03-16 05:03:42 +00:00
use Illuminate\Support\ServiceProvider;
use Webkul\Shop\Http\Middleware\Locale;
use Webkul\Shop\Http\Middleware\Currency;
2018-07-12 07:12:48 +00:00
class ShopServiceProvider extends ServiceProvider
{
/**
* Bootstrap services.
*
* @return void
*/
2018-10-17 13:57:51 +00:00
public function boot(Router $router)
2018-07-12 07:12:48 +00:00
{
2021-03-16 05:03:42 +00:00
/* publishers */
2018-07-12 07:12:48 +00:00
$this->publishes([
2018-08-17 05:48:21 +00:00
__DIR__ . '/../../publishable/assets' => public_path('themes/default/assets'),
2021-03-16 05:03:42 +00:00
__DIR__ . '/../Resources/views' => resource_path('themes/default/views'),
__DIR__ . '/../Resources/lang' => resource_path('lang/vendor/shop'),
]);
2018-07-12 07:12:48 +00:00
2021-03-16 05:03:42 +00:00
/* loaders */
$this->loadRoutesFrom(__DIR__ . '/../Http/routes.php');
$this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations');
$this->loadTranslationsFrom(__DIR__ . '/../Resources/lang', 'shop');
2018-07-12 07:12:48 +00:00
$this->loadViewsFrom(__DIR__ . '/../Resources/views', 'shop');
2021-03-16 05:03:42 +00:00
/* aliases */
2018-10-17 13:57:51 +00:00
$router->aliasMiddleware('locale', Locale::class);
$router->aliasMiddleware('theme', Theme::class);
$router->aliasMiddleware('currency', Currency::class);
2018-10-17 13:57:51 +00:00
2021-03-16 05:03:42 +00:00
/* view composers */
2018-10-17 07:21:47 +00:00
$this->composeView();
2021-03-16 05:03:42 +00:00
/* paginators */
Paginator::defaultView('shop::partials.pagination');
Paginator::defaultSimpleView('shop::partials.pagination');
2018-10-17 07:21:47 +00:00
}
2018-10-17 10:30:31 +00:00
/**
* Register services.
*
* @return void
*/
public function register()
{
$this->registerConfig();
2018-10-17 10:30:31 +00:00
}
2018-10-17 07:21:47 +00:00
/**
2021-03-16 05:03:42 +00:00
* Bind the the data to the views.
2018-10-17 07:21:47 +00:00
*
* @return void
*/
protected function composeView()
{
view()->composer('shop::customers.account.partials.sidemenu', function ($view) {
$tree = Tree::create();
2018-07-12 07:12:48 +00:00
2019-01-15 11:54:41 +00:00
foreach (config('menu.customer') as $item) {
$tree->add($item, 'menu');
}
$tree->items = core()->sortItems($tree->items);
$view->with('menu', $tree);
2018-10-17 07:21:47 +00:00
});
2018-07-12 07:12:48 +00:00
}
/**
* Register package config.
*
* @return void
*/
protected function registerConfig()
{
$this->mergeConfigFrom(
dirname(__DIR__) . '/Config/menu.php', 'menu.customer'
);
2020-06-19 07:46:01 +00:00
$this->mergeConfigFrom(
dirname(__DIR__) . '/Config/system.php', 'core'
);
}
2020-10-05 08:57:49 +00:00
}