

<?php $__env->startSection('content'); ?>
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card">
                <div class="card-header">Users</div>

                <div class="card-body">
                    <form action="/find" method="POST" role="search">
                        <?php echo e(csrf_field()); ?>

                        <div class="input-group">
                            <input type="text" class="form-control" name="q"                              
                                placeholder="Search users"><span class="input-group-btn">
                            </span>
                            <button type="submit" class="btn btn-default">
                                <span class="glyphicon glyphicon-search">Search</span>
                            </button>
                        </div>
                        <label class="checkbox-inline">
                            <input type="checkbox" name="roles[]" value="root"> Root 
                        </label>
                        <label class="checkbox-inline">
                            <input type="checkbox" name="roles[]" value="admin"> Admin 
                        </label>
                        <label class="checkbox-inline">
                            <input type="checkbox" name="roles[]" value="user"> User 
                        </label>
                    </form>
                    <table class="table">
                        <thead>
                          <tr>
                            <th scope="col">ID</th>
                            <th scope="col">Name</th>
                            <th scope="col">Surname</th>
                            <th scope="col">Email</th>
                            <th scope="col">Role</th>
                            <th scope="col">Action</th>
                          </tr>
                        </thead>
                        <tbody>
                        <?php $__empty_1 = true; $__currentLoopData = $users; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $user): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                            <tr>
                                <td><?php echo e($user->id); ?></td>
                                <td><?php echo e($user->name); ?></td>
                                <td><?php echo e($user->surname); ?></td>                                 
                                <td><?php echo e($user->email); ?></td>  
                                <td><?php echo e(implode(',',$user->roles()->get()->pluck('name')->toArray())); ?></td>
                                <td>
                                <?php if(in_array('admin',$user->roles()->get()->pluck('name')->toArray())): ?>
                                    <?php if(!in_array('root',$user->roles()->get()->pluck('name')->toArray())): ?>
                                        <form action="/users/<?php echo e($user->id); ?>/demote" method="GET">
                                            <?php echo csrf_field(); ?>
                                            <button type="submit" class="btn btn-secondary float-left">Demote</button>
                                        </form>
                                    <?php endif; ?>
                                <?php else: ?>
                                    <form action="/users/<?php echo e($user->id); ?>/promote" method="GET">
                                        <?php echo csrf_field(); ?>
                                        <button type="submit" class="btn btn-primary float-left">Promote</button>
                                    </form>
                                <?php endif; ?>    
                            </td>                                                                         
                            </tr>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                            <tr>
                                <td>No Users available</td>                                
                            </tr>
                        <?php endif; ?>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\xampp\htdocs\virtual\resources\views/users/index.blade.php ENDPATH**/ ?>