"Klasifikasi Rekap Konten" ]); } public function create(){ return view('dashboard.content-recaps.classifications.create', [ 'title' => "Buat Klasifikasi Rekap Konten Baru" ]); } public function store(ContentRecapClassificationRequest $request){ $validatedData = $request->validated(); try{ $existedData = ContentRecapClassification::withTrashed()->where('slug', $validatedData['slug'])->first(); if($existedData && filled($existedData->deleted_at)){ return redirect()->back()->with('data-exists', $validatedData['slug']); }elseif($existedData){ return redirect()->back()->with('failed-status', 'Tema dengan nama tersebut sudah ada.'); } $createdClassification = ContentRecapClassification::create($validatedData); }catch(\Exception $e){ Log::error("ContentRecapClassifications (store): ". $e); return redirect()->back()->with('failed-status', 'Gagal menambahkan klasifikasi rekap konten.'); } return redirect()->route('dashboard.content.recap.classifications.index')->with('success-status', 'Berhasil menambahkan klasifikasi rekap konten.') ->with('new_data', encrypt_id($createdClassification->id)); } public function edit($id){ $contentRecapClassification = ContentRecapClassification::findOrFail(decrypt_id($id)); return view('dashboard.content-recaps.classifications.edit', [ 'title' => "Ubah Klasifikasi Rekap Konten", 'contentRecapClassification' => $contentRecapClassification ]); } public function update(ContentRecapClassificationRequest $request, $id){ $validatedData = $request->validated(); try{ $contentRecapClassification = ContentRecapClassification::findOrFail(decrypt_id($id)); $contentRecapClassification->update($validatedData); }catch(\Exception $e){ Log::error("ContentRecapClassifications (update): ". $e); return redirect()->back()->with('failed-status', 'Gagal mengubah klasifikasi rekap konten.'); } return redirect()->route('dashboard.content.recap.classifications.show', ['id' => encrypt_id($contentRecapClassification->id)])->with('success-status', 'Berhasil mengubah klasifikasi rekap konten.'); } public function show($id){ $contentRecapClassification = ContentRecapClassification::findOrFail(decrypt_id($id)); return view('dashboard.content-recaps.classifications.show', [ 'title' => "Detail Klasifikasi Rekap Konten", 'contentRecapClassification' => $contentRecapClassification ]); } public function destroy($id){ try { $contentRecapClassification = ContentRecapClassification::findOrFail(decrypt_id($id)); $contentRecapClassification->delete(); return response()->json(['message' => 'Berhasil menghapus klasifikasi rekap konten.']); } catch (\Exception $e) { Log::error("ContentRecapClassifications (destroy): ". $e); return response()->json(['message' => 'Gagal menghapus klasifikasi rekap konten.'], 500); } } public function restore($slug) { try{ $recapContentClassification = ContentRecapClassification::withTrashed() ->where('slug', $slug) ->first(); if (!$recapContentClassification) { return redirect()->back()->with('failed-status', 'Klasifikasi tidak ditemukan.'); } if (filled($recapContentClassification->deleted_at)) { $recapContentClassification->restore(); return redirect()->back()->with('success-status', 'Klasifikasi berhasil dipulihkan.'); } return redirect()->back()->with('info-status', 'Klasifikasi sudah aktif.'); }catch(\Exception $e){ Log::error("ContentRecapClassifications (restore): ". $e); return redirect()->back()->with('failed-status', 'Gagal melakukan proses pemulihan.'); } } }