title: How can I modify the Laravel API Resource collection response to include another 'data' wrapper with in the 'data' wrapper?
body: <pre><code>&lt;?php
  
  namespace App\Http\Resources;
  
      use Illuminate\Http\Resources\Json\ResourceCollection;
      
      class LanguageCollection extends ResourceCollection
      {
          public $collects = LanguageResource::class;
      
          /**
           * TagCollection constructor.
           * @param $resource
           */
          public function __construct($resource)
          {
              parent::__construct($resource);
          }
      
          /**
           * Transform the resource collection into an array.
           *
           * @param \Illuminate\Http\Request $request
           * @return array
           */
          public function toArray($request)
          {
              return [
                  'languages' =&gt; parent::toArray($request)
              ];
          }
      }
  </code></pre>
  <p>This would give a response structure as follows:</p>
  <p><a href="https://i.stack.imgur.com/BRNTa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BRNTa.png" alt="enter image description here" /></a></p>
  <p>But I want to put all the languages with in another wrapper called &quot;result&quot; so the response structure will look like this:</p>
  <p><a href="https://i.stack.imgur.com/hGMDQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hGMDQ.png" alt="enter image description here" /></a></p>
  <p>I don't want to hard code it this way cause this would require us to change every resource collecction.</p>
  <pre><code>   public function toArray($request)
      {
          return [
              'result' =&gt; ['languages' =&gt; parent::toArray($request)]
          ];
      }
  </code></pre>
  <p>What is the correct way to achieve this response structure?</p>