Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

108
Visualizações
take user id in all views with laravel

first sorry for my english cuz im from spain. ok the problem is when i try to get the user in all views with appserviceprovider, this is my code

    public function boot() {
   $comprador =Auth::user();

    View::share('comprador', $comprador);}

and next i try to get the item in other view and the result is null

   <div class="col-6 ">
{{dd($comprador)}}
    </div>

and this is the final result enter image description here

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You dont need to declare any variables you have the auth global helper that you can use anywhere. The code in your blade looks like this.

<div class="col-6 ">
  {{ auth()->user() }}
</div>

if you need lets say the name of the user its just auth()->user()->name etc.

about 4 years ago · Juan Pablo Isaza Relatório

0

    
    
    
    
    
    userlistviewpage.php
    
    <table class="table table-hover">

    <thead>

      <th>Username</th>

      <th>Orders</th>

      <th>Balance</th>

    </thead>

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

        <tr>

          <td>{{$user->username}} </td>

          <td>{{$user->purchases}} </td>

          <td>{{$user->balance}} </td>


        </tr>
@endforeach

    </tbody>

</table>

    Controller.php:

    public function boot() {
       $comprador = User::all();

        return view('profile.userlistviewpage', compact('users'));
        
        }

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda