Beispiel #1
0
 /**
  * @param array $roles
  * @return static
  */
 public function byRoles($roles)
 {
     $this->innerJoinWith(['roles' => function ($query) use($roles) {
         /** @var ActiveQuery $query */
         return $query->where([Role::tableName() . '.name' => $roles]);
     }]);
     return $this;
 }
Beispiel #2
0
 public function search($params)
 {
     $query = Role::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $this->addCondition($query, 'name', true);
     $this->addCondition($query, 'type');
     $this->addCondition($query, 'description', true);
     $this->addCondition($query, 'biz_rule', true);
     $this->addCondition($query, 'data', true);
     return $dataProvider;
 }
Beispiel #3
0
 /**
  * @return ActiveQuery
  */
 public function getRoles()
 {
     return $this->hasMany(Role::className(), ['name' => 'item_name'])->viaTable('{{%admin_auth_assignment}}', ['user_id' => 'id']);
 }
 /**
  * Finds the Role model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return Role the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if ($id !== null && ($model = Role::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }