@extends('Admin.layout.app')

@section('title', 'Add Menu')

@section('page-title', 'Add Menu')

@section('content')


<div class="container-fluid">

    <div class="card shadow-sm">
        <div class="card-header d-flex justify-content-between align-items-center">
            <h4 class="mb-0">Add New Menu</h4>

            <a href="{{ route('admin.setting.products') }}" class="btn btn-secondary">
                <i class="fas fa-arrow-left"></i> Back
            </a>
        </div>

        <div class="card-body">

            <form action="{{ route('admin.product.store') }}" method="POST" enctype="multipart/form-data">
                @csrf

                <div class="row">

                    <!-- Image -->
                    <div class="col-md-6 mb-3">
                        <label class="form-label">Menu Image <span class="text-danger">*</span></label>

                        <input type="file"
                               name="image"
                               class="form-control @error('image') is-invalid @enderror"
                               accept="image/*">

                        @error('image')
                            <div class="invalid-feedback">{{ $message }}</div>
                        @enderror
                    </div>

                    <!-- Title -->
                    <div class="col-md-6 mb-3">
                        <label class="form-label">Title <span class="text-danger">*</span></label>

                        <input type="text"
                               name="title"
                               class="form-control @error('title') is-invalid @enderror"
                               value="{{ old('title') }}"
                               placeholder="Enter menu title">

                        @error('title')
                            <div class="invalid-feedback">{{ $message }}</div>
                        @enderror
                    </div>

                    <!-- Status -->
                    <div class="col-md-6 mb-3">
                        <label class="form-label">Status <span class="text-danger">*</span></label>

                        <select name="status"
                                class="form-select @error('status') is-invalid @enderror">
                            <option value="">Select Status</option>
                            <option value="1" {{ old('status') == '1' ? 'selected' : '' }}>
                                Active
                            </option>
                            <option value="0" {{ old('status') == '0' ? 'selected' : '' }}>
                                Inactive
                            </option>
                        </select>

                        @error('status')
                            <div class="invalid-feedback">{{ $message }}</div>
                        @enderror
                    </div>
                    
                     <div class="col-md-6 mb-3">
                            <label class="form-label d-block">Popular</label>
                        
                            <div class="form-check form-switch">
                                <input class="form-check-input"
                                       type="checkbox"
                                       role="switch"
                                       id="popular"
                                       name="popular"
                                       value="1"
                                       >
                        
                                <label class="form-check-label" for="popular">
                                    Mark as Popular
                                </label>
                            </div>
                        
                            @error('popular')
                                <div class="text-danger small">{{ $message }}</div>
                            @enderror
                        </div>
                    
                    <div class="col-md-12 mb-3">
                           <label class="form-label">Description <span class="text-danger">*</span></label>
                       
                           <textarea name="description"
                                     id="description"
                                     rows="8"
                                     class="form-control @error('description') is-invalid @enderror"></textarea>
                       
                           @error('description')
                               <div class="invalid-feedback">{{ $message }}</div>
                           @enderror
                     </div>

                </div>

                <div class="mt-3">
                    <button type="submit" class="btn btn-success">
                        <i class="fas fa-save"></i> Save Product
                    </button>

                    <a href="{{ route('admin.setting.products') }}" class="btn btn-secondary">
                        Cancel
                    </a>
                </div>

            </form>

        </div>
    </div>

</div>


@endsection


@push('js')
<script src="https://cdn.ckeditor.com/ckeditor5/41.4.2/classic/ckeditor.js"></script>

<script>
ClassicEditor
    .create(document.querySelector('#description'))
    .catch(error => {
        console.error(error);
    });
</script>
@endpush