/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Route::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['status' => $this->status]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'alias', $this->alias])->andFilterWhere(['like', 'type', $this->type]); return $dataProvider; }
<?php $types = Route::find()->where(['status' => 1])->groupBy('type')->all(); echo "<table class='table table-condensed table-striped table-hover'>"; echo "<tr>"; echo "<th>Type</th>"; echo "<th>Permision</th>"; echo "<tr>"; $auth = Yii::$app->authManager; $permissions = $auth->getPermissionsByRole($model->name); //echo "<tbody>"; foreach ($types as $type) { echo "<tr>"; echo "<td>" . $type->type . "</td>"; echo "<td>"; $aliass = Route::find()->where(['status' => 1, 'type' => $type->type])->all(); foreach ($aliass as $alias) { echo "<label style='display:block;width:100px;float:left;overflow:hidden;'>"; $can = array_key_exists($alias->name, $permissions); $checked = false; if ($can) { $checked = true; } echo Html::checkbox($type->type . '_' . $alias->alias, $checked, ['title' => $alias->name, 'class' => 'checkboxPermission']) . ' ' . $alias->alias; echo "</label>"; } echo "</td>"; echo "</tr>"; } //echo "</tbody>"; echo "</table>";