mercredi 5 février 2020

`Row `1` must be array` in laravel

I am trying to import csv file in laravel with help of maatwebsite . I have query which is bringing data from two table both have relation with each other. it is exporting only one table data when I try to fetch data of both tables it gives me an error of Row1must be array

$data = SaleOrder::where('id',$id)->with('customers')->get()->toArray();

    return Excel::create('Packlist Sale Order '.$id, function($excel) use ($data) {
            $excel->sheet('mySheet', function($sheet) use ($data)
            {




            foreach($data as $customer)
            {

              $sheet->fromArray($customer['customers']);

            }

            $sheet->fromArray($data);


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

I want fetch data of both tables in csv file



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire