Skip to content

Instantly share code, notes, and snippets.

@holisticnetworking
Created February 15, 2017 21:01
Show Gist options
  • Save holisticnetworking/8f9bdd673b8f81e02a9b3fc108e6d432 to your computer and use it in GitHub Desktop.
Save holisticnetworking/8f9bdd673b8f81e02a9b3fc108e6d432 to your computer and use it in GitHub Desktop.
See line 19, where the problem lies.
if( $this->request->query( 'fmt' ) == 'items' ) :
$invoices = collection( $invoices )->map( function( $invoice, $key ) use ( $columns ) {
// Iterated through line items, rather than invoices:
$lis = collection( $invoice->line_items )->map( function( $line_item, $k ) use ( $invoice, $columns ) {
$line = [];
foreach( $columns as $ckey=>$meta ) :
// For line item lists:
if( preg_match( '/line_item/i', $meta ) ) :
$meta = preg_replace( '/line_item\./i', '', $meta );
$line[] = $line_item->{$meta};
// For invoice lists:
else :
$line[] = $invoice->{$meta};
endif;
endforeach;
return $line;
} )->toArray();
return $lis;
} )->combine(
'{n}',
function ( $line ) { return $line; }
)->toArray();
die( pr( $invoices ) );
endif;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment