samedi 4 décembre 2021

Catch an error while importing huge CSV in queue using laravel excel

I am using ShouldQueue method to have the large CSV into Queue but the errors of validations I am not able to catch them!

public function registerEvents(): array
{
    return [
        ImportFailed::class => function(ImportFailed $event) {
            dd($event); // This I will write into the FILE or send EMAIL but the job runs successfully but validation errors keep empty.
            $this->importedBy->notify(new ImportHasFailedNotification);
        },
    ];
}

My code looks like below

public function registerEvents(): array
    {
        return [
            ImportFailed::class => function(ImportFailed $event) {
            $filename = public_path('tmp').'/validation_error.txt';
            $myfile = fopen($filename, "w");
            fwrite($myfile, "domo");
            fclose($myfile);
            },
        ];
    }

I am in hope that if there is any error validation_error.txt file will have "Demo" inside it.

Also, I have crossed verify by removing ShouldQueue it gives me proper errors for email already exists a kind of.

Please help if you have any ideas! Thanks!



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3xUVQit
via IFTTT

Aucun commentaire:

Enregistrer un commentaire