Blame view

common/modules/relation/relationQueryTrait.php 846 Bytes
a8370482   Alexander Karnovsky   init project
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
  <?php
  
  namespace common\modules\relation;
  
  trait relationQueryTrait {
  
      static public $cache_tree = [];
  
      /** @var \yii\db\ActiveQuery $this */
      static $model;
  
      /*
       * @return \yii\db\ActiveQuery
       */
      private function getModel()
      {
          if (empty(self::$model)) {
              $class = $this->modelClass;
              self::$model = new $class;
          }
          return self::$model;
      }
  
b519af22   Karnovsky A   Base-product func...
24
25
      /*public function getRelations($relation) {
          $model = $this->getModel();
a8370482   Alexander Karnovsky   init project
26
  
b519af22   Karnovsky A   Base-product func...
27
28
29
30
31
32
          $relation = $model->_getRelation($relation);
          return
              $model->owner
                  ->hasMany($relation['outer']['model'], [$relation['outer']['key'] => $relation['outer']['linked_key']])
                  ->viaTable($relation['linked_table'], [$relation['inner']['linked_key'] => $relation['inner']['key']]);
      }*/
a8370482   Alexander Karnovsky   init project
33
  }