title: Using groupBy with resource collection laravel
body: <p>I am working on api, and using resource to send data. I want to send collection which is grouped by status. So far I have done the following:</p>
  <pre><code>public function data(){
      $collection = ModelNameResource::collection(
          ModelName::query()
              -&gt;latest()
              -&gt;get()
      );
      $data = $collection-&gt;groupBy('status');
      return $data;
  }
  </code></pre>
  <p>Although I have got what I want but want to know if there is the better approach to achieve this?</p>