feat: add graduation archive and public document services

This commit is contained in:
2026-04-14 13:51:39 +00:00
parent d77ad72bcc
commit 58c9b47dc0
30 changed files with 2513 additions and 295 deletions
@@ -5,9 +5,11 @@ namespace App\Http\Controllers;
use App\Models\DocumentType;
use App\Models\Student;
use App\Models\StudentDocument;
use App\Models\StudentGraduation;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;
use Illuminate\View\View;
use Symfony\Component\HttpFoundation\StreamedResponse;
class PublicStudentLookupController extends Controller
{
@@ -44,6 +46,9 @@ class PublicStudentLookupController extends Controller
if ($selectedStudent) {
$requiredDocumentSummary = $this->buildRequiredDocumentSummary($selectedStudent);
$matchedBy = $this->detectMatchedBy($selectedStudent, $query);
$selectedStudent->public_graduation_record = $selectedStudent->status === 'graduated'
? StudentGraduation::query()->where('student_id', $selectedStudent->id)->first()
: null;
}
$students->each(function (Student $student) {
@@ -136,6 +141,21 @@ class PublicStudentLookupController extends Controller
&& (str_contains($name, 'foto') || str_contains($fileName, 'foto'));
}
public function downloadGraduationDocument(Student $student, string $document): StreamedResponse
{
abort_unless($student->status === 'graduated', 404);
abort_unless(in_array($document, ['skl', 'ijazah'], true), 404);
$graduation = StudentGraduation::query()->where('student_id', $student->id)->firstOrFail();
$filePathField = $document === 'skl' ? 'skl_file_path' : 'ijazah_file_path';
$fileNameField = $document === 'skl' ? 'skl_file_name' : 'ijazah_file_name';
abort_unless($graduation->{$filePathField} && Storage::disk('public')->exists($graduation->{$filePathField}), 404);
return Storage::disk('public')->download($graduation->{$filePathField}, $graduation->{$fileNameField} ?: basename($graduation->{$filePathField}));
}
protected function buildRequiredDocumentSummary(Student $student): array
{
$requiredTypes = DocumentType::query()