dstpabuaran.com/app/Http/Controllers/Admin/Finance/CashAccountController.php
Yoga Pangestu c3d8ea2f66 feat: implement cash account management with deposit and withdrawal functionality
- Introduced CashAccountController for managing cash accounts.
- Created CashTransactionRequest and CashAccountRequest for transaction validation.
- Developed CashAccountService to handle business logic for cash transactions.
- Added UI components for cash account management, including deposit and withdrawal dialogs.
- Implemented data tables for displaying transactions and cash account details.
- Updated routes to include cash account management endpoints.
- Added tests for cash account functionality, including deposit and withdrawal operations.
2026-07-29 02:08:39 +07:00

46 lines
1.3 KiB
PHP

<?php
namespace App\Http\Controllers\Admin\Finance;
use App\Http\Controllers\Controller;
use App\Http\Requests\Admin\Finance\CashTransactionRequest;
use App\Services\Admin\Finance\CashAccountService;
use Illuminate\Http\RedirectResponse;
use Inertia\Inertia;
use Inertia\Response;
class CashAccountController extends Controller
{
public function __construct(
private CashAccountService $service
) {}
public function index(): Response
{
$cashAccount = $this->service->get();
return Inertia::render('admin/finance/cash-account/index', [
'cashAccount' => $cashAccount,
'transactions' => $this->service->getAllTransactions(),
]);
}
public function deposit(CashTransactionRequest $request): RedirectResponse
{
$this->service->deposit($request->validated());
Inertia::flash('toast', ['type' => 'success', 'message' => 'Deposit berhasil ditambahkan.']);
return to_route('admin.finance.cash-accounts.index');
}
public function withdrawal(CashTransactionRequest $request): RedirectResponse
{
$this->service->withdrawal($request->validated());
Inertia::flash('toast', ['type' => 'success', 'message' => 'Withdrawal berhasil ditambahkan.']);
return to_route('admin.finance.cash-accounts.index');
}
}