Ejemplo n.º 1
0
 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();
         }
     }
 }
Ejemplo n.º 2
0
 public function storeComment($id)
 {
     $thread = ForumThread::find($id);
     if ($thread == null) {
         Redirect::route('forum')->with('fail', "That thread does not exist.");
     }
     $validator = Validator::make(Input::all(), array('body' => 'required|min:5'));
     if ($validator->fails()) {
         return Redirect::route('forum-thread', $id)->withInput()->withErrors($validator)->with('fail', "Please fill in the form correctly.");
     } else {
         $comment = new ForumComment();
         $comment->body = Input::get('body');
         $comment->author_id = Auth::user()->id;
         $comment->thread_id = $id;
         $comment->category_id = $thread->category->id;
         $comment->group_id = $thread->group->id;
         if ($comment->save()) {
             return Redirect::route('forum-thread', $id)->with('success', "The comment was saved.");
         } else {
             return Redirect::route('forum-thread', $id)->with('fail', "An error occured wile saving.");
         }
     }
 }
 public function storeComment($id)
 {
     $thread = ForumThread::find($id);
     if ($thread == null) {
         # code...
         return Redirect::route('forum-thread', $id)->with('fail', "There is nothing to do with this");
     }
     $validator = Validator::make(Input::all(), ['comment' => 'required|min:4|max:65000']);
     if ($validator->fails()) {
         # code...
         return Redirect::route('forum-thread', $id)->withInput()->withErrors($validator)->with('fail', "please fix these errors");
     } else {
         $comment = new ForumComment();
         $comment->body = Input::get('comment');
         $comment->author_id = Auth::user()->id;
         $comment->thread_id = $id;
         $comment->category_id = $thread->category_id;
         $comment->group_id = $thread->group->id;
         if ($comment->save()) {
             # code...
             return Redirect::route('forum-thread', $id)->with('success', "The comment is saved");
         } else {
             return Redirect::route('forum-thread', $id)->with('fail', "An error occured while saving");
         }
     }
 }