Initial commit: CABM-IT (ItGlue-style MSP documentation platform)
Laravel 13 + Livewire/Volt app for managing client organizations, documents, passwords, flexible assets, virtual machines, contacts, domains, todos, shortcuts, and role-based user administration.
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Document;
|
||||
use App\Models\Organization;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
|
||||
class DocumentDownloadController extends Controller
|
||||
{
|
||||
public function __invoke(Request $request, Organization $organization, Document $document): StreamedResponse
|
||||
{
|
||||
abort_unless($document->organization_id === $organization->id, 404);
|
||||
abort_unless($document->isUpload() && $document->file_path, 404);
|
||||
|
||||
if ($request->boolean('inline')) {
|
||||
return Storage::response($document->file_path, $document->name);
|
||||
}
|
||||
|
||||
return Storage::download($document->file_path, $document->name);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user