sarga/packages/Webkul/Admin/src/Providers/AdminServiceProvider.php

99 lines
2.8 KiB
PHP
Raw Normal View History

2018-06-20 05:06:27 +00:00
<?php
namespace Webkul\Admin\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Event;
2018-06-25 11:00:42 +00:00
use Illuminate\Support\Facades\Blade;
use Webkul\Admin\Providers\EventServiceProvider;
2018-06-20 05:06:27 +00:00
class AdminServiceProvider extends ServiceProvider
{
/**
* Bootstrap services.
*
* @return void
*/
public function boot()
{
include __DIR__ . '/../Http/routes.php';
2018-07-11 05:41:27 +00:00
$this->loadTranslationsFrom(__DIR__ . '/../Resources/lang', 'admin');
2018-06-20 05:06:27 +00:00
$this->publishes([
2018-06-20 08:22:48 +00:00
__DIR__ . '/../../publishable/assets' => public_path('vendor/webkul/admin/assets'),
2018-06-20 05:06:27 +00:00
], 'public');
$this->loadViewsFrom(__DIR__ . '/../Resources/views', 'admin');
2018-06-25 11:00:42 +00:00
$this->composeView();
$this->app->register(EventServiceProvider::class);
2018-06-25 11:00:42 +00:00
}
/**
* Bind the the data to the views
*
* @return void
*/
protected function composeView()
{
2018-08-01 06:11:33 +00:00
view()->composer(['admin::catalog.products.create', 'admin::catalog.products.edit'], function ($view) {
$accordians = current(Event::fire('admin.catalog.products.accordian.create'));
$view->with('form_accordians', $accordians);
});
2018-07-12 07:12:48 +00:00
view()->composer(['admin::layouts.nav-left', 'admin::layouts.nav-aside', 'admin::layouts.tabs'], function ($view) {
2018-06-25 11:00:42 +00:00
$menu = current(Event::fire('admin.menu.create'));
2018-07-02 09:29:27 +00:00
$keys = explode('.', $menu->currentKey);
$subMenus = $tabs = [];
2018-07-12 07:12:48 +00:00
if (count($keys) > 1) {
2018-07-02 09:29:27 +00:00
$subMenus = [
'items' => $menu->sortItems(array_get($menu->items, current($keys) . '.children')),
'current' => $menu->current,
'currentKey' => $menu->currentKey
];
2018-07-12 07:12:48 +00:00
if (count($keys) > 2) {
2018-07-02 09:29:27 +00:00
$tabs = [
'items' => $menu->sortItems(array_get($menu->items, implode('.children.', array_slice($keys, 0, 2)) . '.children')),
'current' => $menu->current,
'currentKey' => $menu->currentKey
];
}
2018-06-25 11:00:42 +00:00
}
2018-07-11 05:41:27 +00:00
2018-07-02 09:29:27 +00:00
$view->with('menu', $menu)->with('subMenus', $subMenus)->with('tabs', $tabs);
2018-06-20 05:06:27 +00:00
});
}
/**
* Register services.
*
* @return void
*/
2018-07-31 07:50:54 +00:00
public function register()
{
// $this->mergeConfigFrom(
// __DIR__ . '/../Config/auth.php',
// 'auth'
// );
}
2018-06-20 05:06:27 +00:00
/**
* Merge the given configuration with the existing configuration.
*
* @param string $path
* @param string $key
* @return void
*/
protected function mergeConfigFrom($path, $key)
{
$config = $this->app['config']->get($key, []);
$this->app['config']->set($key, array_merge($config, require $path));
}
}