[ 'class' => \yii\filters\AccessControl::className(), 'rules' => [ // allow authenticated users [ 'actions' => [ 'index','view' ], 'allow' => true, 'roles' => ['admin','employee','reception'], ], // everything else is denied ], ], ]; } /** * Lists all Transfer models. * @return mixed */ public function actionIndex() { $searchModel = new TransferSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); $accounts = Account::read(); $searchModel->totalsTransfers(); $users = User::read(); return $this->render('index', [ 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'accounts' => $accounts, 'users' => $users, ]); } /** * Displays a single Transfer model. * @param integer $id * @return mixed */ public function actionView($id) { return $this->render('view', [ 'model' => $this->findModel($id), ]); } /** * Updates an existing Transfer model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed public function actionUpdate($id) { $model = $this->findModel($id); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id_transfer]); } else { return $this->render('update', [ 'model' => $model, ]); } } */ /** * Finds the Transfer model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Transfer the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Transfer::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } } }