Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

400
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda