attachments()->get(); Log::debug('Found ' . $attachments->count() . ' attachments.'); /** @var Attachment $attachment */ foreach ($attachments as $attachment) { $originalFile = storage_path('upload') . DIRECTORY_SEPARATOR . 'at-' . $attachment->id . '.data'; if (file_exists($originalFile)) { Log::debug('Stored 1 attachment'); $decrypted = Crypt::decrypt(file_get_contents($originalFile)); $newFile = storage_path('export') . DIRECTORY_SEPARATOR . $this->job->key . '-Attachment nr. ' . $attachment->id . ' - ' . $attachment->filename; file_put_contents($newFile, $decrypted); $this->getFiles()->push($newFile); } } } }