private function getRouteModel($action)
 {
     $route = $this->id . '/' . $action->id;
     $routeModel = RbacRoute::findOne(['name' => $route]);
     if (is_null($routeModel)) {
         throw new HttpException(500, 'Internal Server Error');
     } else {
         return $routeModel;
     }
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = RbacRoute::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;
 }
 /**
  * Finds the RbacRoute model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  *
  * @param int $id
  *
  * @return RbacRoute the loaded model
  *
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = RbacRoute::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemple #4
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>