public function getAllSelect($prompt = false) { $ui_modules = UiModule::all(); if ($prompt) { $ar_ui_modules = array(); } else { $ar_ui_modules = array('' => 'Selecione...'); } foreach ($ui_modules as $ui_profile) { $ar_ui_modules[$ui_profile->id] = $ui_profile->name; } return $ar_ui_modules; }
public function edit($id) { if (!empty($id)) { $ui_module = new UiModule(); $ui_module = $ui_module->find($id); $this->_dataView['ui_module'] = $ui_module; } $params = \Input::all(); if (!empty($params)) { $validator = \Validator::make($params, array('name' => array('required'))); if (!$validator->fails()) { $params['route'] = 'uiadmin/' . strtolower($ui_module->module); $ui_module->fill($params); if ($ui_module->save()) { return \Redirect::to('uiadmin/uimodule'); } } else { $messages = $validator->messages(); $this->_dataView['messages_errors'] = $messages->all(); } } $ui_modules_exists = UiModule::all(); $modules = app('modules'); $ui_modules = array(); foreach ($modules->enabled() as $module_name => $module) { $ob_module = (object) null; if (strtolower($ui_module->module) == strtolower($module_name)) { $ob_module->id = $ui_module->id; } else { $ob_module->id = 0; } $ob_module->name = $module_name; $ob_module->exists = false; foreach ($ui_modules_exists as $module_exists) { if ($module_name == $module_exists->module) { $ob_module->exists = true; break; } } array_push($ui_modules, $ob_module); } $this->_dataView['ui_modules'] = $ui_modules; $this->_dataView['module_action'] = 'Editar'; return view('uimodule::form', $this->_dataView); }
public function items(Request $request, $id) { if (!empty($id)) { $ui_menu = new UiMenu(); $ui_menu = $ui_menu->find($id); } $this->_dataView['ui_menu'] = $ui_menu; $params = \Input::all(); if (!empty($params)) { $menuserialize = json_decode($params['menuserialize']); if (!empty($menuserialize)) { \DB::update('UPDATE ui_menu_item SET parent_id = NULL WHERE ui_menu_id = ' . $ui_menu->id); $ui_menu_item = new UiMenuItem(); $ui_menu_item->order($menuserialize); $this->_dataView['message_success'] = 'Ordenação salva com sucesso!'; } } $ui_modules = UiModule::all(); $ar_ui_modules = array('' => 'Selecione...'); foreach ($ui_modules as $ui_module) { $ar_ui_modules[$ui_module->id] = $ui_module->name; } $ui_menu_items = UiMenuItem::where('ui_menu_id', '=', $ui_menu->id)->whereNull('parent_id')->orderBy('position')->get(); $module_menu = $ui_menu->moduleMenu($ui_menu_items); $ui_admin_auth = $request->session()->get('ui_admin_auth'); $ui_admin_auth->admin_menu = $ui_menu->adminMenu($ui_menu_items); $request->session()->set('ui_admin_auth', $ui_admin_auth); $targets = array('0' => 'Mesma aba', '1' => 'Nova aba'); $this->_dataView['targets'] = $targets; $this->_dataView['module_menu'] = $module_menu; $this->_dataView['ui_modules'] = $ar_ui_modules; $this->_dataView['module_action'] = 'Itens - ' . $ui_menu->name; return view('uimenu::items', $this->_dataView); }
public function permission($id) { if (!empty($id)) { $ui_profile = new UiProfile(); $ui_profile = $ui_profile->find($id); $this->_dataView['ui_profile'] = $ui_profile; } $params = \Input::all(); if (!empty($params)) { foreach ($params['permissions'] as $module => $actions) { //Recupera o modulo selecionado $ui_module = UiModule::where('module', '=', $module)->first(); //Apaga todas as permissões do módulo selecionado \DB::table('ui_acl')->where('ui_profile_id', '=', $ui_profile->id)->whereRaw('ui_module_action_id IN (SELECT id FROM ui_module_action WHERE ui_module_id = ' . $ui_module->id . ')')->delete(); foreach ($actions as $ui_module_action_id => $action) { $ui_acl = new UiAcl(); $ui_acl->ui_profile_id = $ui_profile->id; $ui_acl->ui_module_action_id = $ui_module_action_id; $ui_acl->save(); } } return \Redirect::to('uiadmin/uiprofile'); } $ui_modules = UiModule::all(); $ar_ui_modules = array(); foreach ($ui_modules as $ui_module) { $ui_module_action = UiModuleAction::where('ui_module_id', '=', $ui_module->id)->get(); $ar_module_action = array(); foreach ($ui_module_action as $module_action) { $ob_module_action = (object) $module_action->toArray(); $ui_acl = UiAcl::where('ui_profile_id', '=', $ui_profile->id)->where('ui_module_action_id', '=', $module_action->id)->first(); if (!empty($ui_acl)) { $ob_module_action->exists = true; } else { $ob_module_action->exists = false; } array_push($ar_module_action, $ob_module_action); } $ob_ui_mobile = (object) $ui_module->toArray(); $ob_ui_mobile->actions = $ar_module_action; array_push($ar_ui_modules, $ob_ui_mobile); } $ui_modules = $ar_ui_modules; $this->_dataView['ui_modules'] = $ui_modules; $this->_dataView['module_action'] = 'Permissões'; return view('uiprofile::permission', $this->_dataView); }