Example #1
0
 /**
  * Execute the console command
  *
  * @return mixed
  */
 public function handle()
 {
     PointLog::where('createdAt', '<', date('Y-m-d') . ' 00:00:00')->delete();
 }
 public function pointLog()
 {
     $list = PointLog::orderBy('createdAt', 'desc')->get();
     return XePresenter::make('openseminar_1212::views.manager.pointLog', ['list' => $list]);
 }
Example #3
0
 /**
  * 댓글 등록 시 글 작성자에게 이메일 발송
  * 인터셉셥 사용
  *
  * @see http://xpressengine.io/docs/3.0/Interception#사용법
  * @see http://xpressengine.io/plugin/xe_aoplist
  * @return void
  */
 protected function pointInterception()
 {
     // 게시물 등록 인터셉트
     intercept(BoardHandler::class . '@add', static::getId() . '::board.add', function ($addFunc, array $args, UserInterface $user, ConfigEntity $config) {
         /** @var Board $board */
         $board = $addFunc($args, $user, $config);
         $pointLog = new PointLog();
         $pointLog->userId = $user->getId();
         $pointLog->point = 2;
         //            관리자에서 설정한 값으로 사용하도록
         //            $config = app('xe.config')->get('openseminar');
         //            $pointLog->point = $config->get('document_point');
         $pointLog->createdAt = date('Y-m-d H:i:s');
         $pointLog->save();
         $point = Point::find($user->getId());
         if ($point === null) {
             $point = new Point();
         }
         $point->userId = $user->getId();
         $point->point = $pointLog->where('userId', $user->getId())->sum('point');
         $point->save();
         return $board;
     });
     // 댓글 등록 인터셉트트
     intercept(CommentHandler::class . '@create', static::getId() . '::comment.add', function ($addFunc, array $inputs, UserInterface $user = null) {
         /** @var Comment $comment */
         $comment = $addFunc($inputs, $user);
         if ($user == null) {
             $user = Auth::user();
         }
         $pointLog = new PointLog();
         $pointLog->userId = $user->getId();
         $pointLog->point = 1;
         //            관리자에서 설정한 값으로 사용하도록
         //            $config = app('xe.config')->get('openseminar');
         //            $pointLog->point = $config->get('comment_point');
         $pointLog->createdAt = date('Y-m-d H:i:s');
         $pointLog->save();
         $point = Point::find($user->getId());
         if ($point === null) {
             $point = new Point();
         }
         $point->userId = $user->getId();
         $point->point = $pointLog->where('userId', $user->getId())->sum('point');
         $point->save();
         return $comment;
     });
 }