Add meta data from laravel collection to resource?

41 Views Asked by At

I have a laravel collection and its resource, to laravel collection I'm adding meta data.

I'm trying to add it like stated in multiple source like laravel docs or this stackoverflow article or this one.

$metaData = ['total' => $elements->count(), 'active_element_id' => $activeElement];

NaviItemResource::collection($elements)->additional([$metaData])

I see this in additional data from collection, but I would need it also in Resource file like stated on image.

Is that possible to add in resource as well?

enter image description here

0

There are 0 best solutions below