public function changesExtractor($audits)
    {
        $suffix = isset($audits[0]['_matchingData']['AuditDeltas'][0]) ? '.{*}' : '';
        $changes = collection($audits)
            ->extract('_matchingData.AuditDeltas' . $suffix)
            ->indexBy('property_name')
            ->toArray();

        $audit = $audits[0];
        unset($audit['_matchingData']);

        $audit['original'] = collection($changes)
            ->map(function ($c) { return $c['old_value']; })
            ->map([$this, 'habtmFormatter'])
            ->map([$this, 'allBallsRemover'])
            ->toArray();
        $audit['changed'] = collection($changes)
            ->map(function ($c) { return $c['new_value']; })
            ->map([$this, 'habtmFormatter'])
            ->map([$this, 'allBallsRemover'])
            ->toArray();

        return $audit;
    }
public function changesExtractor($audits)
    {
        $suffix = isset($audits[0]['_matchingData']['AuditDeltas'][0]) ? '.{*}' : '';
        $changes = collection($audits)
            ->extract('_matchingData.AuditDeltas' . $suffix)
            ->indexBy('property_name')
            ->toArray();

        $audit = $audits[0];
        unset($audit['_matchingData']);

        $audit['original'] = collection($changes)
            ->map(function ($c) { return $c['old_value']; })
            ->map([$this, 'habtmFormatter'])
            ->map([$this, 'allBallsRemover'])
            ->toArray();
        $audit['changed'] = collection($changes)
            ->map(function ($c) { return $c['new_value']; })
            ->map([$this, 'habtmFormatter'])
            ->map([$this, 'allBallsRemover'])
            ->toArray();

        return $audit;
    }
public function changesExtractor ( $ audits ) { $ suffix = isset ( $ audits [ 0 ] [ '_matchingData' ] [ 'AuditDeltas' ] [ 0 ] ) ? '.{*}' : '' ; $ changes = collection ( $ audits ) -> extract ( '_matchingData.AuditDeltas' . $ suffix ) -> indexBy ( 'property_name' ) -> toArray ( ) ; $ audit = $ audits [ 0 ] ; unset ( $ audit [ '_matchingData' ] ) ; $ audit [ 'original' ] = collection ( $ changes ) -> map ( function ( $ c ) { return $ c [ 'old_value' ] ; } ) -> map ( [ $ this , 'habtmFormatter' ] ) -> map ( [ $ this , 'allBallsRemover' ] ) -> toArray ( ) ; $ audit [ 'changed' ] = collection ( $ changes ) -> map ( function ( $ c ) { return $ c [ 'new_value' ] ; } ) -> map ( [ $ this , 'habtmFormatter' ] ) -> map ( [ $ this , 'allBallsRemover' ] ) -> toArray ( ) ; return $ audit ; }
Converts a group of related audit logs into a single one with the
original and changed keys set.

@param array $audits The list of audit logs to compile into a single one
@return array
Converts a group of related audit logs into a single one with the original and changed keys set .