Skip to content

Commit

Permalink
fix bug in update cabang
Browse files Browse the repository at this point in the history
  • Loading branch information
punkestu committed Nov 24, 2024
1 parent 7cca20c commit 48f3448
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions app/Http/Controllers/Rotasi/CabangController.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,18 @@ public function update(Request $request, $id)
'longitude' => 'required',
]);
$cabang->save();
$cabang->coord()->update([
'latitude' => $request->latitude,
'longitude' => $request->longitude,
]);

if ($cabang->coord()->exists()) {
$cabang->coord()->update([
'latitude' => $request->latitude,
'longitude' => $request->longitude,
]);
} else {
$cabang->coord()->create([
'latitude' => $request->latitude,
'longitude' => $request->longitude,
]);
}
} else {
if ($cabang->coord()->exists())
$cabang->coord()->delete();
Expand Down

0 comments on commit 48f3448

Please sign in to comment.