public function deleteGroup()
 {
     $groupIds = Input::get('id');
     $groups = $this->groups->findAll($groupIds);
     XeDB::beginTransaction();
     try {
         foreach ($groups as $group) {
             $this->groups->delete($group);
         }
     } catch (Exception $e) {
         XeDB::rollBack();
         throw $e;
     }
     XeDB::commit();
     return redirect()->back()->with('alert', ['type' => 'success', 'message' => '삭제되었습니다.']);
 }
 public function update($id, Request $request)
 {
     /** @var MemberEntityInterface $member */
     $member = $this->members->find($id, ['mails', 'groups']);
     if ($member === null) {
         $e = new InvalidArgumentHttpException();
         $e->setMessage('존재하지 않는 회원입니다.');
         throw $e;
     }
     // default validation
     $validate = Validator::make($request->all(), ['email' => 'email', 'displayName' => 'required', 'rating' => 'required', 'status' => 'required']);
     if ($validate->fails()) {
         $messages = $validate->messages();
         $message = $messages->first();
         $e = new InvalidArgumentException();
         $e->setMessage($message);
         throw $e;
     }
     // display name validation
     $displayName = trim($request->get('displayName'));
     if ($member->getDisplayName() !== $displayName) {
         $this->handler->validateDisplayName($displayName);
     }
     $memberData = $request->except('groupId', 'profileImgFile', '_token');
     // encrypt password
     if (!empty($memberData['password'])) {
         $memberData['password'] = Hash::make($memberData['password']);
     } else {
         unset($memberData['password']);
     }
     if ($profileFile = $request->file('profileImgFile')) {
         /** @var MemberImageHandler $imageHandler */
         $imageHandler = app('xe.member.image');
         $memberData['profileImageId'] = $imageHandler->updateMemberProfileImage($member, $profileFile);
     }
     $inputtedGroup = $request->get('groupId', []);
     $currentGroups = array_pluck($member->groups ?: [], 'id');
     $newGroups = array_diff($inputtedGroup, $currentGroups);
     $oldGroups = array_diff($currentGroups, $inputtedGroup);
     XeDB::beginTransaction();
     try {
         $member->fill($memberData);
         $member = $this->members->update($member);
         // join to new group
         $newGroups = $this->groups->findAll($newGroups);
         foreach ($newGroups as $group) {
             $this->groups->addMember($group, $member);
         }
         // remove from old groups
         if ($member->groups !== null) {
             foreach ($member->groups as $group) {
                 if (in_array($group->id, $oldGroups)) {
                     $this->groups->exceptMember($group, $member);
                 }
             }
         }
     } catch (Exception $e) {
         XeDB::rollBack();
         throw $e;
     }
     XeDB::commit();
     return redirect()->back()->with('alert', ['type' => 'success', 'message' => '수정되었습니다.']);
 }
 /**
  * getItemAccessPermission
  *
  * @param MenuItem $item to find permission target item object
  *
  * @return \Xpressengine\Permission\Permission
  * @throws \Xpressengine\Permission\Exceptions\WrongInstanceException
  */
 public function getItemAccessPermission(MenuItem $item)
 {
     $registered = $this->permission->findRegistered($this->permissionType, $item->getBreadCrumbsKeyString());
     $pureGrant = $registered->pure(Action::ACCESS);
     $mode = $pureGrant === null ? "inherit" : "manual";
     $menuAccessGrant = $registered->offsetGet(Action::ACCESS);
     $groups = $this->groupRepo->findAll($menuAccessGrant['group']);
     $users = $this->memberRepo->findAll($menuAccessGrant['user']);
     $excepts = $this->memberRepo->findAll($menuAccessGrant['except']);
     return ['mode' => $mode, 'rating' => $menuAccessGrant['rating'], 'group' => $groups, 'user' => $users, 'except' => $excepts];
 }