I am trying to group JSON data from API response and create a relationship from it. The data I am receiving is the statistics from live football games. The response includes arrays of live fixtures. Each fixture contains data about the leagues and teams. Different fixtures may be from the same league. Now I want to retrieve the leagues and group fixtures from the same league together while maintaining the league-fixture relationship. In a way, I can query league->fixtures() and get all fixtures under the league. Here is a sample response from the API
Please help if you have a hint on how to achieve that. Thank in advance