@extends('usuarios.funcionarios.master.layout2')
@extends('usuarios.funcionarios.admin.menu')
@extends('usuarios.funcionarios.admin.dispositivos.menu')

@section('conteudo')
<br>
<nav class="" style="--bs-breadcrumb-divider: url(&#34;data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8'%3E%3Cpath d='M2.5 0L1 1.5 3.5 4 1 6.5 2.5 8l4-4-4-4z' fill='currentColor'/%3E%3C/svg%3E&#34;);" aria-label="breadcrumb">

    <ol class="breadcrumb justify-content-end">
        <li class="breadcrumb-item"> <a href=""> Usuário</a> </li>
        <li class="breadcrumb-item "  ><a href=""> Administrador</a></li>
        <li class="breadcrumb-item " ><a href=""> Dispositivos</a></li>
        <li class="breadcrumb-item active" aria-current="page">Usuários</li>
    </ol>
</nav>
<main class="col-12  p-4   ">
    <nav class="d-none">
        {{-- {{ $usuarios= App\Models\User::join('acessos','users.id','=','acessos.user_id')->select('users.*','acessos.*')->distinct('users.id')->get() }} --}}
        {{ $acessos=App\Models\Acesso::select('user_id')->distinct()->get() }}
        {{ $i=1 }}
    </nav>
    <h4>Acessos</h4> <br>
    <hr>
    <br>
    <div class="table-responsive">
      <table class="table table-hover table-striped table-sm">
        <thead>
          <tr>
            <th>#</th>
            <th>Usuário</th>
            <th>Dispositivos</th>
            <th>Acessos</th>
            <th>Visualizar</th>

          </tr>
        </thead>
        <tbody>

            @foreach($acessos as $as)

            <tr>
                <td>{{ $i++ }}</td>

                <td>
                    <div class="d-none">
                        {{ $us=$as->getUser }}
                        {{ $devs= $us->getDevices }}
                        {{ $devCount=0 }}
                        @foreach($devs as $dev)
                            {{ $devCount++ }}
                        @endforeach
                    </div>
                    {{ $us->getPessoa->nome }} <br>
                    <small>{{ $us->email }}</small>
                </td>
                <td>{{ $devCount }}</td>
                <td>


                </td>
                <td><a href="{{ route('us.admin.funcionario.disp',$us->id ) }}" class="btn btn-sm btn-outline-success"> <i class="fa fa-eye"></i> Ver mais</a></td>
            </tr>
            @endforeach


        </tbody>
      </table>
    </div>
  </main>

@endsection
