@extends('backend.master')

@section('title', 'Edit Bank Method')

@section('content')
<h1 class="h4 mb-3">Edit Bank: {{ $bankMethod->bank_name }}</h1>

@if ($errors->any())
    <div class="alert alert-danger">
        <ul class="mb-0">
            @foreach ($errors->all() as $error)
                <li>{{ $error }}</li>
            @endforeach
        </ul>
    </div>
@endif

<form action="{{ route('admin.deposit-methods.bank.update', $bankMethod) }}"
      method="POST" enctype="multipart/form-data">
    @csrf
    @method('PUT')

    <div class="mb-3">
        <label class="form-label">Bank Name</label>
        <input type="text" name="bank_name" value="{{ old('bank_name', $bankMethod->bank_name) }}" class="form-control" required>
    </div>

    <div class="mb-3">
        <label class="form-label">Slug</label>
        <input type="text" name="slug" value="{{ old('slug', $bankMethod->slug) }}" class="form-control" required>
    </div>

    <div class="mb-3">
        <label class="form-label">Logo (image)</label>
        @if($bankMethod->logo)
            <div class="mb-2">
                <img src="{{ asset('storage/'.$bankMethod->logo) }}" alt="" width="60">
            </div>
        @endif
        <input type="file" name="logo" class="form-control">
        <small class="text-muted">নতুন ছবি আপলোড করলে পুরনোটা রিপ্লেস হবে।</small>
    </div>

    <div class="mb-3">
        <label class="form-label">Account Number</label>
        <input type="text" name="account_number"
               value="{{ old('account_number', $bankMethod->account_number) }}"
               class="form-control" required>
    </div>

    <div class="mb-3">
        <label class="form-label">Account Holder</label>
        <input type="text" name="account_holder"
               value="{{ old('account_holder', $bankMethod->account_holder) }}"
               class="form-control" required>
    </div>

    <div class="mb-3">
        <label class="form-label">Branch Name</label>
        <input type="text" name="branch_name"
               value="{{ old('branch_name', $bankMethod->branch_name) }}"
               class="form-control">
    </div>

    <div class="mb-3 row">
        <div class="col-md-4">
            <label class="form-label">Sort Order</label>
            <input type="number" name="sort_order"
                   value="{{ old('sort_order', $bankMethod->sort_order) }}"
                   class="form-control">
        </div>
        <div class="col-md-4 d-flex align-items-end">
            <div class="form-check">
                <input type="checkbox" name="status" value="1" class="form-check-input" id="status"
                       {{ old('status', $bankMethod->status) ? 'checked' : '' }}>
                <label for="status" class="form-check-label">Active</label>
            </div>
        </div>
    </div>

    <button class="btn btn-primary">Update</button>
    <a href="{{ route('admin.deposit-methods.bank.index') }}" class="btn btn-secondary">Back</a>
</form>
@endsection
