mercredi 5 février 2020

Maatwebsite is not fetching data of relational table in laravel

I am try to export csv file with maatwebsite. Query I write is fetching data of other table also with which it is having relation. but it is exporting csv file only with one table data.


    $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)
            {

        $sheet->fromArray($data);
        foreach($data as $customer)
        {

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

        }

    })->download('xlsx');

I want to fetch data of both tables in csv file



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire