public function storeThreadComment($id) { $thread = ForumThread::find($id); if ($thread == null) { Redirect::route('forum-get-new-comment')->with('fail', "You posted to an invalid thread."); } $validator = Validator::make(Input::all(), array('body' => 'required|min:3|max:65000')); if ($validator->fails()) { return Redirect::route('forum-get-new-comment', $id)->withInput()->withErrors($validator)->with('fail', "Your Input doesn't match the requirements!"); } else { $comment = new ForumComment(); $comment->body = Input::get('body'); $comment->thread_id = $id; $comment->category_id = $thread->category_id; $comment->group_id = $thread->group_id; $comment->author_id = Auth::user()->id; if ($comment->save()) { return Redirect::route('forum-thread', $thread->id)->with('success', "Your comment has been added."); } else { return Redirect::route('forum-get-new-comment', $id)->with('fail', "An error occured while adding your comment")->withInput(); } } }
public function deleteComment($id) { $comment = ForumComment::find($id); if ($comment == null) { return Redirect::route('forum')->with('fail', "That comment does not exist."); } $threadid = $comment->thread->id; if ($comment->delete()) { return Redirect::route('forum-thread', $threadid)->with('success', "The comment was deleted."); } else { return Redirect::route('forum-thread', $threadid)->with('fail', "An error occured while deleting the comment."); } }
public function deleteComment($id) { $comment = ForumComment::find($id); $threadId = $comment->thread_id; if ($comment == null) { # code... Redirect::route('forum-home')->with('fail', "The comment is not Available anymore"); } if ($comment->delete()) { # code... return Redirect::route('forum-thread', $threadId)->with('success', "Comment has been successfully deleted"); } else { return Redirect::route('forum-thread', $threadId)->with('fail', "Something went wrong while deleting"); } }