Esempio n. 1
0
 /**
  * @inheritdoc
  */
 public static function find()
 {
     return parent::find()->where(['type' => static::CMS_TYPE]);
 }
Esempio n. 2
0
 /**
  * @inheritdoc
  */
 public static function find()
 {
     /** @var RelationModel $instance */
     $instance = new static();
     $query = parent::find();
     return $query;
 }
Esempio n. 3
0
 /**
  * @inheritdoc
  */
 public static function find()
 {
     $instance = new static();
     $query = parent::find()->select("{$instance::tableName()}.*");
     foreach ($instance->_relations as $key => $relation) {
         $joinType = isset($relation['joinType']) ? $relation['joinType'] : 'leftJoin';
         if (isset($relation['table'])) {
             $relationTable = $instance->{$relation['table']}->tableName();
         } else {
             $relationTable = $instance::tableName();
         }
         $table = $instance->{$key}->tableName();
         if (is_array($relation['on'])) {
             $on = [];
             foreach ($relation['on'] as $k => $fk) {
                 $on[] = "{$table}.{$k} = {$relationTable}.{$fk}";
             }
             $on = implode(' AND ', $on);
         } else {
             $on = $relation['on'];
         }
         $params = isset($relation['params']) ? $relation['params'] : [];
         $query->{$joinType}($table, $on, $params)->addSelect("{$table}.*");
     }
     return $query;
 }
Esempio n. 4
0
 public static function find()
 {
     return parent::find()->where(['role' => static::ROLE_USER]);
 }