Laravel - 如何获取某些属性/字段已更改为某个值的日期?

For example I have table

orders 

and model

Order

order have attribute status. Initial status is 'cart', but second status is 'ordered', after that status is 'processed', after that status id 'delivery', after that status is 'canceled' or completed. I will probably have more than 10 statuses.

Is there any a better solution rather than creating datetime attribute/field for each status :

cart_at
ordered_at
processed_at
....

and then save datetime for each status after is changed ?

I want a package where I can do something like :

echo 'Order is cancelled at '. $order->getDateFor('status', 'canceled');

You can have a table name order_events an log there what is going on with your orders with the following fields:

id
order_id
event_type_id
details
created_at

You can use VentureCraft/revisionable package to track all changes on your model atributes and then use revisionable upgrade package https://github.com/fico7489/laravel-revisionable-upgrade to get date when status was updated :

echo 'order is updated to status "canceled" at ' . $order->dateUpdated('status', 'canceled');