Merge pull request #317 from bagisto/jitendra

Modified config creation
This commit is contained in:
JItendra Singh 2018-12-14 15:03:39 +05:30 committed by GitHub
commit c26af29596
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 16 deletions

View File

@ -6,6 +6,7 @@ use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Webkul\Admin\Facades\Configuration;
use Webkul\Core\Repositories\CoreConfigRepository as CoreConfig;
use Webkul\Core\Tree;
/**
* Configuration controller
@ -29,6 +30,12 @@ class ConfigurationController extends Controller
*/
protected $coreConfig;
/**
*
* @var array
*/
protected $configTree;
/**
* Create a new controller instance.
*
@ -41,7 +48,26 @@ class ConfigurationController extends Controller
$this->_config = request('_config');
$this->coreConfig = $coreConfig;
$this->prepareConfigTree();
}
/**
* Prepares config tree
*
* @return void
*/
public function prepareConfigTree()
{
$tree = Tree::create();
foreach(config('core') as $item) {
$tree->add($item);
}
$tree->items = core()->sortItems($tree->items);
$this->configTree = $tree;
}
/**
@ -51,10 +77,26 @@ class ConfigurationController extends Controller
*/
public function index()
{
// if(!request()->route('slug'))
// return redirect()->route('admin.configuration.index', ['slug' => 'marketplace']);
if(!request()->route('slug') && !request()->route('slug2'))
return redirect()->route('admin.configuration.index', $this->getDefaultConfigSlugs());
return view($this->_config['view']);
return view($this->_config['view'], ['config' => $this->configTree]);
}
/**
* Returns slugs
*
* @return array
*/
public function getDefaultConfigSlugs()
{
$firstItem = current($this->configTree->items);
$secondItem = current($firstItem['children']);
$slugs = explode('.', $secondItem['key']);
return ['slug' => current($slugs), 'slug2' => end($slugs)];
}
/**

View File

@ -86,18 +86,6 @@ class AdminServiceProvider extends ServiceProvider
$view->with('menu', $tree);
});
view()->composer(['admin::layouts.nav-aside', 'admin::layouts.tabs', 'admin::configuration.index'], function ($view) {
$tree = Tree::create();
foreach(config('core') as $item) {
$tree->add($item);
}
$tree->items = core()->sortItems($tree->items);
$view->with('config', $tree);
});
view()->composer(['admin::users.roles.create', 'admin::users.roles.edit'], function ($view) {
$tree = Tree::create();