Пример #1
0
 /**
  * Finds the Access model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Access the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Access::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Пример #2
0
 public function actionDeletemodule()
 {
     $data = [];
     $module = Access::findOne(["id" => $_POST["module_id"]]);
     $profile_id = $module->profile_id;
     $rowdeleted = $module->delete();
     $data['message'] = "{$rowdeleted} Module(s) Deleted";
     $dataProvider = new ActiveDataProvider(['query' => Access::find()->where(["profile_id" => $profile_id])->orderBy('id DESC'), 'pagination' => ['pageSize' => 20]]);
     $data['gridmodules'] = GridView::widget(['dataProvider' => $dataProvider, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'id', ['attribute' => 'module', 'value' => 'module.label'], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{deletemodule}', 'buttons' => ['deletemodule' => function () {
         return Html::a('<span class="glyphicon glyphicon-trash"></span>', null, ['data-confirm' => 'Are you sure you want to delete this item?', 'class' => "deletemoduleajax"]);
     }]]], 'options' => ['class' => '', 'id' => 'grid-accesses']]);
     Yii::$app->response->format = Response::FORMAT_JSON;
     return $data;
 }