How to use the Chunk method of Laravel Excel?

Asked

Viewed 205 times

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 trouble implementing the method chunk the above code normally works on small files plus on larger files from error because of the size.

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

Laravel Excel Documentation

  • What is the exception that is generated?

  • Good night Vigílio the problem and the memory the processing and very big due to Chunk() in this working then the server falls, I just want to pass this Chunk() method not to generate a very big processing and work correctly.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.