您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

OrderStatusHistory.php 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. namespace domain\Order\OrderStatusHistory;
  3. use common\components\ActiveRecordCommon;
  4. use domain\Order\Order\Order;
  5. use domain\Order\OrderStatus\OrderStatus;
  6. use domain\User\User\User;
  7. class OrderStatusHistory extends ActiveRecordCommon
  8. {
  9. protected OrderStatus $orderStatusObject;
  10. public function getOrder(): Order
  11. {
  12. return $this->orderRelation;
  13. }
  14. public function setOrder(Order $order): self
  15. {
  16. $this->populateFieldObject('id_order', 'orderRelation', $order);
  17. return $this;
  18. }
  19. public function getUser(): User
  20. {
  21. return $this->userRelation;
  22. }
  23. public function setUser(User $user): self
  24. {
  25. $this->populateFieldObject('id_user', 'userRelation', $user);
  26. return $this;
  27. }
  28. public function getDate(): \DateTime
  29. {
  30. return new \DateTime($this->date);
  31. }
  32. public function setDate(\DateTime $date): self
  33. {
  34. $this->date = $date->format('Y-m-d H:i:s');
  35. return $this;
  36. }
  37. public function getOrderStatusAlias(): string
  38. {
  39. return $this->order_status_alias;
  40. }
  41. public function setOrderStatusAlias(string $orderStatusAlias): self
  42. {
  43. $this->order_status_alias = $orderStatusAlias;
  44. return $this;
  45. }
  46. public function getOrderStatus(): OrderStatus
  47. {
  48. return $this->orderStatusObject;
  49. }
  50. public function setOrderStatus(OrderStatus $orderStatus): self
  51. {
  52. $this->orderStatusObject = $orderStatus;
  53. $this->setOrderStatusAlias($orderStatus->getAlias());
  54. return $this;
  55. }
  56. public static function tableName()
  57. {
  58. return 'order_status_history';
  59. }
  60. public function rules()
  61. {
  62. return [
  63. [['id_order', 'order_status_alias', 'date', 'id_user'], 'required'],
  64. [['id_order', 'id_user'], 'integer'],
  65. [['order_status_alias'], 'string'],
  66. [['date'], 'safe'],
  67. ];
  68. }
  69. public function attributeLabels()
  70. {
  71. return [
  72. 'id' => 'ID',
  73. 'id_order' => 'Commande',
  74. 'order_status_alias' => 'Statut',
  75. 'date' => 'Date',
  76. 'id_user' => 'Utilisateur'
  77. ];
  78. }
  79. /* Relations */
  80. protected function getOrderRelation()
  81. {
  82. return $this->hasOne(Order::class, ['id' => 'id_order']);
  83. }
  84. protected function getUserRelation()
  85. {
  86. return $this->hasOne(User::class, ['id' => 'id_user']);
  87. }
  88. }