Blame view

common/modules/product/models/Stock.php 2.72 KB
d8c1a2e0   Yarik   Big commit artbox
1
  <?php
5c2eb7c8   Yarik   Big commit almost...
2
3
4
      
      namespace common\modules\product\models;
      
c70f24ea   Yarik   For Leha commit.
5
      use common\modules\language\behaviors\LanguageBehavior;
5c2eb7c8   Yarik   Big commit almost...
6
      use Yii;
c70f24ea   Yarik   For Leha commit.
7
      use yii\db\ActiveQuery;
5c2eb7c8   Yarik   Big commit almost...
8
      use yii\db\ActiveRecord;
c70f24ea   Yarik   For Leha commit.
9
      use yii\web\Request;
772a3ca4   Yarik   Big commit
10
      
d8c1a2e0   Yarik   Big commit artbox
11
      /**
5c2eb7c8   Yarik   Big commit almost...
12
       * This is the model class for table "stock".
4428da8c   Yarik   Almost all databa...
13
       *
772a3ca4   Yarik   Big commit
14
15
16
17
       * @property integer          $id
       * @property ProductStock[]   $productStocks
       * @property ProductVariant[] $productVariants
       * @property Product[]        $products
c70f24ea   Yarik   For Leha commit.
18
       * * From language behavior *
772a3ca4   Yarik   Big commit
19
20
21
22
23
24
25
       * @property StockLang        $lang
       * @property StockLang[]      $langs
       * @property StockLang        $objectLang
       * @property string           $ownerKey
       * @property string           $langKey
       * @property StockLang[]      $modelLangs
       * @property bool             $transactionStatus
c70f24ea   Yarik   For Leha commit.
26
27
28
29
30
31
32
33
34
35
36
37
       * @method string           getOwnerKey()
       * @method void             setOwnerKey( string $value )
       * @method string           getLangKey()
       * @method void             setLangKey( string $value )
       * @method ActiveQuery      getLangs()
       * @method ActiveQuery      getLang( integer $language_id )
       * @method StockLang[]    generateLangs()
       * @method void             loadLangs( Request $request )
       * @method bool             linkLangs()
       * @method bool             saveLangs()
       * @method bool             getTransactionStatus()
       * * End language behavior *
d8c1a2e0   Yarik   Big commit artbox
38
       */
5c2eb7c8   Yarik   Big commit almost...
39
      class Stock extends ActiveRecord
d8c1a2e0   Yarik   Big commit artbox
40
      {
5c2eb7c8   Yarik   Big commit almost...
41
42
43
44
45
46
47
          /**
           * @inheritdoc
           */
          public static function tableName()
          {
              return 'stock';
          }
772a3ca4   Yarik   Big commit
48
          
c70f24ea   Yarik   For Leha commit.
49
          public function behaviors()
5c2eb7c8   Yarik   Big commit almost...
50
51
          {
              return [
c70f24ea   Yarik   For Leha commit.
52
53
                  'language' => [
                      'class' => LanguageBehavior::className(),
5c2eb7c8   Yarik   Big commit almost...
54
55
56
57
58
59
60
61
62
63
                  ],
              ];
          }
          
          /**
           * @inheritdoc
           */
          public function attributeLabels()
          {
              return [
772a3ca4   Yarik   Big commit
64
                  'id' => Yii::t('product', 'Stock ID'),
5c2eb7c8   Yarik   Big commit almost...
65
66
              ];
          }
4428da8c   Yarik   Almost all databa...
67
          
772a3ca4   Yarik   Big commit
68
69
70
          /**
           * @return \yii\db\ActiveQuery
           */
4428da8c   Yarik   Almost all databa...
71
72
73
74
75
          public function getProductStocks()
          {
              return $this->hasMany(ProductStock::className(), [ 'stock_id' => 'id' ]);
          }
          
772a3ca4   Yarik   Big commit
76
77
78
          /**
           * @return ActiveQuery
           */
4428da8c   Yarik   Almost all databa...
79
80
81
82
83
84
          public function getProductVariants()
          {
              return $this->hasMany(ProductVariant::className(), [ 'id' => 'product_variant_id' ])
                          ->via('productStocks');
          }
          
772a3ca4   Yarik   Big commit
85
86
87
          /**
           * @return ActiveQuery
           */
4428da8c   Yarik   Almost all databa...
88
89
90
91
92
          public function getProducts()
          {
              return $this->hasMany(Product::className(), [ 'id' => 'product_id' ])
                          ->via('productVariants');
          }
d8c1a2e0   Yarik   Big commit artbox
93
      }