fputcsv($file, $table);
should be fputcsv($file, $row)
, shouldn't it?
And convert the object to an array using Eloquent's to_array()
method: http://laravel.com/docs/database/eloquent#to-array
public function get_export()
{
$table = Cpmreport::all();
$file = fopen('file.csv', 'w');
foreach ($table as $row) {
fputcsv($file, $row->to_array());
}
fclose($file);
return Redirect::to('consolidated');
}