I need to export over 100K records to Excel from database using Maatwebsite Laravel excel 3.1 plugin, the problem is that I get data as an array.
$data = $this->client->getData("sc/asistencia-social/informe",$request->all());
return (new ExcelExport($data))->store('myFile.xlsx'); //using FromQuery
My ExcelExport Class :
<?php
namespace App\Exports;
use Maatwebsite\Excel\Concerns\FromQuery;
use Maatwebsite\Excel\Concerns\Exportable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\SerializesModels;
class ExcelExport implements FromQuery
{
use Exportable, SerializesModels;
private $data;
public function __construct($data)
{
$this->data = $data; //Inject data
}
public function query()
{
return $this->data;
}
}
Actually, I get a "Call to a member function chunk() on array" error. I even tried to convert it into a collection with no success. Is there any possible solution to this.