Ejemplo n.º 1
0
 public function update($id)
 {
     if (null != Input::get('permission')) {
         $permissions = Input::get('permission');
     } else {
         return Redirect::to('groups')->with('error', 'Ha ocurrido un error: Debe asignar los permisos');
     }
     try {
         $group_company = new CompanyGroup();
         $group = $this->group;
         $data['name'] = Input::get('name');
         foreach ($permissions as $index => $permission) {
             $a[$index] = 1;
         }
         $data['permission'] = json_encode($a);
         $group_company->company_id = Input::get('company');
         $group_company->group_id = $id;
         $group_company->save();
         $group::where('id', $id)->update($data);
         return Redirect::to('groups')->with('message', 'Empresa actualizada correctamente!');
     } catch (\Exception $e) {
         return Redirect::to('groups/edit/' . $id)->with('error', 'Ha ocurrido un error: ' . $e->getMessage());
     }
 }
Ejemplo n.º 2
0
 public function edit($id)
 {
     $data['module'] = $this->module;
     $data['module_name'] = $this->module_name;
     $user = $this->user;
     $data['user'] = $user::where('id', $id)->first();
     $groups_company = CompanyGroup::where('company_id', $data['user']->company_id)->get();
     if (count($groups_company) < 1) {
         $data['groups'] = array('0' => 'No hay grupos asociados a esta empresa');
     } else {
         foreach ($groups_company as $gc) {
             $groups[] = $gc->group_id;
         }
         $data['groups'] = array('0' => 'Seleccione...') + Group::whereIn('id', $groups)->lists('name', 'id');
     }
     $data['sub_module'] = 'Editar usuario';
     $data['companies'] = array('0' => 'Seleccionar') + Company::Active()->lists('name', 'id');
     $data['action'] = 'update/';
     return view('accounts.users.edit', $data);
 }