@extends('layouts.admin')

@section('title')

  Utenti

@stop

@section('content')

	   <div class="row">
        <div class="col-xs-12">
          <div class="box">

            <div class="box-body table-responsive no-padding">
              <table class="table table-striped table-hover">
                <tr>
                  <th>Nome</th>
                  <th class="hidden-xs">Email</th>
                  @if(Auth::user()->is_admin)
                    <th>Admin</th>
                    <th>Livello</th>
                  @endif
                  <th width="200" align="right"></th>
                </tr>
                @foreach($users as $user)
                	<tr>
                    <td>{{$user->name}}</td>
                    <td class="hidden-xs">{{$user->email}}</td>
                    @if(Auth::user()->is_admin)
                      <td>{{$user->is_admin ? 'Si' : 'No'}}</td>
                      <td>{{$user->level}}</td>
                    @endif
                    <td>
                        <form action="{{ route('users.destroy',$user->id) }}" method="POST">         
                            <a href="{{ route('users.edit', $user->id) }}" type="button" class="btn btn-w-m btn-primary"><i class="fa fa-pencil-square-o" aria-hidden="true"></i></a>
                            @csrf
                            @method('DELETE')
                            <button type="submit" class="btn btn-danger" onclick="return confirm('Sei sicuro?')"><i class="fa fa-trash" aria-hidden="true"></i></button>
                        </form>
                    </td>
                	</tr>
                @endforeach
              </table>
            </div>

          </div>

        </div>
        <div class="col-xs-2">
            @if(Auth::user()->only_read == false)
              <a href="{{ route('users.create') }}" class="btn btn-success">Aggiungi</a>
            @endif
        </div>
        
      </div>




@stop
