<?php $__env->startSection('title','Admin | SubAdmins '); ?>
<?php $__env->startSection('content'); ?>
<div class="loader"></div>
<div id="app">
    <div class="main-wrapper main-wrapper-1">
        <?php echo $__env->make('layouts.navbar', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
        <!-- Main Content -->
        <div class="main-content">
            <section class="section">
                <div class="row">
                    <div class="col-12">
                        <?php if(session('success')): ?>
                        <div class="alert alert-success">
                            <?php echo e(session('success')); ?>

                        </div>
                        <?php endif; ?>
                        <div class="card">
                            <div class="card-header">
                                <h4>Sub Admins</h4>
                                <div class="card-header-form">
                                    <div class="input-group">
                                        <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('create-markets')): ?>
                                        <div class="ml-5 form-group">
                                            <a href="<?php echo e(route('sub-admins.create')); ?>" class="btn btn-outline-primary">Create</a>
                                        </div>
                                        <?php endif; ?>
                                    </div>
                                </div>
                            </div>
                            <div class="card-body p-2">
                                <div class="table-responsive">
                                    <table data-searching="false" data-paging="false" data-info="false" data-order='[[ 0, "desc" ]]' id="myTable" class="table table-striped">
                                        <thead>
                                            <tr>
                                                <th>ID</th>
                                                <th>Name</th>
                                                <th>Phone</th>
                                                <th>Bocked</th>
                                                <th>Permissions</th>
                                                <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('sub-admins.toogle-blocked.change')): ?>
                                                <th>Action</th>
                                                <?php endif; ?>
                                                <th>Created At</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <?php $__currentLoopData = $subAdmins; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $user): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                                            <tr>
                                                <td><?php echo e($user->id); ?></td>
                                                <td><?php echo e($user->name); ?></td>
                                                <td><?php echo e($user->phone); ?></td>
                                                <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('sub-admins.toogle-blocked.change')): ?>
                                                <td>
                                                    <div class="mt-3">
                                                        <div class="selectgroup ">
                                                            <label class="selectgroup-item">
                                                                <input type="radio" value="1" name="blocked<?php echo e($user->id); ?>" class="selectgroup-input-radio" <?php if($user->blocked == 1): ?> checked <?php endif; ?>
                                                                onchange="toogleBlock(<?php echo e($user->id); ?>,1)">
                                                                <span class="selectgroup-button">Blocked </span>
                                                            </label>
                                                            <label class="selectgroup-item">
                                                                <input type="radio" name="blocked<?php echo e($user->id); ?>" value="0" class="selectgroup-input-radio" <?php if($user->blocked == 0): ?> checked <?php endif; ?>
                                                                onchange="toogleBlock(<?php echo e($user->id); ?>,0)">
                                                                <span class="selectgroup-button">Unblock</span>
                                                            </label>
                                                        </div>
                                                    </div>
                                                </td>
                                                <?php endif; ?>
                                                <td><a class="btn btn-primary" href="<?php echo e(route('sub-admins.edit-permissions', ['id' => $user->id])); ?>">Edit
                                                    </a></td>
                                                <td><a href="<?php echo e(route('sub-admins.edit', ['id' => $user->id])); ?>" class="btn btn-outline-primary">Edit</a>|<a href="<?php echo e(route('sub-admins.delete', ['id' => $user->id])); ?>" class="btn btn-outline-primary">Delete</a>
                                                </td>
                                                <td><?php echo e($user->created_at); ?></td>
                                            </tr>
                                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </div>
</div>
<script>
    function toogleBlock(id, block) {
        $.ajax({
            url: "<?php echo e(route('sub-admins.toogle-blocked.change')); ?>",
            type: "POST",
            data: {
                user_id: id,
                blocked: block
            },
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]')
                    .attr('content')
            },
        })
    }
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/shyambabamatka/public_html/alpha786.com/resources/views/dashboard/sub-admins/index.blade.php ENDPATH**/ ?>