@extends('layouts.app')
@section('title', __('Expenses'))
@section('content')<div class="row g-3"><div class="col-lg-4"><div class="card"><div class="card-body p-4"><h6>{{ __('Record Expense') }}</h6><form method="POST" action="{{ route('expenses.store') }}">@csrf<label class="form-label mt-2">{{ __('Category') }}</label><input name="category" class="form-control" placeholder="Transport, rent, salary..." required><label class="form-label mt-3">{{ __('Amount') }}</label><input name="amount" type="number" min="0.01" step="0.01" class="form-control" required><label class="form-label mt-3">{{ __('Currency') }}</label><select name="currency_code" class="form-select">@foreach($currencies as $currency)<option value="{{ $currency->code }}" @selected($currency->is_default)>{{ $currency->code }}</option>@endforeach</select><label class="form-label mt-3">{{ __('Date') }}</label><input name="expense_date" type="date" class="form-control" value="{{ now()->toDateString() }}"><select name="method" class="form-select mt-3"><option value="cash">{{ __('Cash') }}</option><option value="bank">{{ __('Bank') }}</option><option value="mobile">{{ __('Mobile Money') }}</option></select><textarea name="notes" class="form-control mt-3" rows="2" placeholder="{{ __('Notes') }}"></textarea><button class="btn btn-success w-100 mt-3">{{ __('Save Expense') }}</button></form></div></div></div><div class="col-lg-8"><div class="card"><div class="card-body"><table class="table align-middle"><thead><tr><th>{{ __('Date') }}</th><th>{{ __('Category') }}</th><th>{{ __('Amount') }}</th><th>{{ __('Method') }}</th><th></th></tr></thead><tbody>@forelse($expenses as $expense)<tr><td>{{ $expense->expense_date->format('d M Y') }}</td><td>{{ $expense->category }}<small class="d-block text-muted">{{ $expense->notes }}</small></td><td>{{ number_format($expense->amount,2) }} {{ $expense->currency_code }}</td><td>{{ ucfirst($expense->method) }}</td><td><form method="POST" action="{{ route('expenses.destroy',$expense) }}">@csrf @method('DELETE')<button class="btn btn-light btn-sm text-danger"><i class="fa-solid fa-trash"></i></button></form></td></tr>@empty<tr><td colspan="5" class="text-center text-muted py-5">{{ __('No expenses yet.') }}</td></tr>@endforelse</tbody></table>{{ $expenses->links('pagination::bootstrap-5') }}</div></div></div></div>@endsection
