$document, ]); } public function download(ShowDocumentRequest $request, Document $document) { return Storage::disk($document->disk)->download($document->url, $document->name); } public function downloadMultiple(DownloadMultipleDocumentsRequest $request) { $documents = Document::whereIn('id', $this->transformKeys($request->file_hash)) ->where('company_id', auth('contact')->user()->company->id) ->get(); $documents->map(function ($document) { if (auth()->user('contact')->client->id != $document->documentable->id) { abort(401); } }); $options = new Archive(); $options->setSendHttpHeaders(true); $zip = new ZipStream('files.zip', $options); foreach ($documents as $document) { $zip->addFileFromPath(basename($document->filePath()), TempFile::path($document->filePath())); } $zip->finish(); } }