/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = RbacRole::find();
     // add conditions that should always apply here
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
示例#2
0
use yii\helpers\ArrayHelper;
/* @var $this yii\web\View */
/* @var $searchModel juliardi\simplerbac\models\RbacAccessRulesSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Rbac Access Rules';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="rbac-access-rules-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::a('Create Rbac Access Rules', ['create'], ['class' => 'btn btn-success']);
?>
    </p>
    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['label' => 'Role', 'attribute' => 'role_id', 'filter' => ArrayHelper::map(RbacRole::find()->all(), 'id', 'name'), 'value' => function ($data) {
    return $data->role->name;
}], ['label' => 'Route', 'attribute' => 'route_id', 'filter' => ArrayHelper::map(RbacRoute::find()->all(), 'id', 'name'), 'value' => function ($data) {
    return $data->route->name;
}], ['class' => 'yii\\grid\\ActionColumn']]]);
?>
</div>