service->get(); return Inertia::render('admin/finance/cash-account/index', [ 'cashAccount' => $cashAccount, 'transactions' => $this->service->getAllTransactions(), ]); } public function deposit(CashTransactionRequest $request): RedirectResponse { try { $this->service->deposit($request->validated()); Inertia::flash('toast', ['type' => 'success', 'message' => 'Deposit berhasil ditambahkan.']); } catch (ValidationException $e) { $firstError = collect($e->errors())->flatten()->first(); Inertia::flash('toast', ['type' => 'error', 'message' => $firstError ?? 'Terjadi kesalahan.']); } catch (\Exception $e) { Inertia::flash('toast', ['type' => 'error', 'message' => $e->getMessage()]); } return to_route('admin.finance.cash-accounts.index'); } public function withdrawal(CashTransactionRequest $request): RedirectResponse { try { $this->service->withdrawal($request->validated()); Inertia::flash('toast', ['type' => 'success', 'message' => 'Withdrawal berhasil ditambahkan.']); } catch (ValidationException $e) { $firstError = collect($e->errors())->flatten()->first(); Inertia::flash('toast', ['type' => 'error', 'message' => $firstError ?? 'Terjadi kesalahan.']); } catch (\Exception $e) { Inertia::flash('toast', ['type' => 'error', 'message' => $e->getMessage()]); } return to_route('admin.finance.cash-accounts.index'); } public function update(CashTransactionRequest $request, CashTransaction $transaction): RedirectResponse { try { $this->service->updateTransaction($transaction, $request->validated()); Inertia::flash('toast', ['type' => 'success', 'message' => 'Transaksi berhasil diperbarui.']); } catch (ValidationException $e) { $firstError = collect($e->errors())->flatten()->first(); Inertia::flash('toast', ['type' => 'error', 'message' => $firstError ?? 'Terjadi kesalahan.']); } catch (\Exception $e) { Inertia::flash('toast', ['type' => 'error', 'message' => $e->getMessage()]); } return to_route('admin.finance.cash-accounts.index'); } public function destroy(CashTransaction $transaction): RedirectResponse { try { $this->service->deleteTransaction($transaction); Inertia::flash('toast', ['type' => 'success', 'message' => 'Transaksi berhasil dihapus.']); } catch (ValidationException $e) { $firstError = collect($e->errors())->flatten()->first(); Inertia::flash('toast', ['type' => 'error', 'message' => $firstError ?? 'Terjadi kesalahan.']); } catch (\Exception $e) { Inertia::flash('toast', ['type' => 'error', 'message' => $e->getMessage()]); } return to_route('admin.finance.cash-accounts.index'); } }