<?php $__env->startSection('title', 'Member'); ?>
<?php $__env->startPush('css'); ?>
    <link rel="stylesheet" href="<?php echo e(asset('/assets/css/datepicker.css')); ?>"/>
    <style>
        .is-invalid {
            border-color: var(--color-primary) !important;
        }
    </style>
<?php $__env->stopPush(); ?>
<?php $__env->startSection('content'); ?>
    <div class="content">
        <div class="container-fluid">
            <div class="row">
                <div class="">
                    <h4 class="mb-1">Create Menu Grp</h4>
                    <nav style="--bs-breadcrumb-divider: '|';"  aria-label="breadcrumb" >
                        <ol class="breadcrumb m-0">
                            <li class="breadcrumb-item"><a href="<?php echo e(route('menugrp.index')); ?>" class="text-primary">Menu Grp</a></li>
                            <li class="breadcrumb-item active" aria-current="page">Create</li>
                        </ol>
                    </nav>
                </div>
            </div>

            <div class="row">
                <div class="mt-4">
                    <div class="col-8">
                        <div class="card myCard form-main-div">
                            <form id="userForm">
                            <div class="row g-3">
                                <div class="col-lg-12">
                                    <?php echo csrf_field(); ?>
                                    <input type="hidden" name="id" value="<?php echo e($user->id ?? ''); ?>">
                                    <label for="name">Name<span class="required-sign ">*</span></label>
                                    <input type="text" class="form-control" id="name" name="name" value="<?php echo e($user->menu_grp_name ?? ''); ?>" placeholder="Name" >
                                </div>
                                <div class="col-lg-12">
                                    <label for="name">Menus<span class="required-sign ">*</span></label>
                                    <?php $__currentLoopData = getMenu(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $menu): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                        <div class="col-md-4 mb-2">
                                            <div class="form-check">
                                                <input
                                                    type="checkbox"
                                                    class="form-check-input"
                                                    id="menu_<?php echo e($menu->id); ?>"
                                                    name="menus[]"
                                                    value="<?php echo e($menu->id); ?>"
                                                    
                                                    <?php if(!empty($userMenus) && in_array($menu->id, $userMenus)): ?> checked <?php endif; ?>
                                                >
                                                <label class="form-check-label" for="menu_<?php echo e($menu->id); ?>">
                                                    <?php echo e($menu->label); ?>

                                                </label>
                                            </div>
                                        </div>
                                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                </div>
                                <div class="col-lg-12">
                                    <label for="name">Status<span class="required-sign ">*</span></label>
                                    <select name="status" class="form-select" id="status">
                                        <?php $__currentLoopData = config('constant.NON_STATUS'); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $val): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <option value="<?php echo e($key); ?>" <?php echo e(isset($user) && $user->status == $key ? 'selected' :''); ?>><?php echo e($val); ?></option>
                                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                    </select>
                                </div>
                                <div class="mt-4">
                                    <div>
                                        <button class="btn btn-secondary px-4">Save</button>
                                    </div>
                                </div>
                            </div>
                        </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <?php $__env->startPush('scripts'); ?>
        <script>
            $(document).ready(function() {

                $('#userForm').on('submit', function(e) {
                    e.preventDefault();

                    let formData = new FormData(this);
                    let id = $('input[name="id"]').val();
                    let url = id ? "<?php echo e(route('menugrp.update', ':id')); ?>".replace(':id', id) : "<?php echo e(route('menugrp.store')); ?>";

                    $.ajax({
                        url: url,
                        method: 'POST',
                        data: formData,
                        processData: false,
                        contentType: false,
                        success: function(response) {
                            notification('success',response.message,'success',2000)
                            if (!id) $('#userForm')[0].reset(); // clear form on create
                        },
                        error: function(xhr) {
                            let msg = 'Something went wrong.';
                            if (xhr.responseJSON && xhr.responseJSON.message) {
                                msg = xhr.responseJSON.message;
                            }
                            notification('error',msg,'danger',2000)
                        }
                    });
                });
            });
        </script>
    <?php $__env->stopPush(); ?>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.admin.master', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/educatio/public_html/nari.hosteldesk.in/resources/views/admin/role.blade.php ENDPATH**/ ?>