Пример #1
0
 public function index_onShow()
 {
     if (($checkedIds = post('checked')) && is_array($checkedIds) && count($checkedIds)) {
         foreach ($checkedIds as $id) {
             if (!($comment = Comment::find($id))) {
                 continue;
             }
             $comment->published = 1;
             $comment->save();
             $helper = new Helper();
             $comments = $helper->getChildren($id);
             DB::table('xeor_comments_comments')->whereIn('id', $comments)->update(array('published' => 1));
         }
         Flash::success('Successfully show those comments.');
     }
     return $this->listRefresh();
 }
Пример #2
0
 public function onDeleteComment()
 {
     // get comment id
     $id = post('id');
     // get user
     $user = self::getUser();
     // find comment
     $comment = Comment::find($id);
     // if user is author delete comment
     if (isset($user) && $user->id == $comment->user_id && $user->id != 0) {
         $comment->delete();
         $helper = new Helper();
         $comments = $helper->getChildren($id);
         $comments[] = $id;
         DB::table('xeor_comments_comments')->whereIn('id', $comments)->delete();
         return $id;
     } else {
         return;
     }
 }