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

398
Visualizações
Laravel update not returning data

My Laravel update operation returns true for dd($data). But I want it to return the updated data. How can I change this to get that output? There is one condition I have that the update should be called directly on the model. Any suggestions?

$data = FileLogs::find($id)->update([
            'orderId' => $request->orderId, 
            'fileId' => $request->fileId, 
            'status' => $request->status
]);
over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

Try this

 $data = tap(FileLogs::find($id))
    ->update(['orderId' => $request->orderId, 'fileId' => $request->fileId, 'status' => $request->status])
    ->first();
 dd($data);
over 4 years ago · Santiago Trujillo Relatório

0

First, update the data then fetch it again

$data=FileLogs::find($id)->update(['orderId'=>$request->orderId,'fileId'=>$request->fileId,'status'=>$request->status]);

$updated_data=FileLogs::find($id);

dd($updated_data);
over 4 years ago · Santiago Trujillo Relatório

0

First find the data and then you can update it and get it like this

$data = FileLogs::find($id);

Now update like this

$data->update(['orderId'=>$request->orderId,'fileId'=>$request->fileId,'status'=>$request->status]);

Now you can do whatever with the data

dd($data);
over 4 years ago · Santiago Trujillo 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