This commit is contained in:
Saufi
2026-06-03 08:51:22 +08:00
commit a14d43fe34
347 changed files with 38197 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
<?php
namespace App\Http\Controllers;
use App\Models\ApplicationDocument;
use Illuminate\Support\Facades\Storage;
use Symfony\Component\HttpFoundation\StreamedResponse;
class DocumentDownloadController extends Controller
{
public function admin(ApplicationDocument $document): StreamedResponse
{
abort_unless(
in_array($document->document_type, ApplicationDocument::ALLOWED_FOR_ADMIN, true),
403
);
abort_unless(Storage::disk($document->disk)->exists($document->path), 404);
activity('documents')
->performedOn($document)
->causedBy(request()->user())
->withProperties(['document_type' => $document->document_type])
->log('document_downloaded_by_admin');
return Storage::disk($document->disk)->download($document->path, $document->original_name);
}
public function finance(ApplicationDocument $document): StreamedResponse
{
abort_unless(
in_array($document->document_type, ApplicationDocument::ALLOWED_FOR_FINANCE, true),
403
);
abort_unless(Storage::disk($document->disk)->exists($document->path), 404);
activity('documents')
->performedOn($document)
->causedBy(request()->user())
->withProperties(['document_type' => $document->document_type])
->log('bank_statement_downloaded_by_finance');
return Storage::disk($document->disk)->download($document->path, $document->original_name);
}
}