|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- <?php
-
- namespace domain\Order\OrderStatusHistory;
-
- use common\components\ActiveRecordCommon;
- use domain\Order\Order\Order;
- use domain\Order\OrderStatus\OrderStatus;
- use domain\User\User\User;
-
- class OrderStatusHistory extends ActiveRecordCommon
- {
- protected OrderStatus $orderStatusObject;
-
- public function getOrder(): Order
- {
- return $this->orderRelation;
- }
-
- public function setOrder(Order $order): self
- {
- $this->populateFieldObject('id_order', 'orderRelation', $order);
- return $this;
- }
-
- public function getUser(): User
- {
- return $this->userRelation;
- }
-
- public function setUser(User $user): self
- {
- $this->populateFieldObject('id_user', 'userRelation', $user);
- return $this;
- }
-
- public function getDate(): \DateTime
- {
- return new \DateTime($this->date);
- }
-
- public function setDate(\DateTime $date): self
- {
- $this->date = $date->format('Y-m-d H:i:s');
- return $this;
- }
-
- public function getOrderStatusAlias(): string
- {
- return $this->order_status_alias;
- }
-
- public function setOrderStatusAlias(string $orderStatusAlias): self
- {
- $this->order_status_alias = $orderStatusAlias;
- return $this;
- }
-
- public function getOrderStatus(): OrderStatus
- {
- return $this->orderStatusObject;
- }
-
- public function setOrderStatus(OrderStatus $orderStatus): self
- {
- $this->orderStatusObject = $orderStatus;
- $this->setOrderStatusAlias($orderStatus->getAlias());
- return $this;
- }
-
- public static function tableName()
- {
- return 'order_status_history';
- }
-
- public function rules()
- {
- return [
- [['id_order', 'order_status_alias', 'date', 'id_user'], 'required'],
- [['id_order', 'id_user'], 'integer'],
- [['order_status_alias'], 'string'],
- [['date'], 'safe'],
- ];
- }
-
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'id_order' => 'Commande',
- 'order_status_alias' => 'Statut',
- 'date' => 'Date',
- 'id_user' => 'Utilisateur'
- ];
- }
-
- /* Relations */
-
- protected function getOrderRelation()
- {
- return $this->hasOne(Order::class, ['id' => 'id_order']);
- }
-
- protected function getUserRelation()
- {
- return $this->hasOne(User::class, ['id' => 'id_user']);
- }
- }
|