@extends('layouts.default')
@extends('content_wrappers.md-10')

@section('title', '| Users')
@section('heading', 'User Administration')

@section('content')
  <div class="table-responsive">
    <table class="table table-bordered table-striped">
      <thead>
        <tr>
          <th>Name</th>
          <th>Email</th>
          <th>Date/Time Added</th>
          <th>Operations</th>
        </tr>
      </thead>

      <tbody>
        @foreach ($users as $user)
        <tr>

          <td>{{ $user->name }}</td>
          <td>{{ $user->email }}</td>
          <td>{{ $user->created_at->format('F d, Y h:ia') }}</td>
          <td>
          @if(in_array('EditUser',$allperms))
            <a href="{{ route('users.edit', $user->id) }}" class="btn btn-info pull-left" style="margin-right: 3px;">Edit</a>
          @endif

          @if(in_array('DeleteUser',$allperms))
            {!! Form::open(['method' => 'DELETE', 'route' => ['users.destroy', $user->id] ]) !!}
            {!! Form::submit('Delete', ['class' => 'btn btn-danger']) !!}
            {!! Form::close() !!}
          @endif
          </td>
        </tr>
        @endforeach
      </tbody>

    </table>
  </div>
  @if(in_array('CreateUser',$allperms))
    <a href="{{ route('users.create') }}" class="btn btn-success">Add User</a>
  @endif
@endsection