]> _ Git - fluidbook-toolbox.git/commitdiff
done #3465 @0.25
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 4 Mar 2020 18:16:45 +0000 (19:16 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 4 Mar 2020 18:16:45 +0000 (19:16 +0100)
app/Http/Controllers/Admin/Operations/DownloadOperation.php

index 5854ee6d7fb32fbbce2f82314df443938a63247a..9217201e308030f49c1f3de5b3e28302e38a7242 100644 (file)
@@ -2,7 +2,10 @@
 
 namespace App\Http\Controllers\Admin\Operations;
 
+use Cubist\Util\Files\Files;
+use Cubist\Util\Zip;
 use Illuminate\Support\Facades\Route;
+use Illuminate\Support\Str;
 
 trait DownloadOperation
 {
@@ -13,8 +16,17 @@ trait DownloadOperation
 
     protected function download($id)
     {
-        $id = $this->crud->getCurrentEntryId() ?? $id;
-        $entry=$this->crud->getEntry($id);
-        $entry->compile();
+        $compilepath = protected_path('quiz/final/' . $id);
+        $entry = $this->crud->getEntry($id);
+        $entry->compile($compilepath);
+
+        $fname = Str::slug($id . ' ' . $entry->getAttribute('title')) . '.zip';
+        $dest = protected_path('quiz/download/' . $fname);
+
+        Zip::archive($compilepath, $dest);
+
+        return response(null)->header('Content-Type', 'application/zip')
+            ->header('Content-Disposition', 'attachment; filename="' . $fname . '"')
+            ->header('X-Sendfile', $dest);
     }
 }