@extends('admin.layouts.app')
@section('title', 'Categories')


@section('content')
<div class="form-container">
    <form action="{{ route('admin.category.update', $category->id) }}" method="POST" enctype="multipart/form-data">
        @csrf
        <div class="form-group">
            <label for="name">Name</label>
            <input type="text" id="name" name="name" placeholder="Category Name" class="form-control @error('name') is-invalid @enderror" value="{{ old('name', $category->name) }}" >
            @error('name')
                <span class="invalid-feedback" role="alert">
                    <strong>{{ $message }}</strong>
                </span>
            @enderror
        </div>

        <div class="form-group">
            <label for="description">Category Description</label>
            <textarea id="description" name="description" rows="5" placeholder="Category Description" class="form-control @error('description') is-invalid @enderror" >{{ old('description', $category->description) }}</textarea>
            @error('description')
                <span class="invalid-feedback" role="alert">
                    <strong>{{ $message }}</strong>
                </span>
            @enderror
        </div>
        
        <div class="form-group">
            <label for="image_url">Category Image</label>
            <input type="file" id="image_url" name="image_url" class="dropify @error('image_url') is-invalid @enderror" data-max-file-size="2M" data-allowed-file-extensions="jpeg png jpg gif">
            @if($category->image)
                <small class="form-text text-muted">Current image:</small><br>
                <img src="{{ asset($category->image) }}" alt="Current Product Image" class="mt-2 rounded" style="width: 150px; height: 150px; object-fit: cover;">
            @endif
            @error('image_url')
                <span class="invalid-feedback" role="alert">
                    <strong>{{ $message }}</strong>
                </span>
            @enderror
        </div>

        <button type="submit" class="btn btn-success"><i class="fas fa-plus-circle"></i> Submit</button>
    </form>
</div>
@endsection

