Пример #1
0
 /**
  * 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;
 }
Пример #2
0
    <?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>";
Пример #3
0
 /**
  * Finds the Route model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return Route the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Route::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }