@extends('layouts.admin.app')

@section('content')
    <div class="card">

        <h5 class="card-header">
            <a href="{{ url('admin/categories') }}" class="btn rounded-pill btn-label-primary">
                <i class="ti me-2 ti-arrow-forward-up"></i> {{ __('trans.category.title') }}
            </a>
            @yield('title')
        </h5>

        <div class="card-body">

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

                <div class="row">

                    <div class="col-md-6 mb-3">
                        <label class="form-label">{{ __('trans.category.name') }} <b class="text-danger">*</b></label>
                        <input type="text" class="form-control" required name="name"
                            value="{{ old('name', $category->name) }}" placeholder="{{ __('trans.category.name') }}" />
                    </div>


                    <div class="col-md-6 mb-3">
                        <label class="form-label">{{ __('trans.category.display_order') }} <b
                                class="text-danger">*</b></label>
                        <input type="number" class="form-control" required name="display_order"
                            value="{{ old('display_order', $category->display_order) }}"
                            placeholder="{{ __('trans.category.display_order') }}" />
                    </div>


                    <div class="col-md-12 mb-3">
                        <div class="input-group">
                            <label>{{ __('trans.category.img') }}</label>

                            <div class="input-group">
                                <span class="input-group-btn">
                                    <a id="lfm" data-input="thumbnail" data-preview="holder"
                                        class="UploadFile btn btn-primary">
                                        <i class="fa fa-picture-o"></i> {{ __('trans.choose') }}
                                    </a>
                                </span>
                                <input id="thumbnail" class="form-control" type="text" name="img"
                                    value="{{ old('img', $category->img) }}" readonly/>
                            </div>
                        </div>

                        <div id="holder" style="margin-top:15px;max-height:100px;">
                            @if (!empty(old('img', $category->img)))
                                <img src="{{ old('img', $category->img) }}" style="height: 5rem;">
                            @endif
                        </div>
                    </div>


                    <div class="row">
                        <div class="col-md-12">
                            <button class="btn btn-primary btn-create w-100">{{ __('trans.save') }}</button>
                        </div>
                    </div>
                </div>
            </form>
        </div>
    </div>
@endsection
