Пример #1
0
 public function store(CommentRequest $request)
 {
     $comment = new Comment();
     $comment->hash = blogify()->makeHash('comments', 'hash', true);
     $comment->content = $request->comment;
     $comment->user_id = $this->auth->user()->id;
     $comment->post_id = $this->post->byHash($request->post)->id;
     $comment->revised = $this->config->approve_comments_first ? 1 : 2;
     $comment->save();
     tracert()->log('comments', $comment->id, $this->auth->user()->id, 'create');
     session()->flash('notify', ['success', 'Your comment has been added']);
     return back();
 }
 /**
  * @param string $hash
  * @param string $new_revised
  * @return \Illuminate\Http\RedirectResponse
  */
 public function changeStatus($hash, $new_revised)
 {
     $revised = $this->checkRevised($new_revised);
     if ($revised === false) {
         abort(404);
     }
     $comment = $this->comment->byHash($hash);
     $comment->revised = $revised;
     $comment->save();
     $this->tracert->log('comments', $comment->id, $this->auth_user->id, $new_revised);
     $message = trans('blogify::notify.comment_success', ['action' => $new_revised]);
     session()->flash('notify', ['success', $message]);
     return redirect()->route('admin.comments.index');
 }
 /**
  * @return void
  */
 private function buildDataArrayForAuthor()
 {
     $this->data['published_posts'] = $this->post->where('publish_date', '<=', date('Y-m-d H:i:s'))->forAuthor()->count();
     $this->data['pending_review_posts'] = $this->post->whereStatusId(2)->forAuthor()->count();
     $post_ids = $this->post->forAuthor()->lists('id');
     $this->data['pending_comments'] = $this->comment->byRevised(1)->whereIn('post_id', $post_ids)->count();
 }