user() ->accounts() ->with('bank:id,name,logo') ->orderBy('name') ->get(['id', 'name', 'name_iv', 'bank_id', 'type', 'currency_code']); $banks = Bank::query() ->where(function ($query) { $query->where('user_id', auth()->id()) ->orWhereNull('user_id'); }) ->orderBy('name') ->get(['id', 'name', 'logo']); return Inertia::render('settings/accounts', [ 'accounts' => $accounts, 'banks' => $banks, ]); } /** * Store a newly created account. */ public function store(StoreAccountRequest $request): RedirectResponse { auth()->user()->accounts()->create($request->validated()); return to_route('accounts.index'); } /** * Update the specified account. */ public function update(UpdateAccountRequest $request, Account $account): RedirectResponse { $this->authorize('update', $account); $account->update($request->validated()); return to_route('accounts.index'); } /** * Hard delete the specified account and cascade delete all transactions. */ public function destroy(Account $account): RedirectResponse { $this->authorize('delete', $account); $account->transactions()->delete(); $account->delete(); return to_route('accounts.index'); } }