3 months ago

Resource Collection Help

Posted 3 months ago by movepixels

I have a RatesCollection and RateResource and normally this setup works as I get the collection of records and in the Collection use the Resource to format the records how I like.

Example in the RatesCollection return:

'records' => RateResource::collection($this->collection),

But in this case i need to group rates like so:

'records' => RateResource::collection($this->collection->groupBy('category')),

Thus creating a nested multi-dimension array / object which the RateResource does not like and is not expecting.

How can I use the RateResource to loop thru the grouped records array / object?



Please sign in or create an account to participate in this conversation.