Conditions | 2 |
Paths | 1 |
Total Lines | 18 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
18 | public function handle(string $filename, Request $request) |
||
19 | { |
||
20 | $assets = Asset::whereIn('id', (array) $request->input('asset_ids', []))->get(); |
||
21 | |||
22 | // enable output of HTTP headers TODO: this should be moved to the controller instead... |
||
23 | $options = new Archive(); |
||
24 | $options->setSendHttpHeaders(true); |
||
25 | |||
26 | $zip = new ZipStream($filename, $options); |
||
27 | |||
28 | $assets->each(function(Asset $asset) use($zip){ |
||
29 | if(file_exists($asset->getFirstMediaPath())) { |
||
30 | $zip->addFileFromPath($asset->filename(), $asset->getFirstMediaPath()); |
||
31 | } |
||
32 | }); |
||
33 | |||
34 | // Output the zip as download |
||
35 | $zip->finish(); |
||
36 | } |
||
38 |