Exemplo n.º 1
1
 public function __construct(Request $request)
 {
     $this->currentModel = new Content();
     $this->langModel = new ContentLang();
     $this->validation = \Validator::make($request->all(), ['name' => 'required:structure|max:255']);
     $modelStructure = new Structure();
     $treeStructure = $modelStructure->get()->sortBy('position');
     foreach ($treeStructure as $key => $struct) {
         $lang = StructureLang::where(['structure_id' => $struct['id'], 'language_id' => FormLang::getCurrentLang()])->first();
         if ($lang) {
             $treeStructure[$key]->name = $lang->name;
             $treeStructure[$key]->link = action('\\Application\\Admin\\Http\\Controllers\\StructureController@getEdit', ['id' => $struct['id']]);
         } else {
             unset($treeStructure[$key]);
         }
     }
     $treeStructure->linkNodes();
     $str = $treeStructure->toArray();
     $witgetStructureTree = new TreeBuilder();
     $TreeStructure = $witgetStructureTree->view($str, '<ul>{val}</ul>', '<li data-href="/admin/content/structure/{id}">{name}</li>', '<li data-href="/admin/content/structure/{id}" class="folder expanded">{name}<ul>{|}</ul></li>');
     view()->share('StructureTree', $TreeStructure);
     view()->share('id_structure', $request->route('id_structure'));
     $this->itemName = 'Content';
     $this->template = 'content';
     $this->layout = 'dual_sidebars';
     parent::__construct();
 }
Exemplo n.º 2
0
 public function getIndex()
 {
     $build = new TreeBuilder();
     $structures = $this->currentModel->get()->sortBy('position');
     foreach ($structures as $key => $struct) {
         $lang = $this->langModel->where(['structure_id' => $struct['id'], 'language_id' => FormLang::getCurrentLang()])->first();
         if ($lang) {
             $structures[$key]->name = $lang->name;
             $structures[$key]->link = action('\\Application\\Admin\\Http\\Controllers\\StructureController@getEdit', ['id' => $struct['id']]);
         } else {
             unset($structures[$key]);
         }
     }
     $structures->linkNodes();
     $str = $structures->toArray();
     $activeTemplate = '<div class="checkbox checkbox-switchery switchery-xs switchery-double pull-right active-button">' . '<input type="checkbox" data-item="' . $this->template . '" data-id="{id}" class="switchery active-button" {cheked} ></div>';
     $editTemplate = '<span class="edit-buttons pull-right">' . '<a href="{link}" class="on-default edit-button"><i class="fa fa-pencil"></i></a>' . '<a data-item="' . $this->template . '" data-id="{id}" class="on-default remove-button"><i class="fa fa-trash-o"></i></a></span>';
     $view = $build->view($str, '<ol class="dd-list">{val}</ol>', '<li class="dd-item" data-id="{id}">' . $activeTemplate . $editTemplate . '<div class="dd-handle">{name}</div></li>', '<li class="dd-item" data-id="{id}">' . $activeTemplate . $editTemplate . '<div class="dd-handle">{name}</div><ol class="dd-list">{|}</ol></li>');
     view()->share('scripts', ['<script type="text/javascript" src="/assets/admin/js/structure/jquery.nestable.js"></script>', '<script type="text/javascript" src="/assets/admin/js/structure/nestable.js"></script>']);
     view()->share('styles', ['<link href="/assets/admin/css/nestable.css" rel="stylesheet" type="text/css">']);
     view()->share('title', 'Structures list');
     return view('admin::structure.index', compact('view'));
     //return view('admin::structure.nestable');
 }