Blame view

common/models/OrderProduct.php 2.23 KB
d8c1a2e0   Yarik   Big commit artbox
1
  <?php
d8c1a2e0   Yarik   Big commit artbox
2
      
5c2eb7c8   Yarik   Big commit almost...
3
      namespace common\models;
d8c1a2e0   Yarik   Big commit artbox
4
      
5c2eb7c8   Yarik   Big commit almost...
5
6
7
      use common\modules\product\models\ProductVariant;
      use Yii;
      use yii\db\ActiveRecord;
d8c1a2e0   Yarik   Big commit artbox
8
      
c70f24ea   Yarik   For Leha commit.
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
      /**
       * Class OrderProduct
       *
       * @property int            $id
       * @property int            $order_id
       * @property int            $product_variant_id
       * @property string         $product_name
       * @property string         $name
       * @property string         $sku
       * @property double         $price
       * @property int            $count
       * @property double         $sum_cost
       * @property Order          $order
       * @property ProductVariant $productVariant
       * @package common\models
       */
      class OrderProduct extends ActiveRecord
d8c1a2e0   Yarik   Big commit artbox
26
      {
5c2eb7c8   Yarik   Big commit almost...
27
28
29
          
          public static function tableName()
          {
8af13427   Yarik   For leha commit.
30
              return 'order_product';
5c2eb7c8   Yarik   Big commit almost...
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
          }
          
          public function rules()
          {
              return [
                  [
                      [ 'order_id' ],
                      'required',
                  ],
                  //['email', 'email'],
                  [
                      [
                          'product_name',
                          'name',
                          'price',
                          'count',
                          'sum_cost',
8af13427   Yarik   For leha commit.
48
                          'product_variant_id',
5c2eb7c8   Yarik   Big commit almost...
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
                          'sku',
                      ],
                      'safe',
                  ],
              ];
          }
          
          public function attributeLabels()
          {
              return [
                  'product_name' => Yii::t('app', 'product_name'),
                  'name'         => Yii::t('app', 'op_name'),
                  'art'          => Yii::t('app', 'art'),
                  'cost'         => Yii::t('app', 'cost'),
                  'count'        => Yii::t('app', 'count'),
                  'sum_cost'     => Yii::t('app', 'sum_cost'),
              ];
          }
          
c70f24ea   Yarik   For Leha commit.
68
69
70
71
72
73
74
75
          public function getOrder()
          {
              return $this->hasOne(Order::className(), [ 'id' => 'order_id' ]);
          }
          
          /**
           * @return \yii\db\ActiveQuery
           */
5c2eb7c8   Yarik   Big commit almost...
76
77
          public function getProductVariant()
          {
4428da8c   Yarik   Almost all databa...
78
              return $this->hasOne(ProductVariant::className(), [ 'id' => 'product_variant_id' ]);
5c2eb7c8   Yarik   Big commit almost...
79
80
          }
      }