title: Laravel RESTful controller parameters
body: <p>I'm using Laravel 4 with Angular JS to handle $http requests using RESTful controllers.</p>
  
  <p>I have a RESTful controller, <code>UserController</code> that has the following functions:</p>
  
  <pre><code>public function getIndex(){
      //is Request::get() the correct way to get the parameter?
      echo json_encode(array(
        'username'=&gt;User::countUsername(Request::get('name')),
        'email'=&gt;User::countEmail(Request::get('email'))
      ));
  }
  
  public function postIndex(){
      //don't know how to get parameter
  }
  </code></pre>
  
  <p>The $http GET and POST requests I am making are below:</p>
  
  <p>GET</p>
  
  <pre><code>//is this url the correct way to send in my parameters for GET request?
  dataString = 'name='+username+'&amp;email='+email;
  $http.get('user?'+dataString).success(
      //do something with returned json
  )
  </code></pre>
  
  <p>POST</p>
  
  <pre><code>data = {
     'username':username,
     'email':email,
     'password':password
  }
  $http.post('user', data).success(
      //do something
  )
  </code></pre>
  
  <p>The <code>getIndex()</code> method works just fine, although I have doubts on whether I am using the correct procedure.</p>
  
  <p>With the above mentioned, I have two questions:</p>
  
  <ol>
  <li><p>Is <code>Request::get()</code> the correct way to retrieve parameters from the XHR GET? Is appending <code>dataString</code> to the URL in my Javascript the correct way to send in parameters the RESTful way?</p></li>
  <li><p>How do I retrieve the JSON object sent from my XHR POST? I have tried several methods including <code>Request::get()</code> and <code>Input::json()</code>, but I've had no luck.</p></li>
  </ol>
  
  <p>Thanks in advance.</p>