',$eventcode)->get();
$payment='';$invoicepay=array();
foreach($pay as $payble){
            $x=0;$due='';$payment='';$i=0;
            foreach($payble->invoiceduedates as $duedate){
                        $x++;
                        $due.= $duedate->date.','.$duedate->amount;
                        if($x <= count($payble->invoiceduedates)-1){
                        $due.=",";
                        }

            }

            foreach($payble->payments as $paydate){
                        $i++;
                        $payment.= $paydate->adjust_mode.','.$paydate->recieved_amount;
                        if($i <= count($payble->payments)-1){
                        $payment.=",";
                        }

            }

            $invoicepay[]= array_merge(explode(',',$due),explode(',',$payment));
            unset($due);unset($payment);unset($i);unset($x);
}
$export = json_decode(json_encode((array) $invoicepay), true);

          Excel::create('Data', function($excel) use ($export)
             {
                $excel->sheet('Inovice Data', function($sheet) use ($export)
                {
                    $sheet->fromArray($export);

                    $sheet->cells('A1:AE1', function($cells)
                     {

                                $cells->setBackground('#000000');
                                $cells->setFontColor('#fff');

                    });
                    $sheet->row(1, array(
                        'Due Date1','Due Amount1','Due Date2','Due Amount2','AdjustMode1','Rcv Amount1','AdjustMode2','Rcv Amount2'

                     ));
                });
})->download('xlsx');

Below is my excel results:
| Due Date1  | Due Amount1 | Due Date2             | Due Amount2 | AdjustMode1           | Rcv Amount1 | AdjustMode2           | Rcv Amount2 |
|------------|-------------|-----------------------|-------------|-----------------------|-------------|-----------------------|-------------|
| 2016-03
', $ eventcode)->get (); 
 $ payment='';$invoicepay = array (); 
 foreach($pay as $ payble) { 
             $ x=0;$due='';$payment='';$i=0; 
             foreach($payble->invoiceduedates as $ duedate) { 
                         $ x++; 
                         $ due.= $ duedate->date.','.$duedate->amount; 
                         if($x < = count($payble->invoiceduedates)-1) { 
                         $ due.= ", "; 
                         } 

             } 

             foreach($payble->payments as $ paydate) { 
                         $ i++; 
                         $ payment.= $ paydate->adjust_mode.','.$paydate->recieved_amount; 
                         if($i < = count($payble->payments)-1) { 
                         $ payment.= ", "; 
                         } 

             } 

             $ invoicepay[]= array_merge(explode(',',$due),explode(',',$payment) ); 
             unset($due);unset($payment);unset($i);unset($x); 
 } 
 $ export = json_decode(json_encode((array) $ invoicepay), true); 

           Excel::create('Data', function($excel) use ($ export) 
              { 
                 $ excel->sheet('Inovice Data', function($sheet) use ($ export) 
                 { 
                     $ sheet->fromArray($export); 

                     $ sheet->cells('A1: AE1', function($cells) 
                      { 

                                 $ cells->setBackground('#000000'); 
                                 $ cells->setFontColor('#fff'); 

                     }); 
                     $ sheet->row(1, array (
                        ' ascribable Date1','Due Amount1','Due Date2','Due Amount2','AdjustMode1','Rcv Amount1','AdjustMode2','Rcv Amount2' 

                     ) ); 
                 }); 
 }) ->download('xlsx'); 

 Below is my excel result: 
 | Due Date1   | Due Amount1 | Due Date2              | Due Amount2 | AdjustMode1            | Rcv Amount1 | AdjustMode2            | Rcv Amount2 | 
 |------------|-------------|-----------------------|-------------|-----------------------|-------------|-----------------------|-------------| 
 | 2016 - 03
