Level 75
Mar 17, 2021
3
Level 10
Returning a model after update still shows old values
Hi, When I update a record and then try to return the values right away I am seeing that it is the old record.
public function update(Request $request, Price $price)
{
$material = $price->material->prices->filter(function ($value) use ($price) {
return $value->id >= $price->id;
});
$prices = $material->pluck('id');
Price::whereIn('id', $prices)->update([
'price' => $request->price
]);
return $price->material->prices;
}
it returns my old prices. However when I then reload the page it has the latest prices. Do I need to tell laravel to wait until the record is updated before doing?
return $price->material->prices;
Please or to participate in this conversation.