title: Laravel Collection Return
body: <p>I am trying to figure out why laravel 5.6 when you have a collection it prints out the json response paginated than if you are using a normal return response with json on a paginated list. So I have right now this returning in my collection.</p>
  
  <pre><code>{
  "data": [],
  "links": {
      "first": "http://local/api/v3/x?=1",
      "last": "http://local/api/v3/x?=1",
      "prev": null,
      "next": null
  },
  "meta": {
      "current_page": 1,
      "from": 1,
      "last_page": 1,
      "path": "http://local/api/v3/x",
      "per_page": "5",
      "to": 3,
      "total": 3
  }
  }
  </code></pre>
  
  <p>And what I want it to look like is: </p>
  
  <pre><code>{
  "current_page": 1,
  "data": [],
  "first_page_url": "http://local/api/v3/x?=1",
  "from": null,
  "last_page": 1,
  "last_page_url": "http://local/api/v3/x?=1",
  "next_page_url": null,
  "path": "http://local/api/v3/x",
  "per_page": 50,
  "prev_page_url": null,
  "to": null,
  "total": 0
  }
  </code></pre>
  
  <p>I have tried to use this following code in the collection and it doesnt work, I have found a few functions to get the data I Want but I am still missing most of the data.</p>
  
  <pre><code>&lt;?php
  
  namespace App\Http\Resources\V3;
  
  use Illuminate\Http\Resources\Json\ResourceCollection;
  
  class DeedTypeCollection extends ResourceCollection
  {
  public $collects = 'App\Http\Resources\V3\x';
  
  /**
   * Transform the resource collection into an array.
   *
   * @param  \Illuminate\Http\Request  $request
   * @return array
   */
  public function toArray($request)
  {
      return [
          'current_page' =&gt; $this-&gt;currentPage(),
          'data' =&gt; $this-&gt;collection,
          'first_page_url' =&gt; $this-&gt;links['first'],
          'from' =&gt; $this-&gt;meta['from'],
          'last_page' =&gt; $this-&gt;meta['last_page'],
          'last_page_url' =&gt; $this-&gt;links['last'],
          'next_page_url' =&gt; $this-&gt;links['next'],
          'path' =&gt; $this-&gt;meta['path'],
          'per_page' =&gt; $this-&gt;meta['per_page'],
          'prev_page_url' =&gt; $this-&gt;links['prev'],
          'to' =&gt; $this-&gt;meta['to'],
          'total' =&gt; $this-&gt;meta['total']
      ];
  }
  }
  </code></pre>
  
  <p>Why does laravel change the default pagination on the collections and how can I fix this to match the default/second dataset.</p>
  
  <p>Here is where the query is built.</p>
  
  <pre><code>/**
   *  Function: prepareIndexSelect.
   *
   *  @param: $request - Request sent to controller
   *
   *  Description: Returns queried collection.
   */
  public static function prepareIndexSelect($request)
  {
      $model = new self();
      $per_page = 50;
      $page = 1;
      $order_by = $model-&gt;getKeyName();
      $sort_by = 'asc';
  
      if ($request-&gt;has('per_page')) {
          $per_page = $request-&gt;input('per_page');
      }
  
      if ($request-&gt;has('sortBy')) {
          $order_by = $request-&gt;input('sortBy');
      }
  
      if ($request-&gt;has('sortByAsc')) {
          $sort_by = $request-&gt;input('sortByAsc');
      }
  
      if ($request-&gt;has('page')) {
          $page = $request-&gt;input('page');
      }
  
      return $model-&gt;when($request-&gt;has('fields'), function ($query) use ($request) {
          self::prepareSelectColumns($query, $request-&gt;input('fields'));
      })-&gt;when($request-&gt;has('includes'), function ($query) use ($request) {
          self::prepareIncludedTables($query, $request-&gt;input('includes'));
      })-&gt;whereSearch($request-&gt;input('search'))
      -&gt;orderBy("{$order_by}", "{$sort_by}")
      -&gt;paginate($per_page, null, null, $page);
  }
  </code></pre>