I am using PHPExcel to generate an excel sheet and then output the file for download (force download). If I am to use the following from the controller file it works as expected:
return Response::download($file_path, 'myfile.xlsx');
But, I have to trigger this behavior from the Model and this does not seem to work.
Any suggestions?
You can call the response's send
method:
Response::download($file_path, 'myfile.xlsx')->send();
But I would suggest against this. It is not your model's job to handle HTTP responses.