✨ feat(lpj): peningkatan model & service inspeksi, penawaran, preview
- Models: Inspeksi tambah 'mig_detail_data_jaminan' pada 'fillable'. - Models: PersetujuanPenawaran ubah import User, hapus 3 field lama. - Models: PersetujuanPenawaran tambah relasi 'region' (belongsTo Region). - Services: PreviewLaporanService tambah 22 item kategori preview. - Services: SaveFormInspesksiService refaktor parsing action & rules. - Services: TypeLaporanService tambah helper alamat & lokasi wilayah. - Services: TypeLaporanService tambahkan updateOrCreate untuk Penilai. - Services: TypeLaporanService tambah getInspeksi dan stub updatePenilai. - Cleanup: penataan kode, trimming, kurangi nested kondisi; mohon cek namespace.
This commit is contained in:
@@ -4,7 +4,6 @@ namespace Modules\Lpj\Services;
|
||||
|
||||
use Modules\Lpj\Models\Inspeksi;
|
||||
use Illuminate\Http\Request;
|
||||
use \Illuminate\Support\Facades\Log;
|
||||
|
||||
class SaveFormInspesksiService
|
||||
{
|
||||
@@ -21,7 +20,6 @@ class SaveFormInspesksiService
|
||||
$inspeksi->name = $request->input('type');
|
||||
|
||||
$processedData = $this->getActionSpecificRules($validatedData, $type, $request, $inspeksi);
|
||||
Log::info($processedData);
|
||||
|
||||
// Merge data lama dengan data baru
|
||||
$existingData = json_decode($inspeksi->data_form, true) ?: [];
|
||||
@@ -35,7 +33,6 @@ class SaveFormInspesksiService
|
||||
'upload_gs'
|
||||
];
|
||||
|
||||
|
||||
foreach ($fotoTypes as $fotoType) {
|
||||
if (isset($existingData[$fotoType])) {
|
||||
$processedData[$fotoType] = $existingData[$fotoType];
|
||||
@@ -60,7 +57,7 @@ class SaveFormInspesksiService
|
||||
} catch (\Exception $e) {
|
||||
return [
|
||||
'success' => false,
|
||||
'message' => 'Gagal menyimpan data : '.$e->getMessage(),
|
||||
'message' => 'Gagal menyimpan data',
|
||||
'error' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
@@ -88,31 +85,36 @@ class SaveFormInspesksiService
|
||||
$hasAssetDescriptionRules = false;
|
||||
$hasFactaData = false;
|
||||
|
||||
$actions = array_map('trim', explode(',', $action));
|
||||
$pisah = array_filter($actions, function($act) use ($allowedActions) {
|
||||
return isset($allowedActions[$act]);
|
||||
});
|
||||
|
||||
|
||||
$pisah = array_filter(
|
||||
explode(',', $action),
|
||||
function ($act) use ($allowedActions) {
|
||||
return isset($allowedActions[trim($act)]);
|
||||
}
|
||||
);
|
||||
|
||||
// dd($pisah);
|
||||
|
||||
foreach ($pisah as $act) {
|
||||
$act = trim($act); // Bersihkan spasi
|
||||
if($act){
|
||||
if (isset($allowedActions[$act])) {
|
||||
$method = $allowedActions[$act];
|
||||
if (isset($allowedActions[$act])) {
|
||||
$method = $allowedActions[$act];
|
||||
|
||||
$actionRules = $this->$method($data, $request, $inspeksi);
|
||||
$rules = array_merge($rules, $actionRules);
|
||||
// Cek apakah act memerlukan asset description rules
|
||||
if($act){
|
||||
if (in_array($act, ['apartemen-kantor', 'tanah', 'bangunan', 'rap'])) {
|
||||
$hasAssetDescriptionRules = true;
|
||||
}
|
||||
$actionRules = $this->$method($data, $request, $inspeksi);
|
||||
$rules = array_merge($rules, $actionRules);
|
||||
|
||||
if (in_array($act, ['rap'])) {
|
||||
$hasFactaData = true;
|
||||
}
|
||||
}
|
||||
// Cek apakah act memerlukan asset description rules
|
||||
if (in_array($act, ['apartemen-kantor', 'tanah', 'bangunan', 'rap'])) {
|
||||
$hasAssetDescriptionRules = true;
|
||||
}
|
||||
|
||||
// Cek apakah act memerlukan fakta data
|
||||
if (in_array($act, ['rap'])) {
|
||||
$hasFactaData = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($hasAssetDescriptionRules) {
|
||||
|
||||
Reference in New Issue
Block a user