Files
fotospiel-app/app/Http/Controllers/SuperAdmin/DataExportController.php
Codex Agent eed7699549
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
tests / ui (push) Has been cancelled
Implement compliance exports and retention overrides
2026-01-02 20:13:45 +01:00

33 lines
860 B
PHP

<?php
namespace App\Http\Controllers\SuperAdmin;
use App\Http\Controllers\Controller;
use App\Models\DataExport;
use Illuminate\Support\Facades\Storage;
use Symfony\Component\HttpFoundation\StreamedResponse;
class DataExportController extends Controller
{
public function download(DataExport $export): StreamedResponse
{
if (! $export->isReady() || $export->hasExpired() || ! $export->path) {
abort(404);
}
$disk = 'local';
if (! Storage::disk($disk)->exists($export->path)) {
abort(404);
}
return Storage::disk($disk)->download(
$export->path,
sprintf('fotospiel-data-export-%s.zip', $export->created_at?->format('Ymd') ?? now()->format('Ymd')),
[
'Cache-Control' => 'private, no-store',
]
);
}
}