i try to export a excel file from a blade view with an unserialize object from a text column in my database but i get an error .
Call to undefined method Illuminate\Database\Query\Builder::transform()
Here my controller :
public function ExportExcel($id)
{
$order = Order::find($id);
$order->transform(function ($order , $key){
$order->cart = unserialize($order->cart);
return $order;
});
Excel::create('facture', function($excel) use ($order) {
$excel->sheet('Excel', function($sheet) use ($order) {
$sheet->loadView('cotisation_structure.factureExcelsingle')->with(['order' => $order]);
});
})->export('xls');
}
Here my blade view :
<html> <body>
<thead>
<tr>
<th>N° Facture</th>
<th>N° licence</th>
<th>Nom</th>
<th>Prénom</th>
<th>Type d'activité</th>
<th>Saison</th>
<th>Mode de paiement</th>
<th>Montant</th>
<th>Date Achat</th>
</tr>
</thead>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
It seems that Transform methode doesn't work for an object , only for a collection .
Someone have an idea to resolve the problem ? thanks i advance
via Mathieu Mourareau