Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Queued Export Failing on Export of hasMany related model #43

Open
wirjo opened this issue Feb 25, 2019 · 6 comments
Open

Queued Export Failing on Export of hasMany related model #43

wirjo opened this issue Feb 25, 2019 · 6 comments

Comments

@wirjo
Copy link

wirjo commented Feb 25, 2019

Problem

  • The queued export appears to be failing when conducting a QueuedExportof a hasMany related model. In our case, we have Clients hasMany Documents and we would like to export the Documents under the Client view. The parameters that we used are:
return (new QueuedExport)
                ->withDisk('s3')
                 ->withHeadings()
                 ->withChunkCount(200);
  • The job in the queue appears to fail and keeps re-attempting. We have traced the issue to where the AppendQueryToSheet job appears to be returning an error. The error appears to trace to $row on map($row) being an object and not an array.

https://github.com/Maatwebsite/Laravel-Nova-Excel/blob/806cafa2cf38de9a8f6c8cbc835445f406148b69/src/Actions/ExportToExcel.php#L227

Diagnosis

Any assistance is appreciated.

Version Used
Laravel-Nova-Excel: v1.10
Laravel: 5.7
PHP: 7.2

@GlennM
Copy link

GlennM commented Feb 25, 2019

Could you perhaps include the PHP & Laravel versions as well? Thanks!

@wirjo
Copy link
Author

wirjo commented Feb 25, 2019

Added. Thanks for maintaining this awesome plugin.

@patrickbrouwers
Copy link
Member

Do you have a full stack trace of the exception/error?

@wirjo
Copy link
Author

wirjo commented Feb 25, 2019

Sorry for the readability, but what I have for now is this screenshot here. When I get back to a computer in 24h, I can also provide the text output.

https://www.dropbox.com/s/27ligg5pyic009l/IMG_4596.PNG?dl=0

@patrickbrouwers
Copy link
Member

This is fine, thanks!

@wirjo
Copy link
Author

wirjo commented Feb 26, 2019

FYI - we are fixing this via abstracting the map() logic into a separate class. Functionality now seems to be working correctly for our use cases.


namespace App;

use Illuminate\Database\Eloquent\Model as Model;
use Maatwebsite\LaravelNovaExcel\Actions\ExportToExcel;
use Illuminate\Contracts\Queue\ShouldQueue;

class SargonExport extends ExportToExcel implements ShouldQueue
{

    /**
     * @var string
     */
    public $name = 'Export to Excel';

    public function map($row): array
    {
    	if ( $row instanceof Model ) {
    		// do nothing
    	} else {
    		// Convert to array first
    		$row = (array) $row;
    	}

    	return parent::map($row);
    	
    }

} 

?>```

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants