@php if(empty($data)){echo "No Data"; die();} $filename = "report"; $keys = array_keys($translation_set); $filename = $filename.".csv"; $file = fopen('php://output', 'w'); header('Content-type: application/csv'); header('Content-Disposition: attachment; filename="'.$filename.'"'); header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download"); foreach($relational_column as $key => $value){ if($value=="created_at" || $value=="updated_at") continue; if (in_array($value, $keys)) $new_value = $translation_set[$value]; else $new_value = $value; $header[] = $new_value; } fputcsv($file,$header); foreach ($data as $row){ $row = (array)$row; unset($row['created_at']); unset($row['updated_at']); fputcsv($file,$row); } fclose($file); @endphp