How to use the chunk method of Laravel Excel?

0
public function uploadNotaCorte(Request $request, EstadoRepository $estadoRepository)
{
    $error      = array();
    $path       = $request->file('file')->getRealPath();
    $notasCorte = Excel::load($path, function($reader) {
    })->get();

    $chunk      = $notasCorte->chunk(100);

    foreach ($notasCorte as $key => $notaCorte) {
     //minhas regras
    }
    return  $error;
}

I'm having a hard time implementing the chunk method. The above code usually works on smaller files, but on files larger than error because of size.

I need to upload a file with 120,000 records and trying to use chunk for this, I do not know what I can do wrong and looked at the documentation and very simple and I could not solve the problem can someone help me?

Laravel Excel Documentation

    
asked by anonymous 22.12.2017 / 21:52

0 answers