title: Laravel 5.5 API resources for collections (standalone data)
body: <p>I was wondering if it is possible to define different data for item resource and collection resource. </p>
  
  <p>For collection I only want to send <code>['id', 'title', 'slug']</code> but the item resource will contain extra details <code>['id', 'title', 'slug', 'user', etc.]</code></p>
  
  <p><strong>I want to achieve something like:</strong></p>
  
  <pre><code>class PageResource extends Resource
  {
      /**
       * Transform the resource into an array.
       *
       * @param  \Illuminate\Http\Request
       * @return array
       */
      public function toArray($request)
      {
          return [
              'id' =&gt; $this-&gt;id,
              'title' =&gt; $this-&gt;title,
              'slug' =&gt; $this-&gt;slug,
              'user' =&gt; [
                  'id' =&gt; $this-&gt;user-&gt;id,
                  'name' =&gt; $this-&gt;user-&gt;name,
                  'email' =&gt; $this-&gt;user-&gt;email,
              ],
          ];
      }
  }
  
  class PageResourceCollection extends ResourceCollection
  {
      /**
       * Transform the resource collection into an array.
       *
       * @param  \Illuminate\Http\Request
       * @return array
       */
      public function toArray($request)
      {
          return [
              'id' =&gt; $this-&gt;id,
              'title' =&gt; $this-&gt;title,
              'slug' =&gt; $this-&gt;slug,
          ];
      }
  }
  </code></pre>
  
  <p><strong>PageResourceCollection</strong> will not work as expected because it uses <strong>PageResource</strong> so it needs </p>
  
  <pre><code>return [
              'data' =&gt; $this-&gt;collection,
         ];
  </code></pre>
  
  <p>I could duplicate the resource into <code>PageFullResource</code> / <code>PageListResource</code> and <code>PageFullResourceCollection</code> / <code>PageListResourceCollection</code> but I am trying to find a better way to achieve the same result.</p>