dougan1884 2017-11-27 17:19
浏览 194

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');
  • 写回答

2条回答 默认 最新

  • douleng0794 2017-11-27 17:24
    关注

    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
    
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog