Blame view

common/models/Currency.php 1.46 KB
d02fd466   Yarik   test
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
  <?php
  
  namespace common\models;
  
  use Yii;
  
  /**
   * This is the model class for table "currency".
   *
   * @property integer $currency_id
   * @property string $name
   * @property string $symbol
   * @property string $code
   * @property double $rate
   * @property string $date_update
   * @property integer $is_default
   */
  class Currency extends \yii\db\ActiveRecord
  {
      /**
       * @inheritdoc
       */
      public static function tableName()
      {
          return 'currency';
      }
  
      /**
       * @inheritdoc
       */
      public function rules()
      {
          return [
              [['rate'], 'number'],
              [['date_update'], 'safe'],
              [['is_default'], 'integer'],
              [['name', 'symbol'], 'string', 'max' => 255],
              [['code'], 'string', 'max' => 3],
          ];
      }
  
      /**
       * @inheritdoc
       */
      public function attributeLabels()
      {
          return [
              'currency_id' => Yii::t('app', 'Currency ID'),
              'name' => Yii::t('app', 'Name'),
              'symbol' => Yii::t('app', 'Symbol'),
              'code' => Yii::t('app', 'Code'),
              'rate' => Yii::t('app', 'Rate'),
              'date_update' => Yii::t('app', 'Date Update'),
              'is_default' => Yii::t('app', 'Is Default'),
          ];
      }
9cc08528   Yarik   test
57
58
59
60
61
  
      public static function getCurrencyDropdown()
      {
          return self::find()->select(['label', 'currency_id'])->indexBy('currency_id')->orderBy(['is_default' => SORT_DESC, 'currency_id' => SORT_ASC])->asArray()->column();
      }
d02fd466   Yarik   test
62
  }