get(); return Inertia::render('admin/kegiatan/index_refhistory_kegiatan', ['refhistorykegiatan' => $refhistorykegiatan]); } catch (\Exception $e) { Log::error('Error fetching Ref History Kegiatan: ' . $e->getMessage()); return back()->with('error', 'Something went wrong.'); } } public function store(RefHistoryKegiatanRequest $request) { try { $refhistorykegiatan = RefHistoryKegiatan::withTrashed() ->where('NamaHistoryKegiatan', $request->NamaHistoryKegiatan) ->first(); if ($refhistorykegiatan) { $refhistorykegiatan->restore(); return redirect()->route('admin.refhistorykegiatan.index')->with('success', 'Ref History Kegiatan berhasil dikembalikan.'); } RefHistoryKegiatan::create($request->validated()); return redirect()->route('admin.refhistorykegiatan.index')->with('success', 'Ref History Kegiatan berhasil dibuat.'); } catch (\Exception $e) { Log::error('Error creating Ref History Kegiatan: ' . $e->getMessage()); return back()->with('error', 'Something went wrong.'); } } public function update(RefHistoryKegiatanRequest $request, RefHistoryKegiatan $refhistorykegiatan) { try { $refhistorykegiatan->update($request->validated()); return redirect()->route('admin.refhistorykegiatan.index')->with('success', 'Ref History Kegiatan berhasil diperbarui.'); } catch (\Exception $e) { Log::error('Error updating Ref History Kegiatan: ' . $e->getMessage()); return back()->with('error', 'Something went wrong.'); } } public function destroy(RefHistoryKegiatan $refhistorykegiatan) { try { $refhistorykegiatan->delete(); return redirect()->route('admin.refhistorykegiatan.index')->with('success', 'Ref History Kegiatan berhasil dihapus.'); } catch (\Exception $e) { Log::error('Error deleting Ref History Kegiatan: ' . $e->getMessage()); return back()->with('error', 'Something went wrong.'); } } }