perbaikan submit surveyor tidak bisa submit

This commit is contained in:
majid
2024-12-20 16:08:11 +07:00
parent 639bdfed98
commit 145b677dbc
2 changed files with 13 additions and 19 deletions

View File

@@ -465,7 +465,9 @@ class SurveyorController extends Controller
{
try {
// Get all inspeksi records for this permohonan
$inspeksiRecords = Inspeksi::where('permohonan_id', $id)->get();
$inspeksiRecords = Inspeksi::with(['dokument.jenisJaminan'])
->where('permohonan_id', $id)
->get();
if ($inspeksiRecords->isEmpty()) {
return response()->json(['buttonDisable' => true]);
@@ -477,23 +479,20 @@ class SurveyorController extends Controller
$denahForm = json_decode($inspeksi->denah_form, true);
$dataPembanding = json_decode($inspeksi->data_pembanding, true);
// Get jenis jaminan to check if it needs denah
$jenisJaminan = JenisJaminan::find($inspeksi->dokument_id);
$jenisJaminan = $inspeksi->dokument->jenisJaminan->name ?? '';
$isTanahBangunan = !in_array(
strtoupper($jenisJaminan->name ?? ''),
['KAPAL', 'PESAWAT', 'KENDARAAN', 'ALAT BERAT']
);
// Check if required forms are empty or incomplete
if (empty($dataForm) || empty($fotoForm)) {
return response()->json(['buttonDisable' => true]);
}
$isInvalid =
empty($dataForm) ||
empty($fotoForm) ||
(($isTanahBangunan && empty($denahForm)) ||
empty($dataPembanding));
if ($isTanahBangunan && empty($denahForm)) {
return response()->json(['buttonDisable' => true]);
}
if (empty($dataPembanding)) {
if ($isInvalid) {
return response()->json(['buttonDisable' => true]);
}
}

View File

@@ -21,13 +21,8 @@ class Inspeksi extends Model
return $this->belongsTo(Permohonan::class, 'permohonan_id');
}
public function jenis_jaminan()
public function dokument()
{
return $this->belongsTo(JenisJaminan::class, 'jenis_jaminan_id');
return $this->belongsTo(DokumenJaminan::class, 'dokument_id');
}
// protected static function newFactory(): InspeksiFactory
// {
// // return InspeksiFactory::new();
// }
}