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



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2ubwcK7
via IFTTT

تعليقات

المشاركات الشائعة من هذه المدونة

I am unable to figure out how to create payment collection request, after a form has been submitted in laravel

laravel, mysql transaction not working after failed one time