@extends('layouts.app')
@section('title', isset($category) ? 'Edit Category' : 'Add Category')
@section('content')
<h4 class="mb-3">{{ isset($category) ? 'Edit Category' : 'Add Category' }}</h4>
<div class="card">
    <div class="card-body">
        <form action="{{ isset($category) ? route('categories.update', $category) : route('categories.store') }}" method="POST">
            @csrf
            @if(isset($category)) @method('PUT') @endif
            <div class="row g-3">
                <div class="col-md-6">
                    <label for="name" class="form-label">Category Name</label>
                    <input type="text" name="name" id="name" class="form-control" value="{{ old('name', $category->name ?? '') }}" required placeholder="e.g. Flour, Chowker, Khal, Maida">
                </div>
            </div>
            <div class="mt-3">
                <button type="submit" class="btn btn-primary">{{ isset($category) ? 'Update' : 'Save' }}</button>
                <a href="{{ route('categories.index') }}" class="btn btn-secondary">Cancel</a>
            </div>
        </form>
    </div>
</div>
@endsection
