feat: update student import and graduation workflows
This commit is contained in:
@@ -20,6 +20,9 @@ class GraduationBulkUploadController extends Controller
|
||||
'documentTypes' => [
|
||||
'skl' => 'SKL',
|
||||
'ijazah' => 'Ijazah',
|
||||
'transcript' => 'Transkrip Nilai',
|
||||
'ukk-certificate' => 'Sertifikat UKK',
|
||||
'lsp-certificate' => 'Sertifikat LSP',
|
||||
],
|
||||
'matchByOptions' => [
|
||||
'student_number' => 'NIS',
|
||||
@@ -31,15 +34,15 @@ class GraduationBulkUploadController extends Controller
|
||||
public function preview(Request $request): RedirectResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'document_type' => ['required', 'in:skl,ijazah'],
|
||||
'document_type' => ['required', 'in:skl,ijazah,transcript,ukk-certificate,lsp-certificate'],
|
||||
'match_by' => ['required', 'in:student_number,nisn'],
|
||||
'documents' => ['required', 'array', 'min:1', 'max:10'],
|
||||
'documents.*' => ['required', 'file', 'mimes:pdf,jpg,jpeg,png', 'max:2048'],
|
||||
'documents.*' => ['required', 'file', 'mimes:pdf,jpg,jpeg,png', 'max:4096'],
|
||||
], [
|
||||
'documents.required' => 'Pilih minimal satu file dokumen untuk dipreview.',
|
||||
'documents.max' => 'Maksimal 10 file per batch upload.',
|
||||
'documents.*.mimes' => 'Dokumen hanya boleh berupa PDF, JPG, JPEG, atau PNG.',
|
||||
'documents.*.max' => 'Ukuran tiap dokumen maksimal 2 MB.',
|
||||
'documents.*.max' => 'Ukuran tiap dokumen maksimal 4 MB.',
|
||||
]);
|
||||
|
||||
$graduations = StudentGraduation::query()->get()->keyBy($validated['match_by']);
|
||||
@@ -59,7 +62,13 @@ class GraduationBulkUploadController extends Controller
|
||||
$baseName = pathinfo($originalName, PATHINFO_FILENAME);
|
||||
$normalizedKey = trim($baseName);
|
||||
$graduation = $graduations->get($normalizedKey);
|
||||
$existingPathField = $validated['document_type'] === 'skl' ? 'skl_file_path' : 'ijazah_file_path';
|
||||
$existingPathField = [
|
||||
'skl' => 'skl_file_path',
|
||||
'ijazah' => 'ijazah_file_path',
|
||||
'transcript' => 'transcript_file_path',
|
||||
'ukk-certificate' => 'ukk_certificate_file_path',
|
||||
'lsp-certificate' => 'lsp_certificate_file_path',
|
||||
][$validated['document_type']];
|
||||
|
||||
$storedTempPath = $file->store('temp/graduation-bulk-upload', 'public');
|
||||
|
||||
@@ -93,7 +102,13 @@ class GraduationBulkUploadController extends Controller
|
||||
$preview = [
|
||||
'token' => (string) Str::uuid(),
|
||||
'document_type' => $validated['document_type'],
|
||||
'document_label' => $validated['document_type'] === 'skl' ? 'SKL' : 'Ijazah',
|
||||
'document_label' => [
|
||||
'skl' => 'SKL',
|
||||
'ijazah' => 'Ijazah',
|
||||
'transcript' => 'Transkrip Nilai',
|
||||
'ukk-certificate' => 'Sertifikat UKK',
|
||||
'lsp-certificate' => 'Sertifikat LSP',
|
||||
][$validated['document_type']],
|
||||
'match_by' => $validated['match_by'],
|
||||
'match_by_label' => $validated['match_by'] === 'student_number' ? 'NIS' : 'NISN',
|
||||
'rows' => $rows,
|
||||
@@ -120,10 +135,18 @@ class GraduationBulkUploadController extends Controller
|
||||
}
|
||||
|
||||
$documentType = $preview['document_type'];
|
||||
$fileNameField = $documentType === 'skl' ? 'skl_file_name' : 'ijazah_file_name';
|
||||
$filePathField = $documentType === 'skl' ? 'skl_file_path' : 'ijazah_file_path';
|
||||
$mimeTypeField = $documentType === 'skl' ? 'skl_mime_type' : 'ijazah_mime_type';
|
||||
$fileSizeField = $documentType === 'skl' ? 'skl_file_size' : 'ijazah_file_size';
|
||||
$documentConfig = [
|
||||
'skl' => ['name' => 'skl_file_name', 'path' => 'skl_file_path', 'mime' => 'skl_mime_type', 'size' => 'skl_file_size'],
|
||||
'ijazah' => ['name' => 'ijazah_file_name', 'path' => 'ijazah_file_path', 'mime' => 'ijazah_mime_type', 'size' => 'ijazah_file_size'],
|
||||
'transcript' => ['name' => 'transcript_file_name', 'path' => 'transcript_file_path', 'mime' => 'transcript_mime_type', 'size' => 'transcript_file_size'],
|
||||
'ukk-certificate' => ['name' => 'ukk_certificate_file_name', 'path' => 'ukk_certificate_file_path', 'mime' => 'ukk_certificate_mime_type', 'size' => 'ukk_certificate_file_size'],
|
||||
'lsp-certificate' => ['name' => 'lsp_certificate_file_name', 'path' => 'lsp_certificate_file_path', 'mime' => 'lsp_certificate_mime_type', 'size' => 'lsp_certificate_file_size'],
|
||||
][$documentType];
|
||||
|
||||
$fileNameField = $documentConfig['name'];
|
||||
$filePathField = $documentConfig['path'];
|
||||
$mimeTypeField = $documentConfig['mime'];
|
||||
$fileSizeField = $documentConfig['size'];
|
||||
|
||||
$processed = 0;
|
||||
$skipped = 0;
|
||||
|
||||
Reference in New Issue
Block a user