public function index() { Allow::permission($this->module['group'], 'view'); $elements = new Dictionary(); $tbl_dic = $elements->getTable(); ## Ordering $elements = $elements->orderBy(DB::raw('-' . $tbl_dic . '.order'), 'DESC')->orderBy($tbl_dic . '.created_at', 'ASC')->orderBy('name', 'ASC'); ## View access if (!Allow::superuser()) { $elements = $elements->where('view_access', '!=', '1'); } if (!Allow::action($this->module['group'], 'hidden')) { $elements = $elements->where('view_access', '!=', '2'); } #Helper::d(Allow::superuser()); #Helper::d('-'); #Helper::dd(Allow::action($this->module['group'], 'edit')); ## Hide dics, which are entities if (!Allow::superuser() && !Allow::action($this->module['group'], 'hidden')) { $elements = $elements->where('entity', NULL); } $tbl_dicval = new DicVal(); $tbl_dicval = $tbl_dicval->getTable(); #$elements = $elements->paginate(30); $elements = $elements->select($tbl_dic . '.*', DB::raw('COUNT(`' . $tbl_dicval . '`.`id`) AS count'))->leftJoin($tbl_dicval, $tbl_dicval . '.dic_id', '=', $tbl_dic . '.id')->groupBy($tbl_dic . '.id')->get(); #Helper::tad($elements); return View::make($this->module['tpl'] . 'index', compact('elements')); }