update form menu surveyor
This commit is contained in:
@@ -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');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user