Hi! First of all thanks for the plugin! =)
I'm using laravel 5.6 and the last version of the plugin.
adminSimulationExport.php
namespace App\Exports;
use Illuminate\Contracts\View\View;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\FromView;
use Maatwebsite\Excel\Concerns\FromQuery;
use Maatwebsite\Excel\Concerns\Exportable;
use App\Simulation;
class adminSimulationExport implements FromQuery
{
use Exportable;
public function __construct($params)
{
$this->orderBy = $params["orderBy"];
$this->active = $params["active"];
$this->direction = $params["direction"];
}
public function query()
{
return Simulation::where('active',$this->active )->orderBy($this->orderBy, $this->direction);
}
}
API.PHP (routes)
$params = [];
$csv = Excel::download(new adminSimulationExport($params), 'simulations.xlsx');
// return response()->download( $csv );
return response()->file( $csv );
When trying to download/show the file i get this error:
The file "HTTP/1.0 200 OK Cache-Control: public Content-Disposition: attachment; filename="simulations.xlsx" Date: Wed, 06 Jun 2018 19:45:33 GMT Last-Modified: Wed, 06 Jun 2018 19:45:33 GMT " does not exist
I'm getting the headers. Is it supposed to work like this?
I'd like to get the path to the file i just created and download/show! =)
Thanks in advance!
@theoarena just return Excel::download(new adminSimulationExport($params), 'simulations.xlsx') it makes a download response for it out of the box :)
Thanks, @patrickbrouwers! It麓s working now =)