Repository navigation
Fix foto pengurus tidak tersimpan saat tambah data baru - #1773
Open
pandigresik wants to merge 1 commit into
Open
pandigresik wants to merge 1 commit into
pandigresik wants to merge 1 commit into
Conversation
Contributor
|
🔄 AI PR Review sedang antri di server...
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Saat menambah data pengurus baru, file foto sudah dipilih dan form tersimpan sukses, tetapi kolom
fotodi database tetapNULL— foto baru tersimpan setelah data diedit dan foto diinput ulang (issue #1770).Penyebabnya: pada
PengurusController::store(), file sudah di-upload olehhandleFileUpload()kestorage/app/public/pengurus/, namun nama file di$input['foto']tidak pernah ditulis ke database karena'foto'tidak tercantum dalam daftar$fillableFieldsyang di-loop. Metodeupdate()tidak terdampak karena memakai$pengurus->update($input)secara langsung — itulah sebabnya bug hanya muncul di proses tambah.Solusi pada PR ini: menambahkan
'foto'ke$fillableFieldspadastore(), sehingga nama file hasil upload ikut tersimpan ke kolomdas_pengurus.fotopada saat pertama kali data dibuat. Ditambah regression test yang memastikan kolomfototerisi dan file benar-benar ada di disk.Changes made:
app/Http/Controllers/Data/PengurusController.php—'foto'ditambahkan ke array$fillableFieldsdistore()sehingga nilai hasilhandleFileUpload()tersimpan ke database saat create.PengurusController.php— pembersihan kecil hasilvendor/bin/pintpada file yang sama (hapuselsetidak berguna di render status DataTables, hapus@return mixedpada phpdocindex(), hapus whitespace di akhir barisdestroy()). Tidak mengubah perilaku.tests/Feature/Controllers/Data/PengurusControllerTest.php— teststore creates pengurus with file uploaddiperkuat denganStorage::fake('local')(agar upload tidak menulis file asli) dan assertiongetRawOriginal('foto')tidakNULL+ file ada dipublic/pengurus/{nama}.Reason for change:
$input['foto']berisi nama file hasil upload, tetapi loop$fillableFieldstidak pernah menyalinnya ke model — kolomfototidak pernah terisi pada proses create.store()konsisten denganupdate()yang sudah benar, tanpa mengubah alur validasi (PengurusRequest) maupun penyimpanan file (HandlesFileUpload).Impact of change:
✅ Foto pengurus tersimpan pada saat pertama kali tambah data — sesuai harapan pada issue #1770.
✅ Tidak ada lagi keharusan edit-ulang hanya untuk memasukkan foto (menghemat langkah pengguna & mengurangi data tanpa foto).
✅ Tidak ada file yatim — sebelumnya file sudah terupload ke storage namun tidak direferensikan database.
✅ Regression test terpasang — memverifikasi kolom
fototerisi dan file fisik benar-benar ada.Related Issue
Steps to Reproduce
Before fix (problem):
das_pengurus.fototetapNULL(file sudah ada di storage, tetapi tidak direferensikan).After fix (solution):
Testing on related features:
HandlesResourceDeletion) — ✅ tidak terpengaruhChecklist
Technical Details
Technical Explanation
Alur
store()sebelum dan sesudah perbaikan:Karena
isset($input['foto'])bernilaifalsesaat tidak ada file (atautruesaat ada), penambahan'foto'ke daftar aman untuk kasus tanpa foto — kolom tetapNULLsesuai aturannullable.Mengapa sebelumnya file tetap ter-upload tetapi "tidak tersimpan":
HandlesFileUpload::handleFileUpload()hanya menulis ke storage dan mengisi$input; penulisan ke database sepenuhnya bergantung pada daftar$fillableFieldsdistore()yang tidak memuatfoto. Metodeupdate()memakai$pengurus->update($input)(mass-assign langsung dari validated + hasil upload), sehingga tidak terdampak.Catatan pembacaan nilai:
Pengurus::getFotoAttribute()mengembalikanStorage::url('pengurus/'.$value)sehingga->value('foto')pada query Eloquent akan memakai accessor. Test memakaigetRawOriginal('foto')untuk memverifikasi nilai mentah kolom.Configuration changes
Tidak ada perubahan konfigurasi.
Dependencies added
Tidak ada dependensi baru.
Testing
Manual Testing
fotokosongupload_limitaktif) → error validasi tampilAutomated Testing
tests/Feature/Controllers/Data/PengurusControllerTest.php→store creates pengurus with file upload(17 test / 68 assertions lolos)php vendor/bin/pestScreenshots / Video
simplescreenrecorder-2026-10-08_16.27.36.mp4
Before:
Foto sudah dipilih pada form tambah, tetapi setelah simpan foto tidak tampil (kolom
fotoNULL).After:
Foto langsung tersimpan dan tampil pada daftar pengurus setelah form tambah disimpan.
Breaking Changes
None.
Migration Guide
Not required — tidak ada perubahan skema maupun konfigurasi.
References
Additional notes: Branch
fix/simpan_foto_penggunamenujurilis-dev. 2 file diubah (+12/−6), commit95e1fdfe. Perubahan inti hanya penambahan satu item'foto'pada$fillableFields; sisanya formatting Pint dan penguatan test.