update form data surveyor

This commit is contained in:
majid
2024-11-13 22:12:51 +07:00
parent 8e9e5e4843
commit 947cccfeac
21 changed files with 1518 additions and 1510 deletions

View File

@@ -19,75 +19,50 @@ class FormSurveyorRequest extends FormRequest
*/
public function rules(): array
{
$commonRules = $this->getBangunanRules();
$actionSpecificRules = $this->getActionSpecificRules();
return array_merge($commonRules, $actionSpecificRules);
return $actionSpecificRules;
}
/**
* Get common rules that apply to all actions.
*/
private function getCommonRules(): array
{
return [
'fakta_positif' => 'nullable|array',
'fakta_negatif' => 'nullable|array',
'rute_menuju' => 'nullable',
'batas_batas' => 'nullable|array',
'kondisi_linkungan' => 'nullable|array',
'kondisi_lain_bangunan' => 'nullable|array',
'informasi_dokument' => 'nullable',
'peruntukan' => 'nullable',
'kdb' => 'nullable',
'kdh' => 'nullable',
'gsb' => 'nullable',
'max_lantai' => 'nullable',
'klb' => 'nullable',
'gss' => 'nullable',
'pelebaran_jalan' => 'nullable',
'nama_petugas' => 'nullable',
'lat' => 'nullable|numeric',
'lng' => 'nullable|numeric',
'foto_gistaru' => 'nullable',
'foto_bhumi' => 'nullable',
'foto_argis_region' => 'nullable',
'foto_tempat' => 'nullable',
'keterangan' => 'nullable',
];
}
/**
* Get rules specific to the action.
*/
private function getActionSpecificRules(): array
{
$action = $this->input('action');
$pisah = explode(',', $action);
switch ($action) {
case 'tanah':
return $this->getTanahRules();
case 'unit':
return $this->getUnitRules();
case 'kapal':
return $this->getUnitRules();
case 'kendaraan':
return $this->getUnitRules();
case 'mesin':
return $this->getUnitRules();
case 'bangunan':
return $this->getTanahBangunanRules();
case 'tanah_bangunan':
return array_merge($this->getAssetDescriptionRules(),$this->getTanahRules(), $this->getBangunanRules(), $this->getLinkunganRules(), $this->getCommonRules());
$allRules = [
'tanah' => $this->getTanahRules(),
'bangunan' => $this->getBangunanRules(),
'kapal' => $this->getKapalRules(),
'kendaraan' => $this->getKendaraanRules(),
'mesin' => $this->getMesinRules(),
'pesawat' => $this->getLinkunganRules(),
'alat-berat' => $this->getLinkunganRules(),
'apartemen-kantor' => $this->getUnitRules(),
'lingkungan' => $this->getLinkunganRules(),
'fakta' => $this->getCommonRules(),
];
case 'alat-berat':
return $this->getUnitRules();
default:
return [];
$rules = [];
$hasAssetDescriptionRules = false;
foreach ($pisah as $act) {
if (isset($allRules[$act])) {
$rules = array_merge($rules, $allRules[$act]);
if ($act == 'tanah' || $act == 'bangunan') {
$hasAssetDescriptionRules = true;
}
}
}
}
if ($hasAssetDescriptionRules) {
$rules = array_merge($rules, $this->getAssetDescriptionRules());
}
return $rules;
}
/**
* Get rules specific to tanah action.
*/
@@ -133,9 +108,9 @@ class FormSurveyorRequest extends FormRequest
];
}
/**
* Get rules specific to unit action.
*/
/**
* Get rules specific to unit action.
*/
private function getUnitRules(): array
{
return [
@@ -164,7 +139,7 @@ class FormSurveyorRequest extends FormRequest
'jarak_cbd_point' => 'nullable',
'nama_cbd_point' => 'nullable',
'lebar_perkerasan_jalan' => 'nullable',
'perkerasan_jalan' => 'nullable',
'perkerasan_jalan.*' => 'nullable',
'lalu_lintas' => 'nullable',
'gol_mas_sekitar' => 'nullable',
'tingkat_keramaian' => 'nullable',
@@ -223,24 +198,57 @@ class FormSurveyorRequest extends FormRequest
private function getAssetDescriptionRules(): array
{
return [
'permohonan_id' => 'required',
'type' => 'required',
'debitur_perwakilan' => 'required|array',
'jenis_asset' => 'required',
'jenis_asset_tidak_sesuai' => 'nullable',
'alamat_sesuai' => 'required',
'alamat_tidak_sesuai' => 'nullable',
'nama_jalan' => 'nullable',
'desa_kelurahan' => 'nullable',
'kecamatan' => 'nullable',
'kota_kabupaten' => 'nullable',
'provinsi' => 'nullable',
'kordinat_lng' => 'nullable',
'kordinat_lat' => 'nullable',
];
}
{
return [
'permohonan_id' => 'required',
'type' => 'required',
'debitur_perwakilan' => 'required|array',
'jenis_asset' => 'required',
'jenis_asset_tidak_sesuai' => 'nullable',
'alamat_sesuai' => 'required',
'alamat_tidak_sesuai' => 'nullable',
'nama_jalan' => 'nullable',
'desa_kelurahan' => 'nullable',
'kecamatan' => 'nullable',
'kota_kabupaten' => 'nullable',
'provinsi' => 'nullable',
'kordinat_lng' => 'nullable',
'kordinat_lat' => 'nullable',
];
}
/**
* Get common rules that apply to all actions.
*/
private function getCommonRules(): array
{
return [
'fakta_positif' => 'nullable|array',
'fakta_negatif' => 'nullable|array',
'rute_menuju' => 'nullable',
'batas_batas' => 'nullable|array',
'kondisi_lingkungan' => 'nullable|array',
'kondisi_lain_bangunan' => 'nullable|array',
'informasi_dokument' => 'nullable',
'peruntukan' => 'nullable',
'kdb' => 'nullable',
'kdh' => 'nullable',
'gsb' => 'nullable',
'max_lantai' => 'nullable',
'klb' => 'nullable',
'gss' => 'nullable',
'pelebaran_jalan' => 'nullable',
'nama_petugas' => 'nullable',
'lat' => 'nullable|numeric',
'lng' => 'nullable|numeric',
'foto_gistaru' => 'nullable',
'foto_bhumi' => 'nullable',
'foto_argis_region' => 'nullable',
'foto_tempat' => 'nullable',
'keterangan' => 'nullable',
];
}
}

View File

@@ -19,6 +19,7 @@
'name' => 'required|max:255',
'slug' => 'required|max:255',
'jenis_legalitas_jaminan_id' => 'nullable',
'form_kategori.*' => 'required',
];
}