I want to export some data(laravel collection ) as csv file.
public function exportTransaction()
{
$ticket=all();
$filename=$customer['firstname']."_".date('Y-m-d').".csv";
$file_path=storage_path(). "/transactions"."/".$filename;
$handle = fopen($file_path,"w+");
fputcsv($handle, array('date'));
foreach($ticket as $row) {
fputcsv($handle, array($row['orderDate']));
}
fclose($handle);
$headers = array(
'Content-Type' => 'text/csv',
);
return Response::download($file_path, $filename, $headers);
}
This is my code. I'm getting this error
local.ERROR: exception 'Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException' with message 'The file "/var/www/html/FootballTicketPad/geethu/bondcms/app/storage/transactions/we1_2018-03-20.csv" does not exist' in /var/www/html/FootballTicketPad/geethu/bondcms/vendor/symfony/http-foundation/File/File.php:37