Blame view

common/modules/product/models/RemoteCategories.php 1.28 KB
ad9b9ca9   Karnovsky A   Karnovsky-2904201...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
  <?php
  
  namespace common\modules\product\models;
  
  use Yii;
  
  /**
   * This is the model class for table "remote_categories".
   *
   * @property string $Name
   * @property string $ID_chief
   * @property string $ID
   */
  class RemoteCategories extends \yii\db\ActiveRecord
  {
      /**
       * @inheritdoc
       */
      public static function tableName()
      {
          return 'remote_categories';
      }
  
      /**
       * @inheritdoc
       */
      public function rules()
      {
          return [
              [['Name'], 'string', 'max' => 100],
              [['ID_chief', 'ID'], 'string', 'max' => 20],
          ];
      }
  
      /**
       * @inheritdoc
       */
      public function attributeLabels()
      {
          return [
              'Name' => Yii::t('product', 'Name'),
              'ID_chief' => Yii::t('product', 'Id Chief'),
              'ID' => Yii::t('product', 'ID'),
          ];
      }
  
      public function getCategory() {
          if (empty($this->ID)) {
              return null;
          }
          return CategorySearch::findByRemoteID($this->ID);
      }
  
      public static function findByID($id) {
          /** @var CategoryQuery $query */
          $query = RemoteCategories::find()
              ->andFilterWhere(['ID' => $id]);
          if (($model = $query->one()) !== null) {
              return $model;
          }
          return null;
      }
  }