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

90 lines
2.2 KiB
PHP
Raw Normal View History

2018-07-12 07:12:48 +00:00
<?php
namespace Webkul\Shop\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Routing\Router;
use Illuminate\Support\Facades\Blade;
use Illuminate\Pagination\Paginator;
2018-10-17 13:57:51 +00:00
use Webkul\Shop\Http\Middleware\Locale;
use Webkul\Shop\Http\Middleware\Theme;
use Webkul\Shop\Http\Middleware\Currency;
use Webkul\Core\Tree;
/**
* Shop service provider
*
* @author Jitendra Singh <jitendra@webkul.com>
* @copyright 2018 Webkul Software Pvt Ltd (http://www.webkul.com)
*/
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
{
include __DIR__ . '/../Http/routes.php';
$this->loadTranslationsFrom(__DIR__ . '/../Resources/lang', 'shop');
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'),
2018-07-12 07:12:48 +00:00
], 'public');
$this->loadViewsFrom(__DIR__ . '/../Resources/views', 'shop');
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
2018-10-17 07:21:47 +00:00
$this->composeView();
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
/**
* Bind the the data to the views
*
* @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'
);
}
2018-10-17 09:44:22 +00:00
}