diff --git a/app/Http/Controllers/SurveyorController.php b/app/Http/Controllers/SurveyorController.php index cc1822a..36b9ae2 100644 --- a/app/Http/Controllers/SurveyorController.php +++ b/app/Http/Controllers/SurveyorController.php @@ -5,6 +5,7 @@ namespace Modules\Lpj\Http\Controllers; use App\Http\Controllers\Controller; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; +use Illuminate\Support\Facades\DB; use Illuminate\Http\Response; use Modules\Lpj\Models\Permohonan; use Modules\Lpj\Models\Branch; @@ -22,7 +23,21 @@ use Modules\Lpj\Models\SpekBangunan; use Modules\Lpj\Models\SpekKategoritBangunan; use Modules\Lpj\Models\SaranaPelengkap; use Modules\Lpj\Models\ArahMataAngin; +use Modules\Lpj\Models\Analisa; +use Modules\Lpj\Models\AnalisaFakta; +use Modules\Lpj\Models\AnalisaLingkungan; +use Modules\Lpj\Models\AnalisaTanahBagunan; +use Modules\Lpj\Models\SpekBangunanAnalisa; +use Modules\Lpj\Models\Denah; +use Modules\Lpj\Models\FotoJaminan; +use Modules\Lpj\Models\Lingkungan; +use Modules\Lpj\Models\LantaiUnit; +use Modules\Lpj\Models\ObjekJaminan; +use Modules\Lpj\Models\RuteJaminan; +use Modules\Lpj\Models\AnalisaUnit; +use Modules\Lpj\Models\SpekBagunanAnalisaDetail; use Modules\Lpj\Http\Requests\SurveyorRequest; +use Modules\Lpj\Http\Requests\FormSurveyorRequest; class SurveyorController extends Controller { @@ -35,29 +50,25 @@ class SurveyorController extends Controller return view('lpj::surveyor.index'); } - - /** * Show the specified resource. */ public function show($id) { - $permohonan = Permohonan::with( - [ - 'user', - 'debiture.province', - 'debiture.city', - 'debiture.district', - 'debiture.village', - 'branch', - 'tujuanPenilaian', - 'penilaian', - 'documents', - ], - )->findOrFail($id); + $permohonan = Permohonan::with([ + 'user', + 'debiture.province', + 'debiture.city', + 'debiture.district', + 'debiture.village', + 'branch', + 'tujuanPenilaian', + 'penilaian', + 'documents', + ])->findOrFail($id); $surveyor = $id; - $branches = Branch::all(); + $branches = Branch::all(); $provinces = Province::all(); $bentukTanah = BentukTanah::all(); $konturTanah = KonturTanah::all(); @@ -72,8 +83,41 @@ class SurveyorController extends Controller $saranaPelengkap = SaranaPelengkap::all(); $arahMataAngin = ArahMataAngin::all(); + $jenisJaminanIds = $permohonan->debiture->documents; + + $buttonDisable = false; + + foreach ($jenisJaminanIds as $jenisJaminanId) { + $denah = Denah::where('permohonan_id', $id) + ->where('jenis_jaminan_id', $jenisJaminanId->jenis_jaminan_id) + ->first(); + + $fotojaminan = FotoJaminan::where('permohonan_id', $id) + ->where('jenis_jaminan_id', $jenisJaminanId->jenis_jaminan_id) + ->first(); + + $analisa = Analisa::where('permohonan_id', $id) + ->where('jenis_jaminan_id', $jenisJaminanId->jenis_jaminan_id) + ->first(); + + // cek jika tidak ada + if (!$denah || !$fotojaminan || !$analisa) { + $buttonDisable = true; + break; + } + } + + $denah = Denah::where('permohonan_id', $id)->get(); + $fotojaminan = FotoJaminan::where('permohonan_id', $id)->get(); + $analisa = Analisa::with('analisaUnit', 'analisaTanahBangunan', 'analisaLingkungan', 'analisaFakta', 'jenisJaminan') + ->where('permohonan_id', $id) + ->get(); return view('lpj::surveyor.detail', compact( + 'buttonDisable', + 'fotojaminan', + 'denah', + 'analisa', 'permohonan', 'surveyor', 'branches', @@ -89,26 +133,358 @@ class SurveyorController extends Controller 'spekKategoriBagunan', 'spekBangunan', 'saranaPelengkap', - 'arahMataAngin', + 'arahMataAngin' )); } - /** - * Show the form for editing the specified resource. + * Store form inspeksi. */ - public function edit($id) + public function store(FormSurveyorRequest $request) { - return view('lpj::edit'); + $validatedData = $request->validated(); + DB::beginTransaction(); + try { + $analisa = Analisa::create($validatedData); + + if ($analisa) { + $validatedData['analisa_id'] = $analisa->id; + + switch ($validatedData['action']) { + case 'tanah_bangunan': + $this->handleTanahBangunan($validatedData, $request); + break; + case 'unit': + $this->handleUnit($validatedData); + break; + default: + throw new \Exception('Invalid action type'); + } + + AnalisaLingkungan::create($validatedData); + $validatedData['foto_tempat'] = $this->uploadFile($request->file('foto_tempat'), 'foto_tempat'); + AnalisaFakta::create($validatedData); + } + + DB::commit(); + return redirect()->route('surveyor.show', [ + 'id' => $validatedData['permohonan_id'], + 'form' => 'inspeksi' + ])->with('success', 'Data form surveyor berhasil disimpan'); + } catch (Exception $e) { + DB::rollback(); + return response()->json(['error' => 'Failed to save data', 'details' => $e->getMessage()], 500); + } } - /** - * Update the specified resource in storage. - */ - public function update(Request $request, $id): RedirectResponse + private function handleTanahBangunan(array $validatedData, FormSurveyorRequest $request) { - // + $analisaTanahBangunan = AnalisaTanahBagunan::create($validatedData); + if ($analisaTanahBangunan) { + $this->createSpekBangunanAnalisa($request, $analisaTanahBangunan); + } } + private function handleUnit(array $validatedData) + { + AnalisaUnit::create($validatedData); + } + + private function createSpekBangunanAnalisa($request, $analisaTanahBangunan) + { + foreach ($request->input('kategori', []) as $spek) { + $spek['analisa_tanah_bangunan_id'] = $analisaTanahBangunan->id; + $spekBangunan = SpekBangunanAnalisa::create($spek); + + if ($spekBangunan) { + $this->createSpekBangunanAnalisaDetails($request, $spekBangunan); + } + } + } + + private function createSpekBangunanAnalisaDetails($request, $spekBangunan) + { + foreach ($request->input('name', []) as $detail) { + $detail['spek_bangunan_analisa_id'] = $spekBangunan->id; + SpekBagunanAnalisaDetail::create($detail); + } + } + + public function storeDenah(Request $request) + { + + try { + $validatedData = $request->validate([ + 'foto_denah' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048', + 'luas' => 'required|numeric', + 'permohonan_id' => 'required', + 'jenis_jaminan_id' => 'required' + ]); + + + $validatedData['foto_denah'] = $this->uploadFile($request->file('foto_denah'), 'foto_denah'); + + + Denah::create($validatedData); + return redirect()->route('surveyor.show', [ + 'id' => $validatedData['permohonan_id'], + 'form' => 'denah' + ])->with('success', 'Data foto berhasil disimpan'); + } catch (Exception $e) { + $failureRedirectUrl = route('surveyor.denah', [ + 'id' => $validatedData['permohonan_id'], + 'jenis_jaminan_id' => $validatedData['jenis_jaminan_id'] + ]); + + $failureRedirectUrl .= '?form=create-denah&denah=' . $validatedData['permohonan_id'] . '&jenis_jaminan=' . $validatedData['jenis_jaminan_id']; + + return redirect($failureRedirectUrl) + ->withInput() + ->with(['error' => 'Gagal menyimpan data: ' . $e->getMessage()]); + } + + } + + + public function storeFoto(Request $request) + { + $validatedData = $request->validate([ + 'permohonan_id' => 'required', + 'jenis_jaminan_id' => 'required', + 'analisa_type' => 'required|in:tanah_bangunan,unit', + 'pendamping' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048', + 'foto_objek.*' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048', + 'name_objek.*' => 'required|string|max:255', + 'foto_lingkungan.*' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048', + 'name_lingkungan.*' => 'required|string|max:255', + 'foto_rute.*' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048', + 'name_rute.*' => 'required|string|max:255', + 'lantai.*' => 'nullable|image|mimes:jpeg,png,jpg,gif,svg|max:2048', + 'name_lantai_unit.*' => 'nullable|string|max:255', + 'foto_lantai_unit.*' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048', + ]); + + DB::beginTransaction(); + + try { + $pendampingPath = $this->uploadFile($request->file('pendamping'), 'pendamping'); + + $fotojaminan = FotoJaminan::create([ + 'pendamping' => $pendampingPath, + 'permohonan_id' => $validatedData['permohonan_id'], + 'jenis_jaminan_id' => $validatedData['jenis_jaminan_id'], + ]); + + $this->processObjekUploads($request, $fotojaminan); + $this->processLantaiUnitUploads($request, $fotojaminan); + $this->processUploads('rute', $request, $fotojaminan); + $this->processUploads('lingkungan', $request, $fotojaminan); + + DB::commit(); + return redirect()->route('surveyor.show', [ + 'id' => $validatedData['permohonan_id'], + 'form' => 'foto' + ])->with('success', 'Data foto berhasil disimpan'); + } catch (Exception $e) { + DB::rollBack(); + return response()->json(['success' => false, 'message' => 'Failed to upload: ' . $e->getMessage()], 500); + } + } + + + + public function update(FormSurveyorRequest $request, $id) + { + $validatedData = $request->validated(); + + DB::beginTransaction(); + + try { + // Update Analisa entity + $analisa = Analisa::findOrFail($id); + $analisa->update($validatedData); + + if ($analisa) { + $validatedData['analisa_id'] = $analisa->id; + $analisaTanahBangunan = AnalisaTanahBagunan::where('analisa_id', $analisa->id)->firstOrFail(); + $analisaTanahBangunan->update($validatedData); + + if ($analisaTanahBangunan) { + $this->updateSpekBangunanAnalisa($request, $analisaTanahBangunan); + } + + $analisaLingkungan = AnalisaLingkungan::where('analisa_id', $analisa->id)->firstOrFail(); + $analisaLingkungan->update($validatedData); + + if ($request->hasFile('foto_tempat')) { + $validatedData['foto_tempat'] = $this->uploadFile($request->file('foto_tempat'), 'foto_tempat'); + } + + $analisaFakta = AnalisaFakta::where('analisa_id', $analisa->id)->firstOrFail(); + $analisaFakta->update($validatedData); + } + + DB::commit(); + return redirect()->route('surveyor.show', [ + 'id' => $validatedData['permohonan_id'], + 'form' => 'inspeksi' + ])->with('success', 'Data form surveyor berhasil diperbarui'); + } catch (Exception $e) { + DB::rollback(); + return response()->json(['error' => 'Failed to update data', 'details' => $e->getMessage()], 500); + } + } + + private function updateSpekBangunanAnalisa($request, $analisaTanahBangunan) + { + + SpekBangunanAnalisa::where('analisa_tanah_bangunan_id', $analisaTanahBangunan->id)->delete(); + + foreach ($request->input('kategori', []) as $spek) { + $spek['analisa_tanah_bangunan_id'] = $analisaTanahBangunan->id; + $spekBangunan = SpekBangunanAnalisa::create($spek); + + if ($spekBangunan) { + $this->updateSpekBangunanAnalisaDetails($request, $spekBangunan); + } + } + } + + private function updateSpekBangunanAnalisaDetails($request, $spekBangunan) + { + // Delete existing SpekBagunanAnalisaDetail records + SpekBagunanAnalisaDetail::where('spek_bangunan_analisa_id', $spekBangunan->id)->delete(); + + // Create new SpekBagunanAnalisaDetail records + foreach ($request->input('name', []) as $detail) { + $detail['spek_bangunan_analisa_id'] = $spekBangunan->id; + SpekBagunanAnalisaDetail::create($detail); + } + } + + + public function updateDenah(Request $request, $id): RedirectResponse + { + + } + private function processObjekUploads(Request $request, FotoJaminan $fotojaminan) + { + $fotoObjek = $request->file('foto_objek'); + $nameObjek = $request->input('name_objek'); + $analisaType = $request->input('analisa_type'); // Tambahkan input untuk tipe analisa + + if (!is_array($fotoObjek) || !is_array($nameObjek) || count($fotoObjek) !== count($nameObjek)) { + throw new Exception("Mismatched foto_objek and name_objek inputs"); + } + + // Definisikan labels berdasarkan tipe analisa + $objekLabels = []; + if ($analisaType === 'tanah_bangunan') { + $objekLabels = [ + 'Tampak Samping Kiri', + 'Tampak Samping Kanan', + 'Nomor Rumah/Unit' + ]; + } elseif ($analisaType === 'unit') { + $objekLabels = [ + 'Tampak Loby', + 'Tampak Lift', + 'Tampak Samping Kiri Unit', + 'Tampak Samping Kanan Unit', + 'Tampak Depan Unit', + 'Nomor Unit' + ]; + } + + foreach ($fotoObjek as $index => $foto) { + if (!isset($nameObjek[$index])) { + throw new Exception("Missing description for foto_objek at index {$index}"); + } + + // Pastikan index ada dalam objekLabels + $label = isset($objekLabels[$index]) ? $objekLabels[$index] : "Foto {$index}"; + + $path = $this->uploadFile($foto, 'objek'); + ObjekJaminan::create([ + 'foto_jaminan_id' => $fotojaminan->id, + 'name_objek' => $label . ': ' . $nameObjek[$index], + 'foto_objek' => $path, + ]); + } + } + + private function processUploads($type, Request $request, FotoJaminan $fotojaminan) + { + $files = $request->file("foto_{$type}"); + $names = $request->input("name_{$type}"); + + if (!is_array($files) || !is_array($names) || count($files) !== count($names)) { + throw new Exception("Mismatched foto_{$type} and name_{$type} inputs"); + } + + foreach ($files as $index => $file) { + if (!isset($names[$index])) { + throw new Exception("Missing description for {$type} at index {$index}"); + } + + $path = $this->uploadFile($file, $type); + + $data = [ + 'foto_jaminan_id' => $fotojaminan->id, + "name_{$type}" => $names[$index], + "foto_{$type}" => $path, + ]; + + switch ($type) { + case 'rute': + RuteJaminan::create($data); + break; + case 'lingkungan': + Lingkungan::create($data); + break; + } + } + } + + private function processLantaiUnitUploads(Request $request, FotoJaminan $fotojaminan) + { + $lantaiFiles = $request->file('foto_lantai_unit'); + $lantaiNames = $request->input('name_lantai_unit'); + + if (!$lantaiFiles) { + return; + } + + if (!is_array($lantaiFiles) || !is_array($lantaiNames) || count($lantaiFiles) !== count($lantaiNames)) { + throw new Exception("Mismatched foto_lantai_unit and name_lantai_unit inputs"); + } + + foreach ($lantaiFiles as $index => $file) { + $path = $this->uploadFile($file, 'lantai'); + LantaiUnit::create([ + 'objek_jaminan_id' => $fotojaminan->id, + 'name_lantai_unit' => "Lantai " . ($index + 1), + 'foto_lantai_unit' => $path, + ]); + } + } + + private function uploadFile($file, $type) + { + if (!$file->isValid()) { + throw new Exception("Invalid file upload for {$type}"); + } + + $fileName = time() . '_' . $file->getClientOriginalName(); + $path = $file->storeAs("public/surveyor/{$type}", $fileName); + + if ($path === false) { + throw new Exception("Failed to store file for {$type}"); + } + + return str_replace('public/', '', $path); + } + + public function dataForDatatables(Request $request) { if (is_null($this->user) || !$this->user->can('debitur.view')) { @@ -172,74 +548,88 @@ class SurveyorController extends Controller * Form inspeksi. */ - public function formInspeksi($id) + public function formInspeksi($id, $jaminanId) { - $permohonan = Permohonan::with( - [ - 'user', - 'debiture.province', - 'debiture.city', - 'debiture.district', - 'debiture.village', - 'branch', - 'tujuanPenilaian', - 'penilaian' - ], - )->findOrFail($id); + $permohonan = $this->getPermohonanJaminanId($id, $jaminanId); + $branches = Branch::all(); $provinces = Province::all(); - return view('lpj::surveyor.detail', compact('permohonan', 'branches', 'provinces')); + $surveyor = $id; + $branches = Branch::all(); + $provinces = Province::all(); + $bentukTanah = BentukTanah::all(); + $konturTanah = KonturTanah::all(); + $posisiKavling = PosisiKavling::all(); + $ketinggianTanah = KetinggianTanah::all(); + $kondisiFisikTanah = KondisiFisikTanah::all(); + $jenisBangunan = JenisBangunan::all(); + $kondisiBangunan = KondisiBangunan::all(); + $sifatBangunan = SifatBangunan::all(); + $spekKategoriBagunan = SpekKategoritBangunan::all(); + $spekBangunan = SpekBangunan::all(); + $saranaPelengkap = SaranaPelengkap::all(); + $arahMataAngin = ArahMataAngin::all(); + + + $analisa = Analisa::with('analisaTanahBangunan', 'analisaLingkungan', 'analisaFakta', 'jenisJaminan') + ->where('permohonan_id', $id) + ->where('jenis_jaminan_id', $jaminanId) + ->first(); + + + + return view('lpj::surveyor.components.inspeksi', compact( + 'analisa', + 'permohonan', + 'surveyor', + 'branches', + 'provinces', + 'bentukTanah', + 'konturTanah', + 'posisiKavling', + 'kondisiFisikTanah', + 'ketinggianTanah', + 'kondisiBangunan', + 'jenisBangunan', + 'sifatBangunan', + 'spekKategoriBagunan', + 'spekBangunan', + 'saranaPelengkap', + 'arahMataAngin', + )); } /** * Denah. */ - public function denah($id) + public function denah($id, $jaminanId) { - $permohonan = Permohonan::with( - [ - 'user', - 'debiture.province', - 'debiture.city', - 'debiture.district', - 'debiture.village', - 'branch', - 'tujuanPenilaian', - 'penilaian' - ], - )->findOrFail($id); - $surveyor = $id; - $branches = Branch::all(); - $provinces = Province::all(); + $permohonan = $this->getPermohonanJaminanId($id, $jaminanId); - return view('lpj::surveyor.detail', compact('permohonan', 'surveyor', 'branches', 'provinces')); + $denah = Denah::where('permohonan_id', $id)->where('jenis_jaminan_id', $jaminanId)->first(); + + return view('lpj::surveyor.components.denah', compact('permohonan', 'denah')); } /** * Foto. */ - public function foto($id) + public function foto($id, $jaminanId) { - $permohonan = Permohonan::with( - [ - 'user', - 'debiture.province', - 'debiture.city', - 'debiture.district', - 'debiture.village', - 'branch', - 'tujuanPenilaian', - 'penilaian' - ], - )->findOrFail($id); + $permohonan = $this->getPermohonanJaminanId($id, $jaminanId); $surveyor = $id; $branches = Branch::all(); $provinces = Province::all(); - return view('lpj::surveyor.detail', compact('permohonan', 'surveyor', 'branches', 'provinces')); + $fotoJaminan = FotoJaminan::with(['objekJaminan', 'lantaiUnit' ,'ruteJaminan', 'lingkungan'])->where('permohonan_id', $id)->where('jenis_jaminan_id', $jaminanId)->first(); + + // return response()->json([ + // 'data' => $fotoJaminan, + // ]); + return view('lpj::surveyor.components.foto', compact('permohonan', 'surveyor', 'branches', 'provinces', 'fotoJaminan')); } /** @@ -537,4 +927,58 @@ class SurveyorController extends Controller } + private function getPermohonanJaminanId($id, $jaminanId) + { + return Permohonan::with([ + 'user', + 'debiture.province', + 'debiture.city', + 'debiture.district', + 'debiture.village', + 'branch', + 'tujuanPenilaian', + 'penilaian', + 'debiture.documents' => function ($query) use ($jaminanId) { + $query->where('jenis_jaminan_id', $jaminanId); + } + ]) + ->whereHas('debiture.documents', function ($query) use ($jaminanId) { + $query->where('jenis_jaminan_id', $jaminanId); + }) + ->findOrFail($id); + } + + private function getCommonData() + { + return [ + 'branches' => Branch::all(), + 'provinces' => Province::all(), + 'bentukTanah' => BentukTanah::all(), + 'konturTanah' => KonturTanah::all(), + 'posisiKavling' => PosisiKavling::all(), + 'ketinggianTanah' => KetinggianTanah::all(), + 'kondisiFisikTanah' => KondisiFisikTanah::all(), + 'jenisBangunan' => JenisBangunan::all(), + 'kondisiBangunan' => KondisiBangunan::all(), + 'sifatBangunan' => SifatBangunan::all(), + 'spekKategoriBangunan' => SpekKategoritBangunan::all(), + 'spekBangunan' => SpekBangunan::all(), + 'saranaPelengkap' => SaranaPelengkap::all(), + 'arahMataAngin' => ArahMataAngin::all() + ]; + } + + + public function submitSurveyor(Request $request, $id) + { + $permohonan = Permohonan::find($id); + $permohonan->update([ + 'status' => 'done', + ]); + return redirect() + ->route('surveyor.index') + ->with('success', 'form surveyor submitted successfully'); + + } + } diff --git a/app/Http/Requests/FormSurveyorRequest.php b/app/Http/Requests/FormSurveyorRequest.php new file mode 100644 index 0000000..b79014a --- /dev/null +++ b/app/Http/Requests/FormSurveyorRequest.php @@ -0,0 +1,133 @@ +getCommonRules(); + $actionSpecificRules = $this->getActionSpecificRules(); + + return array_merge($commonRules, $actionSpecificRules); + } + + /** + * Get common rules that apply to all actions. + */ + private function getCommonRules(): array + { + return [ + 'jenis_jaminan_id' => 'required', + 'type' => 'required', + 'permohonan_id' => 'required', + 'luas' => 'required', + 'jarak_jalan_utama' => 'required', + 'alamat' => 'required', + 'jarak_cbd_point' => 'required', + 'lebar_perkerasan_jalan' => 'required', + 'perkerasan_jalan' => 'required', + 'lalu_lintas' => 'required', + 'gol_mas_sekitar' => 'required', + 'tingkat_keramaian' => 'required', + 'terletak_diarea' => 'required', + 'disekitar_lokasi' => 'required', + 'dekat_makam' => 'required', + 'dekat_tps' => 'required', + 'merupakan_daerah' => 'required', + 'fasilitas_dekat_object' => 'required', + 'fakta_positif' => 'required', + 'fakta_negatif' => 'required', + 'rute_menuju' => 'required', + 'batas_batas' => 'required', + 'kondisi_linkungan' => 'required', + 'kondisi_lain_bangunan' => 'required', + 'informasi_dokument' => 'required', + 'peruntukan' => 'required', + 'kdb' => 'required', + 'kdh' => 'required', + 'gsb' => 'required', + 'max_lantai' => 'required', + 'klb' => 'required', + 'gss' => 'required', + 'pelebaran_jalan' => 'required', + 'nama_petugas' => 'required', + 'lat' => 'required|numeric', + 'lng' => 'required|numeric', + 'foto_tempat' => 'required', + 'keterangan' => 'required', + ]; + } + + /** + * Get rules specific to the action. + */ + private function getActionSpecificRules(): array + { + $action = $this->input('action'); + + switch ($action) { + case 'tanah_bangunan': + return $this->getTanahBangunanRules(); + case 'unit': + return $this->getUnitRules(); + default: + return []; + } + } + + /** + * Get rules specific to tanah_bangunan action. + */ + private function getTanahBangunanRules(): array + { + return [ + 'action' => 'required', + 'bentuk_tanah' => 'required', + 'kontur_tanah' => 'required', + 'posisi_kavling' => 'required', + 'ketinggian_jalan' => 'required', + 'kondisi_fisik_tanah' => 'required', + 'kontur_jalan' => 'required', + 'kondisi_bangunan' => 'required', + 'sifat_bangunan' => 'required', + 'sarana_pelengkap' => 'required', + 'luas_tanah_bagunan' => 'required', + 'tusuk_sate' => 'required', + 'name.*' => 'required|string', + 'kategori.*' => 'required|string', + 'lockland' => 'required', + 'jenis_bangunan' => 'required', + 'kondisi_bangunan' => 'required', + ]; + } + + /** + * Get rules specific to unit action. + */ + private function getUnitRules(): array + { + return [ + 'action' => 'required', + 'jenis_unit' => 'required', + 'kondisi_unit' => 'required', + 'posisi_unit' => 'required', + 'lantai' => 'required', + 'view' => 'required', + 'bentuk_unit' => 'required', + ]; + } +} diff --git a/app/Http/Requests/SurveyorRequest.php b/app/Http/Requests/SurveyorRequest.php index c86fb8a..b986f8e 100644 --- a/app/Http/Requests/SurveyorRequest.php +++ b/app/Http/Requests/SurveyorRequest.php @@ -22,6 +22,7 @@ class SurveyorRequest extends FormRequest 'ketinggian-tanah' => 'ketinggian_tanah', 'kondisi-fisik-tanah' => 'kondisi_fisik_tanah', 'kondisi-bangunan' => 'kondisi_bangunan', + 'jenis-bangunan' => 'jenis_bangunan', 'sifat-bangunan' => 'sifat_bangunan', 'sarana-pelengkap' => 'sarana_pelengkap', 'lalu_lintas_lokasi' => 'lalu_lintas_lokasi', diff --git a/app/Models/Analisa.php b/app/Models/Analisa.php new file mode 100644 index 0000000..4134384 --- /dev/null +++ b/app/Models/Analisa.php @@ -0,0 +1,46 @@ +hasOne(AnalisaTanahBagunan::class, 'analisa_id'); + } + + + public function analisaLingkungan(){ + return $this->hasOne(AnalisaLingkungan::class, 'analisa_id'); + } + + + public function analisaFakta(){ + return $this->hasOne(AnalisaFakta::class, 'analisa_id'); + } + + public function jenisJaminan(){ + return $this->belongsTo(JenisJaminan::class, 'jenis_jaminan_id'); + } + + public function analisaUnit(){ + return $this->hasOne(AnalisaUnit::class, 'analisa_id'); + } + + + protected static function newFactory(): AnalisaFactory + { + //return AnalisaFactory::new(); + } +} diff --git a/app/Models/AnalisaFakta.php b/app/Models/AnalisaFakta.php new file mode 100644 index 0000000..63015a6 --- /dev/null +++ b/app/Models/AnalisaFakta.php @@ -0,0 +1,29 @@ +belongsTo(Analisa::class); + } + + public function spekBangunanAnalisa() + { + return $this->hasMany(SpekBangunanAnalisa::class, 'analisa_tanah_bangunan_id'); + } + + public function spekBagunanAnalisaDetail() + { + return $this->hasMany(SpekBagunanAnalisaDetail::class, 'analisa_tanah_bangunan_id'); + } + + protected static function newFactory(): AnalisaTanahBagunanFactory + { + //return AnalisaTanahBagunanFactory::new(); + } +} diff --git a/app/Models/AnalisaUnit.php b/app/Models/AnalisaUnit.php new file mode 100644 index 0000000..4c0b3a7 --- /dev/null +++ b/app/Models/AnalisaUnit.php @@ -0,0 +1,23 @@ +belongsTo(JenisJaminan::class, 'jenis_jaminan_id'); + } + + protected static function newFactory(): DenahFactory + { + //return DenahFactory::new(); + } +} diff --git a/app/Models/FotoJaminan.php b/app/Models/FotoJaminan.php new file mode 100644 index 0000000..940ecfe --- /dev/null +++ b/app/Models/FotoJaminan.php @@ -0,0 +1,41 @@ +hasMany(ObjekJaminan::class, 'foto_jaminan_id'); + } + + + public function ruteJaminan(){ + return $this->hasMany(RuteJaminan::class, 'foto_jaminan_id'); + } + + + public function lingkungan(){ + return $this->hasMany(Lingkungan::class, 'foto_jaminan_id'); + } + + + public function lantaiUnit(){ + return $this->hasMany(lantaiUnit::class, 'objek_jaminan_id', 'id'); + } +} diff --git a/app/Models/LantaiUnit.php b/app/Models/LantaiUnit.php new file mode 100644 index 0000000..b40a5c3 --- /dev/null +++ b/app/Models/LantaiUnit.php @@ -0,0 +1,24 @@ +hasMany(LantaiUnit::class, 'objek_jaminan_id', 'foto_jaminan_id'); + } + + protected static function newFactory(): ObjekJaminanFactory + { + //return ObjekJaminanFactory::new(); + } +} diff --git a/app/Models/RuteJaminan.php b/app/Models/RuteJaminan.php new file mode 100644 index 0000000..9b88940 --- /dev/null +++ b/app/Models/RuteJaminan.php @@ -0,0 +1,24 @@ +id(); + $table->enum('type', ['unit', 'tanah_bangunan']); + $table->unsignedBigInteger('permohonan_id'); + $table->foreign('permohonan_id')->references('id')->on('permohonan'); + $table->string('luas'); + $table->char('authorized_status', 1)->nullable(); + $table->timestamp('authorized_at')->nullable(); + $table->unsignedBigInteger('authorized_by')->nullable(); + $table->timestamps(); + $table->unsignedBigInteger('created_by')->nullable(); + $table->unsignedBigInteger('updated_by')->nullable(); + $table->timestamp('deleted_at')->nullable(); + $table->unsignedBigInteger('deleted_by')->nullable(); + }); +} + + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('analisa'); + } +}; diff --git a/database/migrations/2024_10_16_153558_create_analisa_tanah_bangunan_table.php b/database/migrations/2024_10_16_153558_create_analisa_tanah_bangunan_table.php new file mode 100644 index 0000000..585dbf4 --- /dev/null +++ b/database/migrations/2024_10_16_153558_create_analisa_tanah_bangunan_table.php @@ -0,0 +1,51 @@ +id(); + + $table->unsignedBigInteger('analisa_id'); + $table->foreign('analisa_id')->references('id')->on('analisa'); + $table->string('bentuk_tanah'); + $table->string('kontur_tanah'); + $table->string('ketinggian_jalan'); + $table->string('kontur_jalan'); + $table->string('posis_kavling'); + $table->enum('tusuk_sate', ['yes', 'no']); + $table->enum('lockland', ['yes', 'no']); + $table->string('kondisi_fisik_tanah'); + $table->string('jenis_bangunan'); + $table->string('kondisi_bangunan'); + $table->string('sifat_bangunan'); + $table->string('sarana_pelengkap'); + $table->char('authorized_status', 1)->nullable(); + $table->timestamp('authorized_at')->nullable(); + $table->unsignedBigInteger('authorized_by')->nullable(); + + $table->timestamps(); + $table->unsignedBigInteger('created_by')->nullable(); + $table->unsignedBigInteger('updated_by')->nullable(); + + $table->timestamp('deleted_at')->nullable(); + $table->unsignedBigInteger('deleted_by')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('analisa_tanah_bangunan'); + } +}; diff --git a/database/migrations/2024_10_16_153613_create_analisa_unit_table.php b/database/migrations/2024_10_16_153613_create_analisa_unit_table.php new file mode 100644 index 0000000..7638518 --- /dev/null +++ b/database/migrations/2024_10_16_153613_create_analisa_unit_table.php @@ -0,0 +1,47 @@ +id(); + + $table->unsignedBigInteger('analisa_id'); + $table->foreign('analisa_id')->references('id')->on('analisa'); + + $table->string('jenis_unit'); + $table->string('kondisi_unit'); + $table->string('posisi_unit'); + $table->string('lantai'); + $table->string('view'); + $table->string('bentuk_unit'); + + $table->char('authorized_status', 1)->nullable(); + $table->timestamp('authorized_at')->nullable(); + $table->unsignedBigInteger('authorized_by')->nullable(); + + $table->timestamps(); + $table->unsignedBigInteger('created_by')->nullable(); + $table->unsignedBigInteger('updated_by')->nullable(); + + $table->timestamp('deleted_at')->nullable(); + $table->unsignedBigInteger('deleted_by')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('analisa_unit'); + } +}; diff --git a/database/migrations/2024_10_16_153727_create_spek_bagunan_analisa_table.php b/database/migrations/2024_10_16_153727_create_spek_bagunan_analisa_table.php new file mode 100644 index 0000000..9da658b --- /dev/null +++ b/database/migrations/2024_10_16_153727_create_spek_bagunan_analisa_table.php @@ -0,0 +1,42 @@ +id(); + $table->string('name'); + + // Foreign key to analisa_tanah_bangunan + $table->unsignedBigInteger('analisa_tanah_bangunan_id'); + $table->foreign('analisa_tanah_bangunan_id')->references('id')->on('analisa_tanah_bangunan'); + + $table->char('authorized_status', 1); + $table->timestamp('authorized_at')->nullable(); + $table->unsignedBigInteger('authorized_by')->nullable(); + + $table->timestamps(); + $table->unsignedBigInteger('created_by'); + $table->unsignedBigInteger('updated_by')->nullable(); + + $table->timestamp('deleted_at')->nullable(); + $table->unsignedBigInteger('deleted_by')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('spek_bagunan_analisa'); + } +}; diff --git a/database/migrations/2024_10_16_153743_create_spek_bagunan_analisa_detail_table.php b/database/migrations/2024_10_16_153743_create_spek_bagunan_analisa_detail_table.php new file mode 100644 index 0000000..e3f190b --- /dev/null +++ b/database/migrations/2024_10_16_153743_create_spek_bagunan_analisa_detail_table.php @@ -0,0 +1,42 @@ +id(); + $table->string('kategori'); + $table->string('name'); + + // Foreign key to spek_bangunan_analisa + $table->unsignedBigInteger('spek_bangunan_analisa_id'); + $table->foreign('spek_bangunan_analisa_id')->references('id')->on('spek_bagunan_analisa'); + + $table->char('authorized_status', 1); + $table->timestamp('authorized_at')->nullable(); + $table->unsignedBigInteger('authorized_by')->nullable(); + + $table->timestamps(); + $table->unsignedBigInteger('created_by'); + $table->unsignedBigInteger('updated_by')->nullable(); + + $table->timestamp('deleted_at')->nullable(); + $table->unsignedBigInteger('deleted_by')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('spek_bagunan_analisa_detail'); + } +}; diff --git a/database/migrations/2024_10_16_153811_create_analisa_fakta_table.php b/database/migrations/2024_10_16_153811_create_analisa_fakta_table.php new file mode 100644 index 0000000..7e05782 --- /dev/null +++ b/database/migrations/2024_10_16_153811_create_analisa_fakta_table.php @@ -0,0 +1,60 @@ +id(); + // Foreign key to analisa table + $table->unsignedBigInteger('analisa_id'); + $table->foreign('analisa_id')->references('id')->on('analisa'); + + $table->text('fakta_positif'); + $table->text('fakta_negatif'); + $table->text('rute_menju'); + $table->string('batas_batas'); + $table->text('kondisi_linkungan'); + $table->text('kondisi_lain_bangunan'); + $table->text('informasi_dokument'); + $table->string('peruntukan'); + $table->string('kdb'); + $table->string('kdh'); + $table->string('gsb'); + $table->string('max_lantai'); + $table->string('klb'); + $table->string('gss'); + $table->string('pelebaran_jalan'); + $table->string('nama_petugas'); + $table->string('foto_tempat'); + $table->string('lat'); + $table->string('lng'); + $table->text('keterangan'); + + $table->char('authorized_status', 1); + $table->timestamp('authorized_at')->nullable(); + $table->unsignedBigInteger('authorized_by')->nullable(); + + $table->timestamps(); // created_at and updated_at + $table->unsignedBigInteger('created_by'); + $table->unsignedBigInteger('updated_by')->nullable(); + + $table->timestamp('deleted_at')->nullable(); + $table->unsignedBigInteger('deleted_by')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('analisa_fakta'); + } +}; diff --git a/database/migrations/2024_10_16_153831_create_analisa_lingkungan_table.php b/database/migrations/2024_10_16_153831_create_analisa_lingkungan_table.php new file mode 100644 index 0000000..e0c5e22 --- /dev/null +++ b/database/migrations/2024_10_16_153831_create_analisa_lingkungan_table.php @@ -0,0 +1,53 @@ +id(); + $table->unsignedBigInteger('analisa_id'); + $table->foreign('analisa_id')->references('id')->on('analisa'); + + $table->string('jarak_jalan_utama'); + $table->string('alamat'); + $table->string('jarak_cbd_point'); + $table->string('lebar_perkerasan_jalan'); + $table->string('perkerasan_jalan'); + $table->string('lalu_lintas'); + $table->string('gol_mas_sekitar'); + $table->string('tingkat_keramaian'); + $table->string('terletak_diarea'); + $table->string('disekitar_lokasi'); + $table->string('dekat_makam'); + $table->enum('dekat_tps', ['yes', 'no']); + $table->string('merupakan_daerah'); + $table->string('fasilitas_dekat_object'); + + $table->char('authorized_status', 1); + $table->timestamp('authorized_at')->nullable(); + $table->unsignedBigInteger('authorized_by')->nullable(); + + $table->timestamps(); // created_at and updated_at + $table->unsignedBigInteger('created_by'); + $table->unsignedBigInteger('updated_by')->nullable(); + + $table->timestamp('deleted_at')->nullable(); + $table->unsignedBigInteger('deleted_by')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('analisa_lingkungan'); + } +}; diff --git a/database/migrations/2024_10_16_153841_create_denah_table.php b/database/migrations/2024_10_16_153841_create_denah_table.php new file mode 100644 index 0000000..308a7ad --- /dev/null +++ b/database/migrations/2024_10_16_153841_create_denah_table.php @@ -0,0 +1,42 @@ +id(); + // Foreign key to permohonan table + $table->unsignedBigInteger('permohonan_id'); + $table->foreign('permohonan_id')->references('id')->on('permohonan'); + + $table->string('foto_denah'); + $table->string('luas'); + + $table->char('authorized_status', 1)->nullable(); + $table->timestamp('authorized_at')->nullable(); + $table->unsignedBigInteger('authorized_by')->nullable(); + + $table->timestamps(); // created_at and updated_at + $table->unsignedBigInteger('created_by')->nullable(); + $table->unsignedBigInteger('updated_by')->nullable(); + + $table->timestamp('deleted_at')->nullable(); + $table->unsignedBigInteger('deleted_by')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('denah'); + } +}; diff --git a/database/migrations/2024_10_16_153902_create_foto_jaminan_table.php b/database/migrations/2024_10_16_153902_create_foto_jaminan_table.php new file mode 100644 index 0000000..f0e1000 --- /dev/null +++ b/database/migrations/2024_10_16_153902_create_foto_jaminan_table.php @@ -0,0 +1,40 @@ +id(); + $table->unsignedBigInteger('permohonan_id'); + $table->foreign('permohonan_id')->references('id')->on('permohonan'); + + $table->string('pendamping'); + + $table->char('authorized_status', 1)->nullable(); + $table->timestamp('authorized_at')->nullable(); + $table->unsignedBigInteger('authorized_by')->nullable(); + + $table->timestamps(); // created_at and updated_at + $table->unsignedBigInteger('created_by')->nullable(); + $table->unsignedBigInteger('updated_by')->nullable(); + + $table->timestamp('deleted_at')->nullable(); + $table->unsignedBigInteger('deleted_by')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('foto_jaminan'); + } +}; diff --git a/database/migrations/2024_10_16_153918_create_objek_jaminan_table.php b/database/migrations/2024_10_16_153918_create_objek_jaminan_table.php new file mode 100644 index 0000000..b55f7eb --- /dev/null +++ b/database/migrations/2024_10_16_153918_create_objek_jaminan_table.php @@ -0,0 +1,42 @@ +id(); + // Foreign key to foto_jaminan table + $table->unsignedBigInteger('foto_jaminan_id'); + $table->foreign('foto_jaminan_id')->references('id')->on('foto_jaminan'); + + $table->string('name'); + $table->string('foto_objek'); + + $table->char('authorized_status', 1)->nullable(); + $table->timestamp('authorized_at')->nullable(); + $table->unsignedBigInteger('authorized_by')->nullable(); + + $table->timestamps(); // created_at and updated_at + $table->unsignedBigInteger('created_by')->nullable(); + $table->unsignedBigInteger('updated_by')->nullable(); + + $table->timestamp('deleted_at')->nullable(); + $table->unsignedBigInteger('deleted_by')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('objek_jaminan'); + } +}; diff --git a/database/migrations/2024_10_16_153945_create_lingkungan_table.php b/database/migrations/2024_10_16_153945_create_lingkungan_table.php new file mode 100644 index 0000000..58f4289 --- /dev/null +++ b/database/migrations/2024_10_16_153945_create_lingkungan_table.php @@ -0,0 +1,42 @@ +id(); + // Foreign key to foto_jaminan table + $table->unsignedBigInteger('foto_jaminan_id'); + $table->foreign('foto_jaminan_id')->references('id')->on('foto_jaminan'); + + $table->string('name_lingkungan'); + $table->string('foto_linkungan'); + + $table->char('authorized_status', 1)->nullable(); + $table->timestamp('authorized_at')->nullable(); + $table->unsignedBigInteger('authorized_by')->nullable(); + + $table->timestamps(); + $table->unsignedBigInteger('created_by')->nullable(); + $table->unsignedBigInteger('updated_by')->nullable(); + + $table->timestamp('deleted_at')->nullable(); + $table->unsignedBigInteger('deleted_by')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('lingkungan'); + } +}; diff --git a/database/migrations/2024_10_16_155227_create_rute_jaminan_table.php b/database/migrations/2024_10_16_155227_create_rute_jaminan_table.php new file mode 100644 index 0000000..6db988e --- /dev/null +++ b/database/migrations/2024_10_16_155227_create_rute_jaminan_table.php @@ -0,0 +1,43 @@ +id(); + + // Foreign key to foto_jaminan table + $table->unsignedBigInteger('foto_jaminan_id'); + $table->foreign('foto_jaminan_id')->references('id')->on('foto_jaminan'); + + $table->string('name'); + $table->string('foto_rute'); + + $table->char('authorized_status', 1)->nullable(); + $table->timestamp('authorized_at')->nullable(); + $table->unsignedBigInteger('authorized_by')->nullable(); + + $table->timestamps(); // created_at and updated_at + $table->unsignedBigInteger('created_by')->nullable(); + $table->unsignedBigInteger('updated_by')->nullable(); + + $table->timestamp('deleted_at')->nullable(); + $table->unsignedBigInteger('deleted_by')->nullable(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('rute_jaminan'); + } +}; diff --git a/database/migrations/2024_10_22_064209_create_lantai_unit_table.php b/database/migrations/2024_10_22_064209_create_lantai_unit_table.php new file mode 100644 index 0000000..bf3c8c0 --- /dev/null +++ b/database/migrations/2024_10_22_064209_create_lantai_unit_table.php @@ -0,0 +1,40 @@ +id(); + $table->unsignedBigInteger('objek_jaminan_id'); + $table->string('name_lantai_unit'); + $table->string('foto_lantai_unit'); + + $table->char('authorized_status', 1)->nullable(); + $table->timestamp('authorized_at')->nullable(); + $table->unsignedBigInteger('authorized_by')->nullable(); + $table->timestamps(); + $table->unsignedBigInteger('created_by')->nullable(); + $table->unsignedBigInteger('updated_by')->nullable(); + + $table->timestamp('deleted_at')->nullable(); + $table->unsignedBigInteger('deleted_by')->nullable(); + + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('lantai_unit'); + } +}; diff --git a/resources/views/surveyor/components/apartemen-kantor.blade.php b/resources/views/surveyor/components/apartemen-kantor.blade.php index b9c021a..05e0adb 100644 --- a/resources/views/surveyor/components/apartemen-kantor.blade.php +++ b/resources/views/surveyor/components/apartemen-kantor.blade.php @@ -10,16 +10,18 @@
+ {{-- {{ $analisa->type }} --}} +
++ {{-- Display relevant analisaLingkungan data --}} +
+{{-- Display relevant analisaFakta data --}} +
+