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(); }
public function __construct(Request $request) { $this->currentModel = new Structure(); $this->langModel = new StructureLang(); $this->validation = \Validator::make($request->all(), ['name' => 'required:structure|max:255']); $this->itemName = 'Structure'; $this->template = 'structure'; $structures = $this->currentModel->all()->toArray(); 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; } else { unset($structures[$key]); } } $list = [0 => 'Root']; foreach ($structures as $struct) { $list[$struct['id']] = $struct['name']; } view()->share('listStructures', $list); parent::__construct(); }