title: Laravel commenting system for specific "post"
body: <p>i am doing a site where you can upload code(codesnippet). And i want so that people can comment on the code the user uploads. And i want a new thread for every code that uploads. But i have a problem heres is my code
  Form:</p>
  
  <pre><code>{{ Form::open(array('url'=&gt;'comments')) }}
  @if (Auth::check())
      {{ Form::hidden('codesnippet_id' -&gt; $codesnipp_id)) }}
      {{ Form::textarea('comment', null, array('placeholder'=&gt;'comment')) }}
      {{ Form::submit('comment', array('class'=&gt;'comment-knapp'))}}
      {{ Form::close() }}
      @endif
  
  
  @foreach($comments as $comment)
          {{ $comment-&gt;created_at }}&lt;br&gt;
          {{ $comment-&gt;comment }}&lt;br&gt;&lt;br&gt;
  @endforeach
  </code></pre>
  
  <p>Routes:</p>
  
  <pre><code>Route::post('comments/{id?}', array('uses' =&gt; 'CommentController@newComment'));
  
  Route::get('comments/{id?}', array('uses' =&gt; 'CommentController@getComments'));
  </code></pre>
  
  <p>Model:</p>
  
  <pre><code>&lt;?php
  
  
  class Comment extends Eloquent {
  
      public function getComments($codesnipp_id){
          $getComments = DB::table('comments')
                          -&gt;where('codesnippet_id', '=', $codesnipp_id)
                          -&gt;select('id', 'comment', 'votes', 'user_id', 'created_at', 'codesnippet_id')
                          -&gt;get();
          return $getComments;
      }
  
      public function writeComment($userID, $comment, $codesnipp_id){
          DB::table('comments')
          -&gt;insert(array('user_id' =&gt; $userID, 
                         'comment' =&gt; $comment,
                         'codesnippet_id' =&gt; $codesnipp_id));
      }
  }
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>&lt;?php
  
  class CommentController extends BaseController {
  
      public $restful = true;
      public $CM;
  
  
      function __construct(){
          $this-&gt;CM = new Comment();
      }
  
      public function newComment($codesnipp_id){
          $comment = Input::get('comment');
  
          $rules = array('comment'=&gt;'required|alphaNum|min:1|max:255');
  
          $validator = Validator::make(Input::all(), $rules);
  
          if ($validator-&gt;fails()) {
              return 'Du måste vara inloggad för att kunna kommentera! 
                      &lt;a href="#loginmodal" id="modaltrigger"&gt;Klicka här&lt;/a&gt; för att logga in';
          } else {
              // $comment = Input::get('comment');
              $username = Session::get('user');
              echo $username . '&lt;br&gt;&lt;br&gt;&lt;br&gt;';
              $userID = $this-&gt;get_id_by_string('users','username' , $username);
              return $this-&gt;CM-&gt;writeComment($userID, $comment, $codesnipp_id);
  
              // return Redirect::to('comment')-&gt;with('message', 'Något gick fel')-&gt;withErrors($validator)-&gt;withInput();
          }
      }
  
      public function getComments($codesnipp_id)
      {
          $comments = $this-&gt;CM-&gt;getComments($codesnipp_id);
          return $comments;
      }
  }
  </code></pre>
  
  <p>The problem is that i get an error Missing argument 1 with $codesnipp_id in my controllers.
  By the way in my comments table i have an codesnippet_id that is connected to the codesnippet table id. 
  I think i am missing something and i need help!
  Ps. sorry for the bad english.</p>