add projet

This commit is contained in:
root
2026-03-05 12:29:37 -05:00
parent 8d1eef8ba8
commit 23b7db1107
9109 changed files with 1106501 additions and 73 deletions
@@ -0,0 +1,53 @@
<?php
namespace App\Http\Controllers\Api\Admin;
use App\Http\Controllers\Controller;
use App\Models\ClassProgressAttachment;
use App\Models\ClassProgressReport;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
class AdminProgressAttachmentController extends Controller
{
use HandlesProgressAttachments;
/**
* Download legacy attachment from class_progress_reports.attachment_path
*/
public function downloadLegacyByReport(int $reportId): BinaryFileResponse
{
$row = ClassProgressReport::query()->find($reportId);
if (! $row || empty($row->attachment_path)) {
abort(404, 'Attachment not found.');
}
$file = $this->resolveAttachmentFile($row->toArray());
if (! $file) {
abort(404, 'Attachment missing.');
}
return response()->download($file, basename($file));
}
/**
* Download file from normalized attachments table
*/
public function downloadAttachment(int $attachmentId): BinaryFileResponse
{
$attachment = ClassProgressAttachment::query()->find($attachmentId);
if (! $attachment || empty($attachment->file_path)) {
abort(404, 'Attachment not found.');
}
$file = $this->resolveAttachmentPath((string) $attachment->file_path);
if (! $file) {
abort(404, 'Attachment missing.');
}
$downloadName = $attachment->original_name ?: basename($file);
return response()->download($file, $downloadName);
}
}