fix loading all pages

This commit is contained in:
arifal
2025-02-12 01:53:40 +07:00
parent 1a15bc03f8
commit b4b34b503e
22 changed files with 784 additions and 166 deletions

View File

@@ -36,12 +36,13 @@ class DataSettingController extends Controller
DB::beginTransaction();
DataSetting::create($request->validated());
DB::commit();
return redirect()->route("data-settings.index")->with("success","Successfully created");
return response()->json(['message' => 'Successfully created'],201);
}catch(Exception $ex){
DB::rollBack();
return redirect()->back()
->withInput()
->with('error', 'Something went wrong while saving data. ' . $ex->getMessage());
return response()->json([
'message' => 'Failed to create data setting',
'error' => $ex->getMessage()
], 500);
}
}
@@ -79,12 +80,10 @@ class DataSettingController extends Controller
$data = DataSetting::findOrFail($id);
$data->update($request->validated());
DB::commit();
return redirect()->route("data-settings.index")->with("success","Successfully updated");
return response()->json(['message' => 'Successfully updated'], 200);
}catch(Exception $ex){
DB::rollBack();
return redirect()->back()
->withInput()
->with('error', 'Something went wrong while saving data. ' . $ex->getMessage());
return response()->json(['message' => $ex->getMessage()],500);
}
}
@@ -97,7 +96,7 @@ class DataSettingController extends Controller
DB::beginTransaction();
DataSetting::findOrFail($id)->delete();
DB::commit();
return response()->json(['success' => true, 'message' => 'Item deleted successfully.']);
return response()->json(['success' => true, 'message' => 'Item deleted successfully.'], 200);
}catch(Exception $e){
DB::rollBack();
Log::error($e->getMessage());