I created a query that works on a single query but when I use ->get()
it prompt
Object of class stdClass could not be converted to string
Here is my code:
$result = DB::table('users')->get(); // the data you want to download as csv
$csv = (array)$result; // stored the data in a array
return Excel::create('csvfile', function ($excel) use ($csv) {
$excel->sheet('mySheet', function ($sheet) use ($csv) {
$sheet->fromArray($csv);
});
})->download('xls');