Gives me the error in the title. If i replace queue by send, works fine. So its clearly complaining about the two parameters in the mail object when sent to the queue. Is there any way around this?
For some reason the mail enters on a loop when i do the proposed solution. To test i'm not using the $request anywhere, i only passing it as shown by @lostdreamer_nl to the SendDocument Mailable. I took all references also from the SendDocument.blade.php.
Here is the Mailalble:
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Support\Facades\File;
use App\Jobs\DeleteFiles;
use App\Document;
class SendDocuments extends Mailable
{
use Queueable, SerializesModels;
public $files;
public $request;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct($files, $request)
{
$this->files = $files;
$this->request = $request;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
$message = $this->markdown('mails.sendDocuments');
if ($this->files) {
foreach ($this->files as $file) {
File::copy(storage_path('app/' . $file->file_id), public_path($file->file_id));
$message->attach(public_path($file->file_id), [
'as' => $file->type->document_type_name . '-' . $file->audit . '.pdf',
'mime' => 'application/pdf'
]);
DeleteFiles::dispatch(public_path($file->file_id))->delay(now()->addSeconds(config('system.deleteTime')));
}
}
return $message;
}
}