
<div class="m-b-md">
  	<a href="<?php echo e(route('group.create')); ?>" id="btn-user-add" class="btn btn-success btn-sm pull-right"><i class="fa fa-plus"></i> Add Group</a>
  	<h3 class="m-b-none">Assign Groups</h3>
  	
</div>

<?php echo e(Helper::bootstrap_alert()); ?>


<section class="panel panel-default">
	<div class="table-responsive">
		<table class="table table-striped">
	      <thead>
	        <tr>
	          <th>#</th>
	          <th>Route Name</th>
	          <th>Route Path</th>
	          <?php foreach($groups as $key => $group): ?>
	          <th class="text-center">
	          	<?php echo e($group->name); ?>

	          </th>
	          <?php endforeach; ?>
	        </tr>
	      </thead>
	      <tbody>
	      	<?php $k = 1; ?>
	      	<?php foreach($routes as $route): ?>
	      		<?php if(substr($route->getName(),0,1) !== '_' && substr($route->getPath(),0,1) !== '_'): ?>
		        <tr>
		          <th scope="row"><?php echo e($k++); ?></th>
		          <td>
		          	<?php echo e($route->getName()); ?>

		          </td>
		          <td>
		          	<?php echo e($route->getPath()); ?>

		          </td>
		          <?php foreach($groups as $group): ?>
		          <td class="pillbox text-center">
			          <label>
			          	<?php if(in_array($route->getName(), $permits[$group->name])): ?>
		                	<?php echo Html::decode(Html::link(route('group.assign.post', strtolower($group->name).'_'.$route->getName().'_pop'), '<i class="fa fa-check fa-fw"></i>', array('class' => 'btn btn-xs btn-primary', 'data-method' => 'POST', 'data-token' => csrf_token(), 'name' => $route->getName()))); ?>

	                    <?php else: ?>
	                    	<?php echo Html::decode(Html::link(route('group.assign.post', strtolower($group->name).'_'.$route->getName().'_push'), '<i class="fa fa-times fa-fw"></i>', array('class' => 'btn btn-xs btn-danger', 'data-method' => 'POST', 'data-token' => csrf_token(), 'name' => $route->getName()))); ?>

	                    <?php endif; ?>
	                  </label>
		          </td>
		          <?php endforeach; ?>
		        </tr>
		        <?php endif; ?>
	        <?php endforeach; ?>
	        	<tr>
	        	<td></td>
	        	<td></td>
	        	<td></td>
	        	<?php foreach($groups as $group): ?>
	        	<td class="text-center">
	        		<?php if($group->name != 'Administrator'): ?>
	        		<?php echo Html::decode(Html::link(route('group.delete', $group->id), '<i class="fa fa-trash fa-fw"></i>', array('class' => 'btn btn-xs btn-default btn-user-edit', 'data-method' => 'delete', 'data-confirm' => 'Are you sure want to delete this group?', 'data-token' => csrf_token()))); ?>

	        		<?php endif; ?>
	        	</td>
	        	<?php endforeach; ?>
	        	</tr>
	      </tbody>
	    </table>
	</div>
</section>