Old status update To New status
There is a form in which I have a status field and I want it to be saved and update in database for update my code is
But when I run it it keep changing my form updated_at which I dont want. I just want status_update to be changed when user change it.
10 Replies
if you use the default timestamps from laravel then this is always the case .. you have to modify your model
How to disable model timestamps in Laravel?
laravel timestamp false, laravel timestamps disable, laravel disable timestamps, laravel model timestamps false, laravel eloquent timestamps false
@mvenghaus but then it would not change updated_at which I want to change but not when I change status type
my point is if user change status it should give update .. it should not affect updated_at ....
update_at would only get affectecd or change when user change something else on the form
If they change the status though the record is getting updated which is why updated_at is getting changed. It’s kind of the entire point of the updated_at field.
you could also update without the model, db query
Yes , I know updated_at is like for full form if user change its gonna update, but I want status_update seperatly which only will update when user change just status nothing else
And when status_update is gonna update I dont want update_at to be update @awcodes
Then you’ll probably need an observer to get the old value and reset it with the old value during saving.
Still doesn’t make sense because the record is changing is the status changes, but it’s your app. 😀
something like this ?
Yea. But my point was getting the old value for updated_at and manually setting it as part of the form data so it gets “updated” with the old value instead of getting set to the current time.
sorry did not catch ya