Black Friday: coupon FRIDAY24 for 40% off Yearly/Lifetime membership! Read more here
Courses

Queues in Laravel

Why Queues? First Example - Email Notification with Queue

avatar

Hi teacher, good night!

Hlep-me please?.

I'm trying to use the queue concept in one of my projects together with laravel-excel that they have in one of their classes, I can populate the table with the data contained in excel normally, so there are files with more than 5 thousand records, therefore being a sync process, it stops the other connections, so I decided to make queues according to their course, so I came across a problem, here I use oracle, I tested it in mysql and it works normally, when I try to call the queue and execute it, I have the following error below, I can save the job in the database so the work does not run and generates the error in the laravel log.

Controller

   public function store(StoreFileUploadRequest $request)
    {
        if ($request->hasFile('file')) {
            Excel::import(new FileUploadImport, $request->file('file'));
            return new FileUploadResource($request);
        } 
    }

Model/Class

class FileUploadImport implements ToModel, WithBatchInserts, ShouldQueue, WithChunkReading
{

    public function model(array $row)
    {
        return new FileUpload([
            'name'             => $row[0],
            'cpf'              => $row[1],
            'data_nascimento'  => $row[2],
        ]);
    }
 
    public function batchSize(): int
    {
        return 2000;
    }
 
    public function chunkSize(): int
    {
        return 2000;
    }

Error:

 local.ERROR: Array to string conversion {"exception":"[object] (ErrorException(code: 0): Array to string conversion at C:\\laragon\\www\\Back-end\\gateway-web-backend\\vendor\\laravel\\framework\\src\\Illuminate\\Support\\Stringable.php:32)
avatar

I am try too, https://docs.laravel-excel.com/3.1/imports/queued.html.

I don´t sucess.

   public function store(StoreFileUploadRequest $request)
    {
        if ($request->hasFile('file')) {
            Excel::queueImport(new FileUploadImport, $request->file('file'));
            return new FileUploadResource($request);
        } 
    }
avatar

Interesting, it seems like there's error to convert something, could you try some other file to import? I'm pretty sure there's some invalid data in some column/row, or maybe empty row unnecessary?

avatar

Hello teacher, I reduced the lines to the maximum and put only numbers, so I have the same problem, I have tried other types of extensions too, without success, something that is incompatible with oracle and I cannot determine through the debug or the logs, because I have just this error shown earlier to you. I'm clearly out of alternatives already, :(.

My date information in excel.

1 2 3

avatar

I don't use Oracle so can't really help in there. Maybe there are too few lines in your Excel? I've heard some "bug" or feature that Excel/CSV counts only with at least 3 lines. Not sure, just blind guess, sorry can't help with personal debugging, please post on Laracasts forum.

avatar

Hi Mr. Povilas.

I was trying to access this course but the video did not show up because of this error The webpage at https://player.vimeo.com/video/732687827?h=061a2ca5c3&badge=0&loop=false&byline=false&portrait=false&title=false&speed=true&transparent=0&gesture=media might be temporarily down or it may have moved permanently to a new web address.

Can you help me so I can access it? Maybe migrate it to private Youtube playlist.

avatar

Hello, sorry for a late reply, but this might be because Vimeo is blocked in your country. There is nothing we can do about this, sorry.