Blame view

common/models/Menu.php 2.08 KB
b507d689   andryeyev   Итерация 1 (Терми...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
  <?php
  
  namespace common\models;
  
  use Yii;
  
  /**
   * This is the model class for table "menu".
   *
   * @property integer $menu_id
   * @property integer $menu_pid
   * @property integer $menu_lft
   * @property integer $menu_rgt
   * @property integer $termin_id
   * @property integer $show
   * @property integer $sortorder
   */
  class Menu extends \yii\db\ActiveRecord
  {
19423060   andryeyev   + 1-уровневое мен...
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
      
      public function getMenuList()
      { 
          return yii::$app->db->createCommand('
              SELECT 
                  `termin_lang`.termin_title, `termin_lang`.termin_id 
              FROM `menu`
                  INNER JOIN `termin_lang` ON `termin_lang`.termin_id = `menu`.termin_id
                      AND `termin_lang`.lang_id = '.yii::$app->lang_id.'
              ORDER BY `menu`.menu_pid ASC, `menu`.sortorder ASC
          ')->queryAll();
  /*
          return $this->find()
              ->selectOption('`termin_lang`.termin_title')
              ->from('menu')
              ->join(
                  'INNER JOIN', 
                  '`termin_lang`.termin_id = `menu`.termin_id', 
                  ['lang_id' => yii::$app->lang_id])
              ->all();
  */
      }
  
b507d689   andryeyev   Итерация 1 (Терми...
43
44
45
46
47
48
49
50
51
52
53
54
55
56
      /**
       * @inheritdoc
       */
      public static function tableName()
      {
          return 'menu';
      }
  
      /**
       * @inheritdoc
       */
      public function rules()
      {
          return [
7765bf97   Dmitryi   menu no perevod
57
              [['menu_pid', 'menu_lft', 'menu_rgt', 'termin_id', 'show', 'sortorder'], 'safe'],
b507d689   andryeyev   Итерация 1 (Терми...
58
59
60
61
62
63
64
65
66
67
              [['menu_pid', 'menu_lft', 'menu_rgt', 'termin_id', 'show', 'sortorder'], 'integer']
          ];
      }
  
      /**
       * @inheritdoc
       */
      public function attributeLabels()
      {
          return [
7765bf97   Dmitryi   menu no perevod
68
69
70
71
72
73
74
              'menu_id' => Yii::t('app', 'Menu ID'),
              'menu_pid' => Yii::t('app', 'Menu Pid'),
              'menu_lft' => Yii::t('app', 'Menu Lft'),
              'menu_rgt' => Yii::t('app', 'Menu Rgt'),
              'termin_id' => Yii::t('app', 'Termin ID'),
              'show' => Yii::t('app', 'Show'),
              'sortorder' => Yii::t('app', 'Sortorder'),
b507d689   andryeyev   Итерация 1 (Терми...
75
76
          ];
      }
6be43b62   andryeyev   MenuSearch fix
77
78
79
80
81
  
      public function getTermin_lang()
      {
          return $this->hasMany(Menu::className(), ['termin_id' => 'termin_id']);
      }  
b507d689   andryeyev   Итерация 1 (Терми...
82
  }