validated(); $validated['persentase'] = FormatHelper::formatPersentase($validated['persentase']); Aspek::create($validated); return redirect()->route('aspek.index')->with('success', 'Data Berhasil Ditambah'); } catch (\Exception $e) { Log::error($e->getMessage()); return back()->with(['error' => 'Gagal Menambahkan Data: ' . $e->getMessage()]); } } /** * Display the specified resource. */ public function show(string $id) { $data['aspek'] = Aspek::find($id); return view('pages.aspek.show', $data); } /** * Show the form for editing the specified resource. */ public function edit(string $id) { $data['aspek'] = Aspek::find($id); return view('pages.aspek.edit', $data); } /** * Update the specified resource in storage. */ public function update(AspekCreateRequest $request, string $id) { try { $validated = $request->validated(); $validated['persentase'] = FormatHelper::formatPersentase($validated['persentase']); Aspek::find($id)->update($validated); return redirect()->route('aspek.index')->with('success', 'Data Berhasil Diperbarui'); } catch (\Exception $e) { Log::error($e->getMessage()); return back()->with(['error' => 'Gagal Mengubah Data: ' . $e->getMessage()]); } } /** * Remove the specified resource from storage. */ public function destroy(string $id) { try { Aspek::find($id)->delete(); return redirect()->route('aspek.index')->with('success', 'Data Berhasil Dihapus'); } catch (\Exception $e) { Log::error($e->getMessage()); return back()->with(['error' => 'Gagal Menghapus Data: ' . $e->getMessage()]); } } }