public function leave(Request $request)
 {
     $confirm = $request->get('confirm_leave');
     if ($confirm !== 'Y') {
         $e = new InvalidArgumentException();
         $e->setMessage('약관의 동의가 필요합니다.');
         throw $e;
     }
     $id = $this->member->getId();
     XeDB::beginTransaction();
     try {
         $this->handler->leave($id);
     } catch (\Exception $e) {
         XeDB::rollback();
         throw $e;
     }
     XeDB::commit();
     Auth::logout();
     return redirect()->to('/');
 }
 /**
  * 회원의 프로필 이미지를 등록한다.
  *
  * @param MemberEntityInterface $member      프로필 이미지를 등록할 회원
  * @param UploadedFile          $profileFile 프로필 이미지 파일
  *
  * @return string 등록한 프로필이미지 ID
  */
 public function updateMemberProfileImage(MemberEntityInterface $member, UploadedFile $profileFile)
 {
     $disk = array_get($this->profileImgConfig, 'storage.disk');
     $path = array_get($this->profileImgConfig, 'storage.path');
     $size = array_get($this->profileImgConfig, 'size');
     // make fitted imageg
     /** @var ImageManager $imageManager */
     $imageManager = call_user_func($this->imageManagerResolver);
     $image = $imageManager->make($profileFile->getRealPath());
     $image = $image->fit($size['width'], $size['height']);
     // remove old profile image
     if ($member->profileImageId !== null && $member->profileImageId !== "") {
         $file = $this->storage->get($member->profileImageId);
         $this->storage->remove($file);
     }
     $id = $member->getId();
     // save image to storage
     $file = $this->storage->create($image->encode()->getEncoded(), $path . "/{$id}", $id, $disk);
     return $file->getId();
 }
 /**
  * 삭제 권한 확인
  *
  * @param MemberEntityInterface $author 로그인 사용자 정보
  * @return bool
  */
 public function deletePerm(MemberEntityInterface $author)
 {
     if ($this->isGuest() === true) {
         return true;
     }
     if ($author instanceof Guest == true) {
         return false;
     }
     if ($this->__get('userId') != $author->getId()) {
         return false;
     }
     return true;
 }
Esempio n. 4
0
 /**
  * 참여 정보 반환
  *
  * @param string                $targetId targetId
  * @param MemberEntityInterface $author   user instance
  * @return array|null
  */
 public function get($targetId, MemberEntityInterface $author)
 {
     return $this->repo->find(['targetId' => $targetId, 'userId' => $author->getId(), 'counterName' => $this->name]);
 }
 /**
  * 주어진 entity 정보를 저장소에 업데이트한다.
  *
  * @param MemberEntityInterface $entity 업데이트할 정보
  *
  * @return MemberEntityInterface
  */
 public function update($entity)
 {
     $data = $entity->diff();
     if (array_has($data, 'password')) {
         $entity->passwordUpdatedAt = $this->getCurrentTime();
     }
     return $this->traitUpdate($entity);
 }