feat(permohonan): tambahkan relasi laporanExternal dan perbarui query show

- Menambahkan method laporanExternal pada model Permohonan untuk mendefinisikan relasi dengan LaporanExternal.
- Memperbarui query pada method show di PenilaiController untuk menyertakan relasi jenisPenilaian dan laporanExternal.
This commit is contained in:
Daeng Deni Mardaeni
2025-03-10 10:37:19 +07:00
parent 18b1e37cee
commit de6e7ad732
3 changed files with 82 additions and 40 deletions

View File

@@ -305,7 +305,7 @@ class PenilaiController extends Controller
*/ */
public function show($id) public function show($id)
{ {
$permohonan = Permohonan::with(['debiture.documents.jenisjaminan', 'region.teams.teamsUsers.user', 'penilaian', 'documents.inspeksi'])->find($id); $permohonan = Permohonan::with(['debiture.documents.jenisjaminan', 'region.teams.teamsUsers.user', 'penilaian', 'documents.inspeksi','jenisPenilaian','laporanExternal'])->find($id);
// return response()->json(['permohonan' => $permohonan]); // return response()->json(['permohonan' => $permohonan]);

View File

@@ -235,4 +235,9 @@
{ {
return $this->hasMany(LampiranDokumen::class); return $this->hasMany(LampiranDokumen::class);
} }
public function laporanExternal()
{
return $this->belongsTo(LaporanExternal::class,'id','permohonan_id');
}
} }

View File

@@ -85,7 +85,6 @@
</div> </div>
</div> </div>
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5"> <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
<label class="form-label max-w-56"> <label class="form-label max-w-56">
@@ -323,6 +322,45 @@
</div> </div>
</div> </div>
</div> </div>
@if($permohonan->jenisPenilaian->name=="External")
@if(isset($permohonan->laporanExternal->file_resume) || isset($permohonan->laporanExternal->file_laporan))
<div class="dropdown" data-dropdown="true" data-dropdown-trigger="click">
<button class="dropdown-toggle btn btn-primary">
Laporan External
</button>
<div class="dropdown-content w-full max-w-56 py-2 !ml-[200px] !mt-[-20px]">
<div class="menu menu-default flex flex-col w-full">
@if(isset($permohonan->laporanExternal->file_resume) && !empty($permohonan->laporanExternal->file_resume))
<div class="menu-item">
<a class="menu-link" onclick="viewPDF('{{ Storage::url($permohonan->laporanExternal->file_resume) }}')">
<span class="menu-icon">
<i class="ki-outline ki-badge"></i>
</span>
<span class="menu-title">
Resume
</span>
</a>
</div>
@endif
@if(isset($permohonan->laporanExternal->file_laporan) && !empty($permohonan->laporanExternal->file_laporan))
<div class="menu-item">
<a class="menu-link" onclick="viewPDF('{{ Storage::url($permohonan->laporanExternal->file_laporan) }}')">
<span class="menu-icon">
<i class="ki-outline ki-setting-2"></i>
</span>
<span class="menu-title">
Laporan
</span>
</a>
</div>
@endif
</div>
</div>
</div>
@endif
@endif
</div> </div>
<div class="flex justify-end gap-5"> <div class="flex justify-end gap-5">
@@ -362,8 +400,6 @@
</div> </div>
</div> </div>
@@ -412,7 +448,8 @@
<div class="flex justify-center items-center gap-2"> <div class="flex justify-center items-center gap-2">
<input type="file" id="kertas_kerja" class="file-input"> <input type="file" id="kertas_kerja" class="file-input">
<button type="button" class="btn btn-outline btn-success" <button type="button" class="btn btn-outline btn-success"
onclick="uploadKertasKerja({{ $permohonan->id }}, '{{ $documentId }}', '{{ $inspeksiId }}', '{{ $jenisJaminanId }}')">Upload</button> onclick="uploadKertasKerja({{ $permohonan->id }}, '{{ $documentId }}', '{{ $inspeksiId }}', '{{ $jenisJaminanId }}')">Upload
</button>
</div> </div>
</div> </div>
<div class="flex justify-between items-center"> <div class="flex justify-between items-center">
@@ -641,7 +678,7 @@
headers: { headers: {
'X-CSRF-TOKEN': '{{ csrf_token() }}' 'X-CSRF-TOKEN': '{{ csrf_token() }}'
}, },
success: function(response) { success: function (response) {
if (response.success) { if (response.success) {
// window.location.reload(); // window.location.reload();
hideLoadingSwal(); hideLoadingSwal();
@@ -651,7 +688,7 @@
Swal.fire('Perhatian!', response.message, 'warning'); Swal.fire('Perhatian!', response.message, 'warning');
} }
}, },
error: function(xhr, status, error) { error: function (xhr, status, error) {
console.log('Error checking button status:', error, status, xhr); console.log('Error checking button status:', error, status, xhr);
if (xhr.responseJSON.message) { if (xhr.responseJSON.message) {
// window.location.reload(); // window.location.reload();