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

130
Visualizações
Object property with the value of null is being treated as ''

I have a set of code where I retrieve data from the database using eloquent

Controller

       $display_tickets = ManualTicket::select('*')
            ->with('user')
            ->with('initiator')
            ->with('manual_ticket_log')
            ->where(function ($checkClients) use($target_client_id){
                $checkClients->whereHas('user', function ($checkClient) use($target_client_id){
                    $checkClient->where('client_id', '=', $target_client_id);
                })
                ->orWhereHas('initiator', function ($checkClient2) use($target_client_id){
                    $checkClient2->where('client_id', '=', $target_client_id);
                });
            })
            ->whereBetween('manual_tickets.created_at', [$start_date->toDateString(), $end_date->addDays(1)->toDateString()])
            ->orderBy("manual_tickets.created_at", "desc")->get();

The variable is then returned to the blade file

  return view('ticket-dashboard/dashboard', compact('display_tickets'));

On the blade file, for each ticket that I receive I am displaying them in a table. However, when the property $display_tickets['ticket_flow_id'] is null, it is being regarded as ' ' on the blade file when it actually holds the value of null. Why is that???

@foreach($display_tickets as $p)
<table>
<th> ticket flow id </th>
<tr>
<td>
        <script type="application/javascript">
                console.log('{{$p['ticket_flow_id']}}');
                var typee = '{{$p['ticket_flow_id']}}';
                console.log(typeof typee);
         </script>
</td>

enter image description here

Controller code

 error_log(json_encode($display_tickets));
 error_log("??salkag");
 error_log(json_encode($display_tickets->ticket_flow_id));
 error_log(gettype($display_tickets->ticket_flow_id));

enter image description here

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

0

Long shot but have you tried this :

{!! $p['ticket_flow_id'] !!}

By default {{}} passes the string through PHPs htmlspecialchars you might get your expected result although opens it up to XSS

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