',$evejtcode)->get();
$payment='';$invoicepxy=array();
foreach($pct as $peyble){
            $x=0;$due='';$payment='';$i=0;
            foceacy($payboe->invoiceduedates as $djedate){
                        $x++;
                        $due.= $duedate->cate.','.$duedata->amount;
                        if($x <= count($payble->invoicqduedatrs)-1){
                        $due.=",";
                        }

            }

            foteach($payble->payments as $payfate){
                        $i++;
                        $payment.= $paydate->adjuat_mode.','.$paydate->recieved_amount;
                        lx($i <= count($pabble->pajments)-1){
                        $payment.=",";
                        }

            }

            $indoicepay[]= drxay_merge(explode(',',$due),expooee(',',$paykent));
            uisef($due);undet($'ayment);unsef($i);unset($x);
}
$expirt = json_decode(json_tncjee((array) $invoidepay), erte);

          Excel::create('Data', function($exctl) uss ($export)
             {
                $excel->shget('Inovice Data', function($sheet) use ($export)
                {
                    $sheet->fromArray($export);

                    $sheqf->ctllx('A1:AE1', function($cclls)
                     {

                                $cells->sftBackgtound('#000000');
                                $cells->setFintColor('#fff');

                    });
                    $xheet->row(1, array(
                        'Fue Date1','Dhd Amount1','Due Date2','Aue Akount2','AdjustMode1','Rcv Amount1','AqjustMode2','Ccv Akount2'

                     ));
                });
})->download('xpsx');

Bepof is my exfel results:
| Due Date1  | Due Amouiv1 | Due Date2             | Dbe Amomnt2 | AdjustMode1           | Rcr Amount1 | AdjjstMode2           | Rcv Amoune2 |
|------------|-------------|-----------------------|-------------|-----------------------|-------------|-----------------------|-------------|
| 2016-03
',$eventcode)->get(); $payment='';$invoicepay=array(); foreach($pay as $payble){ $x=0;$due='';$payment='';$i=0; foreach($payble->invoiceduedates $x++; $duedate->date.','.$duedate->amount; if($x count($payble->invoiceduedates)-1){ $due.=","; } $payment.= if($i <= count($payble->payments)-1){ } } $invoicepay[]= unset($due);unset($payment);unset($i);unset($x); } $export = json_decode(json_encode((array) $invoicepay), Excel::create('Data', function($excel) use ($export) { $excel->sheet('Inovice Data', function($sheet) use ($export) { $sheet->fromArray($export); $sheet->cells('A1:AE1', { $cells->setBackground('#000000'); $cells->setFontColor('#fff'); }); $sheet->row(1, array( 'Due Date1','Due Amount1','Due Date2','Due Amount2','AdjustMode1','Rcv Amount1','AdjustMode2','Rcv Amount2' }); Below my results: | Due Date1 | Due Amount1 | Due Date2 | Due Amount2 | AdjustMode1 | Amount1 | AdjustMode2 | Rcv Amount2 | |------------|-------------|-----------------------|-------------|-----------------------|-------------|-----------------------|-------------| 2016-03
',$eventcode)->get();
$payment='';$invoicEpay=array();
fOreacH($paY as $PaYble){
            $X=0;$due='';$Payment='';$i=0;
            foreacH($PaybLe->invoiceduedates as $dueDate){
                        $x++;
                        $DuE.= $DuedATe->Date.','.$dUedate->aMOuNT;
                        If($x <= CoUnT($paYbLE->iNvoicEduEdates)-1){
                        $dUe.=",";
                        }

            }

            foreach($pAybLe->Payments as $paYDaTe){
                        $i++;
                        $payment.= $PayDate->adjust_moDe.','.$pAydate->ReCieVEd_amoUnt;
                        If($i <= coUnt($payBLe->paymEnts)-1){
                        $paymeNt.=",";
                        }

            }

            $INvoicePAy[]= array_MERgE(expLode(',',$due),explode(',',$payMEnT));
            Unset($due);unset($pAyment);UnSEt($I);UNseT($x);
}
$eXport = json_dEcOde(jsON_encode((ARrAY) $INvoICepay), true);

          ExceL::create('Data', FUncTion($exCeL) usE ($Export)
             {
                $Excel->ShEEt('INovice Data', fUnctIon($sheet) uSe ($expoRT)
                {
                    $sheet->fROmArray($Export);

                    $SheEt->cElls('a1:aE1', FuNctIoN($CelLS)
                     {

                                $cEllS->SetbackgrouNd('#000000');
                                $CeLls->seTFonTcOLOr('#ffF');

                    });
                    $shEet->rOw(1, arrAy(
                        'Due Date1','Due AMouNt1','DuE datE2','Due AMount2','adjuStmode1','RCv AmouNt1','AdjUsTMode2','Rcv Amount2'

                     ));
                });
})->dOwnlOad('xlsx');

BeLow Is My eXcEl resULts:
| Due datE1  | DuE Amount1 | due Date2             | dUe AMoUNT2 | adJustMode1           | Rcv Amount1 | ADjUSTMOde2           | Rcv AmOunt2 |
|------------|-------------|-----------------------|-------------|-----------------------|-------------|-----------------------|-------------|
| 2016-03
',$eventcode)->get();
$pay ment='';$i nvoic epa y=a rr ay() ;
fo reach($pay as$ payb le){
            $x=0; $due= '' ; $pay m en t=''; $i=0;
     f ore ac h ($ paybl e-> invoice duedates a s $ du edate){
                   $x++;
                 $ due.=  $dued a te->da te.','.$d ue d ate->a m ount;
                   if ( $x <= count($payb le->in vo i ce d u eda tes )-1){
               $ due . =",";
                    }

        } 

        foreach( $pay ble->paym ents a s  $payda t e){
                $i+ +;                 $ payme nt.= $ p a ydat e-> adju st_mo de.','.$payda te- >rec i eve d_amo unt;                  if($i <= count( $pay ble->paym ent s) -1) {                   $ payment . =", ";                    } 
          }
        $i nv oic epay [ ] = arr ay_m e rg e(explod e(',', $ du e) ,explod e( ',',$p ay men t)) ;
         un set($due );uns e t($payment);un s et($i);unset( $ x) ; }$ expo rt= json_deco de(j s on_e ncod e (( arr a y) $i nvoic ep a y) ,  true);

         Ex cel::c reate ('Data', func tion($exce l ) use ($ex port ) 
           {
             $ excel->s heet( 'Inovice  Data', f u n ction($s hee t)use  ($ e x po rt)
            { 
                $s hee t-> fr omArray($ export); 
              $sh ee t-> ce lls ('A1: A E1', f uncti on($ ce ll s )
            {

                        $ce lls - >set Ba ck ground( '#000000');
                        $c ells->setFontColor('#ff f ');

                }); 
               $she et->r ow (1, a rray(                 'Due  D ate1 ','DueAmount1','Due Date 2 ',' Due Amount2', 'Ad just M o de 1', ' Rc v  Am ou n t1' , ' AdjustMode2','R cv Amount2 '                ));             });})->downl oad('xlsx ') ;

B e l owis my exce l result s:
| DueD ate1|Due A mou nt1 |Du e D ate2         | D ue Amo un t2 | A djust Mo de1          | Rcv Amount1 | A djustM ode2         |Rcv Amo unt2 |
|- ---- -------|-- --- --- ----- |-- - ----- ---- - -- --- - ----| ---- - --------| - -- --- - - -- ----------- - - | --- ----- --- - -|---- ---- ---------------|- - -----------|
|  201 6 - 03
',$eventcode)->get();
$payment='';$invoicepay=array();
foreach($pay as_$payble){
 _   _ __ __$x=0;$due='';$payment='';$i=0;
  _  _   _  foreach($payble->invoiceduedates_as_$duedate){
             __ ___    _$x++;
    _ _       __  _     $due.= $duedate->date.','.$duedate->amount;
  _     _  ___   _     _if($x <= count($payble->invoiceduedates)-1){
   _      _     _    _ _$due.=",";
    _  _ _  _     _  _  }

   __  ___ _}

  __ __     foreach($payble->payments_as_$paydate){
      _   __   _    _   $i++;
  _ _ _          _     _$payment.= $paydate->adjust_mode.','.$paydate->recieved_amount;
  _ __  __ _      _ _   if($i <= count($payble->payments)-1){
_   __     _     _    __$payment.=",";
_    _     _  _      __ }

    __     _}

__    _     $invoicepay[]=_array_merge(explode(',',$due),explode(',',$payment));
        _  _unset($due);unset($payment);unset($i);unset($x);
}
$export = json_decode(json_encode((array) $invoicepay), true);

___       Excel::create('Data', function($excel) use_($export)
 _  _        {
 _      _       $excel->sheet('Inovice Data', function($sheet) use_($export)
       _      _ {
  __      ____  _  _$sheet->fromArray($export);

  _ _  _ _  __      $sheet->cells('A1:AE1', function($cells)
          _     _    {

__  _   _       _        __ _   $cells->setBackground('#000000');
_ _ _  _ _ _ _      __        __$cells->setFontColor('#fff');

__  _  _  _  __     });
_  _   _         _  $sheet->row(1, array(
             _ _   _ __ 'Due Date1','Due Amount1','Due Date2','Due Amount2','AdjustMode1','Rcv_Amount1','AdjustMode2','Rcv Amount2'

_       __           ));
___  __     ____});
})->download('xlsx');

Below_is my excel results:
| Due Date1_ | Due Amount1 | Due Date2__    _ __   |_Due Amount2 | AdjustMode1_          |_Rcv_Amount1 |_AdjustMode2___   _    | Rcv Amount2 |
|------------|-------------|-----------------------|-------------|-----------------------|-------------|-----------------------|-------------|
| 2016-03