Level 122
add a date time column, then create a mutator for your status. Set the datetime in the mutator according to your business logic whenever the status is set.
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Good morning.
I have a "status" field in the database (Active, Inactive). How could I keep a modification date only for this field?
That is, to know how long a user has been "inactive".
Any suggestions - ideas? Thanks
In case someone needs something similar:
public function setStatusIdAttribute($value)
{
$this->attributes['status_id'] = $value ?? $value = 1;
if($this->isDirty())
{
$this->attributes['status_updated_at'] = now();
}
}
@snapey, I don't know if that's exactly what you had in mind, but thank you.
Please or to participate in this conversation.