src/Serializer/JsonApiSerializer.php
private function fillRelationshipAsCollection($data, $relationship, $key)
    {
        foreach ($relationship as $index => $relationshipData) {
            $data['data'][$index]['relationships'][$key] = $relationshipData;

            if ($this->shouldIncludeLinks()) {
                $data['data'][$index]['relationships'][$key] = array_merge([
                    'links' => [
                        'self' => "{$this->baseUrl}/{$data['data'][$index]['type']}/{$data['data'][$index]['id']}/relationships/$key",
                        'related' => "{$this->baseUrl}/{$data['data'][$index]['type']}/{$data['data'][$index]['id']}/$key",
                    ],
                ], $data['data'][$index]['relationships'][$key]);
            }
        }

        return $data;
    }
private function fillRelationshipAsCollection($data, $relationship, $key)
    {
        foreach ($relationship as $index => $relationshipData) {
            $data['data'][$index]['relationships'][$key] = $relationshipData;

            if ($this->shouldIncludeLinks()) {
                $data['data'][$index]['relationships'][$key] = array_merge([
                    'links' => [
                        'self' => "{$this->baseUrl}/{$data['data'][$index]['type']}/{$data['data'][$index]['id']}/relationships/$key",
                        'related' => "{$this->baseUrl}/{$data['data'][$index]['type']}/{$data['data'][$index]['id']}/$key",
                    ],
                ], $data['data'][$index]['relationships'][$key]);
            }
        }

        return $data;
    }
private function fillRelationshipAsCollection ( $ data , $ relationship , $ key ) { foreach ( $ relationship as $ index => $ relationshipData ) { $ data [ 'data' ] [ $ index ] [ 'relationships' ] [ $ key ] = $ relationshipData ; if ( $ this -> shouldIncludeLinks ( ) ) { $ data [ 'data' ] [ $ index ] [ 'relationships' ] [ $ key ] = array_merge ( [ 'links' => [ 'self' => "{$this->baseUrl}/{$data['data'][$index]['type']}/{$data['data'][$index]['id']}/relationships/$key" , 'related' => "{$this->baseUrl}/{$data['data'][$index]['type']}/{$data['data'][$index]['id']}/$key" , ] , ] , $ data [ 'data' ] [ $ index ] [ 'relationships' ] [ $ key ] ) ; } } return $ data ; }
Loops over the relationships of the provided data and formats it

@param $data
@param $relationship
@param $key

@return array
Loops over the relationships of the provided data and formats it