public function newComment(CommentFormRequest $request)
 {
     $comment = new Comment(array('post_id' => $request->get('post_id'), 'content' => $request->get('content')));
     $comment->save();
     //         return redirect()->back()->with('status', 'Your comment has been created!');
     return redirect()->back()->with('status', 'Your comment has been created!');
 }
Пример #2
0
 /**
  * Post a comment on a blog post
  * POST
  *
  * @param Request $request
  * @param int $id
  * @param string $title
  * @return Response
  */
 public function postComment(Request $request, $id, $title)
 {
     $this->validate($request, ['comment' => 'required']);
     $comment = new BlogCommentManager();
     $comment->author = \Auth::user()->guid;
     $comment->date = date('Y-m-d H:i:s');
     $comment->blog_id = $id;
     $comment->text = nl2br($request->comment);
     $comment->save();
     return redirect()->route('blog.view', [$id, $title]);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['nickname' => 'required|unique:comments|max:15', 'content' => 'required|max:255']);
     $comment = new Comment();
     $comment->nickname = htmlspecialchars(Input::get('nickname'));
     $comment->email = htmlspecialchars(Input::get('email'));
     $comment->website = htmlspecialchars(Input::get('website'));
     $comment->content = htmlspecialchars(Input::get('content'));
     if ($comment->save()) {
         return Redirect::to('admin');
     } else {
         return Redirect::back()->withInput()->withError('啊哦,吐槽不成:(');
     }
 }
Пример #4
0
 public function actionOne()
 {
     $id = $_GET['id'];
     // If a comment has been sent:
     if ($this->isPost()) {
         $comm = new ModelComment();
         // fields cannot be empty!
         $success = $comm->fill(['article_id' => $id, 'author' => htmlspecialchars($_POST['author']), 'text' => htmlspecialchars($_POST['text'])]);
         $success ? $comm->save() : ($_SESSION['error'] = 'Fill all fields!');
         header('Location: /article/one?id=' . $id . '#comment');
         exit;
     }
     // Getting the particular article:
     $item = ModelArticle::getOneById($id);
     $this->isFound($item);
     $comments = ModelComment::getByColumn('article_id', $id);
     $view = new View(['item' => $item, 'comments' => $comments, 'title' => $item->title]);
     $view->displayPage('articles/one');
 }