invoices = $invoices; $this->company = $company; } /** * Execute the job. * * * @return void */ public function handle() { MultiDB::setDB($this->company->db); $tempStream = fopen('php://memory', 'w+'); $options = new Archive(); $options->setOutputStream($tempStream); # create a new zipstream object $file_name = date('Y-m-d') . '_' . str_replace(' ', '_', trans('texts.invoices')).".zip"; $path = $this->invoices->first()->client->invoice_filepath(); $zip = new ZipStream($file_name, $options); foreach ($invoices as $invoice) { $zip->addFileFromPath(basename($invoice->pdf_file_path()), public_path($invoice->pdf_file_path())); } $zip->finish(); Storage::disk(config('filesystems.default'))->put($path . $file_name, $tempStream); fclose($tempStream); //fire email here return Storage::disk(config('filesystems.default'))->url($path . $file_name); } }