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

118 lines
3.1 KiB
PHP
Raw Normal View History

2021-10-24 15:19:08 +00:00
<?php
namespace Sarga\Shop\Providers;
2022-03-06 10:54:17 +00:00
use Illuminate\Foundation\AliasLoader;
use Sarga\Shop\ShoppingCart;
use Webkul\Checkout\Facades\Cart;
2021-10-24 15:19:08 +00:00
use Webkul\Core\Tree;
use Illuminate\Routing\Router;
use Illuminate\Pagination\Paginator;
use Webkul\Shop\Http\Middleware\Theme;
use Illuminate\Support\ServiceProvider;
use Webkul\Shop\Http\Middleware\Locale;
use Webkul\Shop\Http\Middleware\Currency;
class ShopServiceProvider extends ServiceProvider
{
/**
* Bootstrap services.
*
* @return void
*/
public function boot(Router $router)
{
/* publishers */
2023-02-24 09:50:09 +00:00
$this->publishes([
2021-10-24 15:19:08 +00:00
// __DIR__ . '/../../publishable/assets' => public_path('themes/default/assets'),
2023-02-24 09:50:09 +00:00
__DIR__ . '/../Resources/views' => resource_path('themes/default/views'),
2021-10-24 15:19:08 +00:00
// __DIR__ . '/../Resources/lang' => resource_path('lang/vendor/shop'),
2023-02-24 09:50:09 +00:00
],'sarga_theme');
2021-10-24 15:19:08 +00:00
/* loaders */
// $this->loadRoutesFrom(__DIR__ . '/../Http/routes.php');
// $this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations');
// $this->loadTranslationsFrom(__DIR__ . '/../Resources/lang', 'shop');
// $this->loadViewsFrom(__DIR__ . '/../Resources/views', 'shop');
/* aliases */
// $router->aliasMiddleware('locale', Locale::class);
// $router->aliasMiddleware('theme', Theme::class);
// $router->aliasMiddleware('currency', Currency::class);
/* view composers */
// $this->composeView();
/* paginators */
// Paginator::defaultView('shop::partials.pagination');
// Paginator::defaultSimpleView('shop::partials.pagination');
2022-03-06 10:54:17 +00:00
$this->app->register(ModuleServiceProvider::class);
2021-10-24 15:19:08 +00:00
}
/**
* Register services.
*
* @return void
*/
public function register()
{
2022-03-06 10:54:17 +00:00
$this->registerFacades();
2021-10-24 15:19:08 +00:00
// $this->registerConfig();
}
2022-03-06 10:54:17 +00:00
/**
* Register cart as a singleton.
*
* @return void
*/
protected function registerFacades(): void
{
$loader = AliasLoader::getInstance();
$loader->alias('shoppingcart', ShoppingCart::class);
2021-10-24 15:19:08 +00:00
2022-03-06 10:54:17 +00:00
$this->app->singleton('shoppingcart', function () {
return new ShoppingCart();
});
$this->app->bind('shoppingcart', ShoppingCart::class);
}
2021-10-24 15:19:08 +00:00
/**
* Bind the the data to the views.
*
* @return void
*/
protected function composeView()
{
view()->composer('shop::customers.account.partials.sidemenu', function ($view) {
$tree = Tree::create();
2021-11-09 17:55:21 +00:00
$menu = config('menu.customer');
foreach ($menu as $item) {
2021-10-24 15:19:08 +00:00
$tree->add($item, 'menu');
}
$tree->items = core()->sortItems($tree->items);
$view->with('menu', $tree);
});
}
/**
* Register package config.
*
* @return void
*/
protected function registerConfig()
{
$this->mergeConfigFrom(
dirname(__DIR__) . '/Config/menu.php', 'menu.customer'
);
$this->mergeConfigFrom(
dirname(__DIR__) . '/Config/system.php', 'core'
);
}
}