Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

393
Views
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 answers
Answer question

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 Report

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!