From b882c61e6b31b320dd4e7595c8f1cad9f8f9935a Mon Sep 17 00:00:00 2001 From: Pusdatin BPKD Jkt Date: Fri, 21 Oct 2022 10:34:49 +0700 Subject: [PATCH] Ubah SPD Tanpa Refresh --- .../RealisasiBelanjaController.php | 13 +++++++-- .../views/realisasi_belanja/index.blade.php | 29 ++++++++++++++++++- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/RealisasiBelanjaController.php b/app/Http/Controllers/RealisasiBelanjaController.php index 40cf812..b30f5c9 100644 --- a/app/Http/Controllers/RealisasiBelanjaController.php +++ b/app/Http/Controllers/RealisasiBelanjaController.php @@ -604,7 +604,12 @@ class RealisasiBelanjaController extends Controller } DB::commit(); - return redirect($redirect)->with('success','Data SPD berhasil di input!'); + $msg = "Data SPD berhasil di input!"; + if($request->ajax()){ + return response()->json(["success"=>true, "message"=>$msg]); + }else{ + return redirect($redirect)->with('success',$msg); + } // }else{ // return redirect($redirect)->with('error', "Data SPD belum dipilih!"); // } @@ -612,7 +617,11 @@ class RealisasiBelanjaController extends Controller }catch(\Exception $e){ throw new \Exception($e->getMessage()); DB::rollBack(); - return redirect($redirect)->with('error',$e->getMessage()); + if($request->ajax()){ + return response()->json(["success"=>false, "message"=>$e->getMessage()]); + }else{ + return redirect($redirect)->with('error',$e->getMessage()); + } } } diff --git a/resources/views/realisasi_belanja/index.blade.php b/resources/views/realisasi_belanja/index.blade.php index 1eda132..9e4149c 100644 --- a/resources/views/realisasi_belanja/index.blade.php +++ b/resources/views/realisasi_belanja/index.blade.php @@ -150,9 +150,11 @@ + @endsection \ No newline at end of file