Are you sure you are actually getting a DeliveryTime record with your where condition? Try firstOrFail() to check?
$deliveryTime = DeliveryTime::where('key','=',$key)->firstOrFail();
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello everyone,
I have a strange problem. I'm trying to update a database entry with the save function, but the changed columns won't change. I don't get any errors.
This is the code in my update function:
$deliveryTime = DeliveryTime::where('key','=',$key)->first();
$deliveryTime->name = $request->name;
$deliveryTime->short_name = $request->short_name;
$deliveryTime->color = $request->color;
$deliveryTime->save();
return redirect()->action('DeliveryTimeController@edit',$deliveryTime->key)->with(['success' => 'Delivery time updated.']);
When I print the variables p.ex. $request->name I get the correct value. When I print the $deliveryTime->name after I changed it, I get the correct value too.
It looks like the save() doesn't execute. The redirect is executed.
I used this way for updating entries in my database a lot and until now I never had any problems and I don't get where the problem is.
Maybe someone has an idea?
Best, Verdemis
I reworked the whole script and now it works, but I still don't have a clou what exactly was the problem. But now it works and I can go on. Thanks to everyone who tried to help :)
Please or to participate in this conversation.