mad-lawsuit/app/Http/Controllers/DocumentController.php
TheMaddax b7125cf2b7 Phase 4: Production deployment configuration
- Add Docker configuration (Dockerfile, docker-compose.yml)
- Add Nginx and Supervisor configuration
- Add deployment documentation (DEPLOYMENT.md)
- Complete Phase 3 data migration (63 entries, 63 docs, 28 subs)
- Add responsive PDF viewer component
- Fix date format to American (MM/DD/YYYY)
- Update typography to match v1.0
- Add admin dashboard with full CRUD operations
- Configure PostgreSQL with secure password
- Connect to caddy_network for reverse proxy
- Ready for production deployment
2025-12-17 19:12:32 -07:00

35 lines
1,007 B
PHP

<?php
namespace App\Http\Controllers;
use App\Models\Document;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
use Symfony\Component\HttpFoundation\StreamedResponse;
class DocumentController extends Controller
{
/**
* Download a document by ID.
*/
public function download(int $id): StreamedResponse
{
$document = Document::findOrFail($id);
// Files are stored in public disk (storage/app/public/documents/)
// Check if file exists
if (!Storage::disk('public')->exists($document->file_path)) {
abort(404, 'Document file not found.');
}
// Stream the file to the browser
return Storage::disk('public')->download(
$document->file_path,
$document->original_filename,
[
'Content-Type' => $document->mime_type,
'Content-Disposition' => 'inline; filename="' . $document->original_filename . '"',
]
);
}
}