@extends('layouts.app')

@section('title', 'Edit Category')

@section('content')

<div class="card">
    <div class="card-header">
        <h4 class="card-title">Edit Category</h4>
    </div>

    <div class="card-body">

        <form action="{{ route('categories.update', $category->category_id) }}" method="POST">
            @csrf
            @method('PUT')

            <div class="row">

                <div class="col-md-12">
                    <div class="form-group">
                        <label>Category Name *</label>

                        <input
                            type="text"
                            name="category_name"
                            class="form-control"
                            placeholder="Enter Category Name"
                            value="{{ old('category_name', $category->category_name) }}"
                            required
                        >

                        @error('category_name')
                            <small class="text-danger">{{ $message }}</small>
                        @enderror
                    </div>
                </div>

                <div class="col-md-12">
                    <div class="form-group">
                        <label>Description</label>

                        <textarea
                            name="description"
                            class="form-control"
                            rows="4"
                            placeholder="Enter Category Description"
                        >{{ old('description', $category->description) }}</textarea>

                        @error('description')
                            <small class="text-danger">{{ $message }}</small>
                        @enderror
                    </div>
                </div>

            </div>

            <button type="submit" class="btn btn-primary mr-2">
                Update Category
            </button>

            <a href="{{ route('categories.list') }}" class="btn btn-danger">
                Cancel
            </a>

        </form>

    </div>
</div>

@endsection