Good morning,
What I can think of is that you can do one of these three things:
At the moment of displaying the data compare if created_at
and updated_at
are equal, and in that case do not show updated_at
(or make a function / method in the model that does this)
Make a migration to add a boolean type column edited
that by default is false
and once the model is edited in addition to saving the changes it is verified if edited
is false
, in which case it is changed to true
.
Then, when displaying the data, if edited
is true
show column udated_at
Make a migration to add a column of type datetime last_update
that by default is null
and once the model is edited (like the previous method) give it the current time value, then use the column to show the time.
For methods 2 and 3 the change of edited
or last_update
you can do it in different ways:
Make the change when you update the model, either in the controller's method or wherever you do it.
Observe the event updated
or updating
of the model, either outside or without of the model .
I hope this answers your question and that you have explained me well, any questions you tell me and I will try to clarify myself better or find another solution.