-1
I created a list of Extensions through PHP and Laravel 5.5 and I’m having difficulty displaying the query data $users
in the view why I can’t properly traverse the fields with Foreach
What’s wrong with my code? How do I go through the fields telephonenumber, samaccountname, l, with foreach?
Below the code
public function index()
{
// realizando a consulta para exibir as informações na pagina principal do site
// Logo
$logo = $this->logo->first();
// Seo
$seo = $this->seo->first();
// realizando a consulta pela OU com ldap search
$ou = $this->ldap->search()->ous()->find('AD');
// Realizando um filtro para trazer somente usuários ativos da ou AD e com telefone preenchido
$users = $this->ldap->search()->users()->select('l','city','samaccountname', 'telephonenumber', 'departament')->in($ou)
->whereEnabled()
->where('telephonenumber', true)
->get();
return view('site.home.index', compact('logo', 'seo', 'users'));
}
The above Code returns the data in this way. dd($users)
Foreach code in view.
<div class="panel-body">
<!-- Div responsavel por alinhar as linhas -->
<div class="row-fluid">
<thead>
<tr>
<th class="text-center"><a href="">Usuario:</a></th>
<th class="text-center"><a href="">Ramal:</a></th>
<th class="text-center"><a href="">Departamento:</a></th>
<th class=""><a href="">Local:</a></th>
</tr>
</thead>
@forelse($users as $key =>$dados_users)
<tbody>
<tr>
@foreach($dados_users['samaccountname'] as $key =>$samaccountname)
{{-- Repassando o conteudo dos campos --}}
<td class="text-center">$samaccountname</td>
@endforeach
@foreach($dados_users['telephonenumber'] as $key =>$telephonenumber)
{{-- Repassando o conteudo dos campos --}}
<td class="text-center">$telephonenumber</td>
@endforeach
@foreach($dados_users['departament'] as $key =>$departament)
{{-- Repassando o conteudo dos campos --}}
<td class="text-center">$telephonenumber</td>
@endforeach
{{-- Se for Vazio... --}}
@empty
<h4 class="text-center"> Nenhum Registro Cadastrado!</h4>
@endforelse
@endif
</tr>
</tbody>
</table>
<!-- fim sm- 12 -->
{{ }}
@endsection
What is the correct way to go through the View data of this array with Foreach?