Blame view

common/models/Currency.php 1.53 KB
eb7e82fb   Administrator   29.02.16
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
  <?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 [

06ec2844   Administrator   28.03.16
48
49
50
51
52
53
54
              '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'),

eb7e82fb   Administrator   29.02.16
55
56
57
58
59
60
61
62
          ];

      }

  

      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();

      }

  }