[ 'class' => AccessControl::className(), 'rules' => [ [ 'actions' => [], 'allow' => true, 'roles' => ['@'], ], ], ], ]; } public function actionIndex(){ $models = Feedback::find()->where('uid=:uid and type=:type',[':uid'=>Yii::$app->user->id,':type'=>Feedback::TYPE_COMPANY]); $pages = new Pagination(["totalCount"=>$models->count(),"pageSize"=>self::PAGESIZE]); $models = $models->offset($pages->offset)->limit($pages->limit)->all(); return $this->render('index',['models'=>$models,'pages'=>$pages]); } public function actionCreate(){ $model = new Feedback(); $content = Yii::$app->request->get('content'); $email = Yii::$app->request->get('email'); $model->uid = Yii::$app->user->id; $model->content = isset($content)?$content:""; $model->contact = isset($email)?$email:""; $model->created_at = time(); $model->updated_at = time(); $model->status = Feedback::STATUS_ACTIVE; $model->type = Feedback::TYPE_COMPANY; $model->state = Feedback::STATE_WAIT; if($model->validate()&&$model->save()){ $result=['sign'=>1,'msg'=>'已经反馈']; return json_encode($result); }else{ $result=['sign'=> 4000,'msg'=>'反馈失败']; return json_encode($result); } } }