public function action_postreply($topic_slug, $topic_id)
 {
     $topic = Forumtopic::find($topic_id);
     if (is_null($topic)) {
         return Event::first('404');
     }
     $category = $topic->category;
     $rules = array('content' => 'required|min:2');
     $content = trim(Input::get('content'));
     $validator = Validator::make(compact('content'), $rules);
     if ($validator->fails()) {
         return Redirect::back()->with_errors($validator)->with_input();
     }
     $message = new Forummessage();
     $message->content = BBCodeParser::parse($content);
     $message->content_bbcode = $content;
     $message->forumtopic_id = $topic->id;
     $message->forumcategory_id = $category->id;
     $message->save();
     $url = URL::to_action('forums::topic@index', compact('topic_slug', 'topic_id')) . '?page=last#message' . $message->id;
     return Redirect::to($url);
 }
 public function saveWithMessage(Forummessage $message)
 {
     $this->user_id = Auth::user()->id;
     $incSlug = 0;
     $originalSlug = $this->slug;
     $this->sticky = false;
     do {
         try {
             parent::save();
             $incSlug = 0;
         } catch (Exception $e) {
             if ($e->getCode() == 23000) {
                 $incSlug++;
             }
             $this->slug = $originalSlug . '-' . $incSlug;
         }
     } while ($incSlug != 0);
     $this->category->nb_topics++;
     $this->category->save();
     $message->forumtopic_id = $this->id;
     $message->forumcategory_id = $this->forumcategory_id;
     $message->save();
     return $this;
 }