i'm creating function export Excel in laravel and i'm using Maatwebsite to do this. Here is code
public function exportSigns($id)
{
Excel::create('List Users', function($excel) use($id){
$sheets = [
'lList Users' => ActionUsers::with(['petition' => function ($query) use($id){
$query->where('petition_id',$id)->orderBy('created_at', 'desc');
}])->get(),
];
foreach ($sheets as $key => $signs) {
$excel->sheet($key, function ($sheet) use ($signs){
$sheet->row(1, array(
'Name',
'Email',
'Job',
'City',
'Reason',
'Time'
));
foreach ($signs as $key => $sign) {
$sheet->row($key + 2, array(
$sign->name,
$sign->email,
$sign->job,
$sign->address,
$sign->reason,
$sign->created_at,
));
}
});
}
})->download('xlsx');
}
and error is SQLSTATE[42S22]: Column not found: 1054 Unknown column 'petition_id' in 'where clause' (SQL: select * from petitions where petitions.id in (1) and petition_id = 1 order by created_at desc) Anyone can help me solve that
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire