title: how to make Pagination in laravel to return values in json format
body: <p>I have client controller that sends request and server controller that processes the request and sends response.</p>
  
  <p>How to paginate the response json data in laravel. </p>
  
  <p>Server Controller  </p>
  
  <pre><code>public function index() {
  
      $data = languages::where('is_active','1')-&gt;orderBy('id','desc')-&gt;get();   
      $response = Response::json($data,200);
      return $response;
  }
  </code></pre>
  
  <p>Client Controller</p>
  
  <pre><code>public function index()
  {
      $url = url('languagesService');
      $data = json_encode(array("username" =&gt; $this -&gt; username,"password" =&gt; $this -&gt; password));
  
      $ch = curl_init($url);
      curl_setopt($ch, CURLOPT_URL,$url);
      curl_setopt($ch, CURLOPT_HEADER,false);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
      curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
      curl_setopt($ch, CURLOPT_POST, true);
      curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  
      $response = CURL_EXEC($ch);
      $data = json_decode($response);
      return View::make("languages.index")-&gt;with("data",$data);
  
  }
  </code></pre>