[ 'class' => AccessControl::className(), 'rules' => [ [ 'actions' => ['login', 'error', 'cjyy'], 'allow' => true, ], [ 'actions' => ['logout', 'index'], 'allow' => true, 'roles' => ['@'], ], ], ], 'verbs' => [ 'class' => VerbFilter::className(), 'actions' => [ 'logout' => ['post'], ], ], ]; } public function actionIndex() { $dataProvider = new ActiveDataProvider([ 'query' => RabbitLog::find(), 'sort' => [ 'defaultOrder' => [ 'addtime' => SORT_DESC ] ], ]) ; return $this->render('index',[ 'dataProvider' => $dataProvider ]); } public function actionView($id){ return $this->render('view',[ 'model'=>RabbitLog::findOne($id), ]); } public function actionCreate() { $model = new Banner(); $model->status=Banner::STATUS_DISPLAY; if ($model->load(Yii::$app->request->post()) && $model->save()) { //保存操作记录 \common\models\RabbitLog::saveLog('banner','create',$model->searchById($model->primaryKey),$model->primaryKey); Yii::$app->session->setFlash('success','Banner【'.$model->title.'】发布成功'); return $this->redirect(['index']); } else { return $this->render('create', [ 'model' => $model, ]); } } public function searchById($id){ if (($model = RabbitLog::findOne($id)) !== null) { return json_encode($model->toArray()); } else { throw new \yii\web\NotFoundHttpException('The requested page does not exist.'); } } }