Files
lpj/app/Http/Requests/FormSurveyorRequest.php
2024-11-13 20:16:26 +00:00

255 lines
7.5 KiB
PHP

<?php
namespace Modules\Lpj\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class FormSurveyorRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*/
public function authorize(): bool
{
return true;
}
/**
* Get the validation rules that apply to the request.
*/
public function rules(): array
{
$actionSpecificRules = $this->getActionSpecificRules();
return $actionSpecificRules;
}
/**
* Get rules specific to the action.
*/
private function getActionSpecificRules(): array
{
$action = $this->input('action');
$pisah = explode(',', $action);
$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(),
];
$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.
*/
public function getTanahRules(): array
{
return [
'luas_tanah' => 'required',
'luas_tanah_tidak_sesuai' => 'nullable',
'hadap_mata_angin' => 'required',
'hadap_mata_angin_tidak_sesuai' => 'nullable',
'bentuk_tanah' => 'nullable|array',
'bentuk_tanah_lainnya' => 'nullable',
'kontur_tanah' => 'required|array',
'ketinggian_jalan' => 'required|array',
'kontur_jalan' => 'required',
'posisi_kavling' => 'required|array',
'posisi_kavling_lainnya' => 'nullable',
'tusuk_sate' => 'required',
'lockland' => 'required',
'kondisi_fisik_tanah' => 'required|array',
];
}
/**
* Get rules specific to Bangunan action.
*/
private function getBangunanRules(): array
{
return [
'action' => 'required',
'luas_tanah_bagunan' => 'required',
'jenis_bangunan' => 'required',
'kondisi_bangunan' => 'nullable',
'sifat_bangunan' => 'required|array',
'sifat_bangunan_input' => 'nullable|array',
'nama_bagunan' => 'required|array',
'spek_kategori_bangunan' => 'required|array',
'spek_kategori_bangunan.*' => 'required|string',
'sarana_pelengkap' => 'required',
'sarana_pelengkap_input' => 'nullable|array',
];
}
/**
* Get rules specific to unit action.
*/
private function getUnitRules(): array
{
return [
'action' => 'required',
'luas_unit' => 'required',
'luas_unit_tidak_sesuai' => 'nullable',
'jenis_unit' => 'required|array',
'kondisi_unit' => 'required|array',
'posisi_unit' => 'required|array',
'lantai' => 'required|array',
'view' => 'required|array',
'bentuk_unit' => 'required|array',
];
}
/**
* Get rules specific to Linkungan action.
*/
private function getLinkunganRules(): array
{
return [
'action' => 'required',
'jarak_jalan_utama' => 'nullable',
'jalan_linkungan' => 'nullable',
'jarak_cbd_point' => 'nullable',
'nama_cbd_point' => 'nullable',
'lebar_perkerasan_jalan' => 'nullable',
'perkerasan_jalan.*' => 'nullable',
'lalu_lintas' => 'nullable',
'gol_mas_sekitar' => 'nullable',
'tingkat_keramaian' => 'nullable',
'terletak_diarea' => 'nullable',
'disekitar_lokasi' => 'nullable',
'kondisi_bangunan_sekitar' => 'nullable',
'sifat_bangunan_sekitar' => 'nullable',
'dekat_makam' => 'nullable',
'jarak_makam' => 'nullable',
'nama_makam' => 'nullable',
'dekat_tps' => 'nullable',
'jarak_tps' => 'nullable',
'nama_tpu' => 'nullable',
'merupakan_daerah' => 'nullable',
'fasilitas_dekat_object' => 'nullable',
];
}
private function getKapalRules(): array
{
return [
'action' => 'required',
'kondisi_kapal' => 'required',
'kondisi_kapal_lain' => 'required',
];
}
public function getKendaraanRules(): array
{
return [
'action' => 'required',
'kondisi_kendaraan' => 'required',
'kondisi_kendaraan_lain' => 'required',
];
}
public function getMesinRules(): array
{
return [
'action' => 'required',
'kondisi_mesin' => 'required',
'kondisi_mesin_lain' => 'required',
];
}
public function getAlatBeratRules(): array
{
return [
'action' => 'required',
'kondisi_alat_berat' => 'required',
'kondisi_alat_berat_lain' => 'required',
];
}
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',
];
}
/**
* 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',
];
}
}