@extends('layouts.app')
@section('title', isset($customer) ? 'Edit Customer' : 'Add Customer')
@section('content')
<h4 class="mb-3">{{ isset($customer) ? 'Edit Customer' : 'Add Customer' }}</h4>
<div class="card">
    <div class="card-body">
        <form action="{{ isset($customer) ? route('customers.update', $customer) : route('customers.store') }}" method="POST">
            @csrf
            @if(isset($customer)) @method('PUT') @endif
            <div class="row g-3">
                <div class="col-md-3">
                    <label for="name" class="form-label">Name</label>
                    <input type="text" name="name" id="name" class="form-control" value="{{ old('name', $customer->name ?? '') }}" required>
                </div>
                <div class="col-md-3">
                    <label for="shop_name" class="form-label">Shop Name</label>
                    <input type="text" name="shop_name" id="shop_name" class="form-control" value="{{ old('shop_name', $customer->shop_name ?? '') }}">
                </div>
                <div class="col-md-3">
                    <label for="phone" class="form-label">Phone</label>
                    <input type="text" name="phone" id="phone" class="form-control" value="{{ old('phone', $customer->phone ?? '') }}">
                </div>
                <div class="col-md-3">
                    <label for="address" class="form-label">Address</label>
                    <input type="text" name="address" id="address" class="form-control" value="{{ old('address', $customer->address ?? '') }}">
                </div>
            </div>
            <div class="mt-3">
                <button type="submit" class="btn btn-primary">{{ isset($customer) ? 'Update' : 'Save' }}</button>
                <a href="{{ route('customers.index') }}" class="btn btn-secondary">Cancel</a>
            </div>
        </form>
    </div>
</div>
@endsection
