fix(assessment-form): fix session presentase set minus value

This commit is contained in:
arieeefajar 2025-05-09 21:17:17 +07:00
parent b15e0486f2
commit 9f32685fff
2 changed files with 8 additions and 4 deletions

View File

@ -70,7 +70,8 @@ public function store(Request $request)
];
})->collapse();
$cf_he_array = $cf_he->toArray();
// $cf_he_array = $cf_he->toArray();
$cf_he_array = collect($cf_he)->sortKeys()->values()->toArray();
$cf_combined = array_shift($cf_he_array);
@ -96,8 +97,6 @@ public function store(Request $request)
$hasil = 'tidak cocok';
}
// dd($cf_e, $cf_h, $cf_he, $cf_combined, $hasil);
$landName = Land::find($request->land)->owner;
DB::beginTransaction();
@ -118,6 +117,11 @@ public function store(Request $request)
}
DB::commit();
$presentase = round($cf_combined * 100, 2);
if ($presentase < 0) {
$presentase = "minus";
}
toast("Data berhasil disimpan.", "success")->position('top-right')->autoclose(3000);
return redirect()->back()->with(['land' => $landName, 'presentase' => $presentase, 'hasil' => $hasil]);
} catch (\Throwable $th) {

View File

@ -84,7 +84,7 @@
Certainty
Factor.</p>
<h1 class="mb-0 mt-2"><span class="counter-value"
data-target="{{ session('presentase') }}">0</span>%
data-target="{{ session('presentase') != 'minus' ? session('presentase') : '0' }}">0</span>%
</h1>
@endif
@if (session('hasil') && session('land'))