12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- namespace backend\controllers;
- use common\models\RabbitLog;
- use Yii;
- use yii\web\Controller;
- use yii\filters\VerbFilter;
- use yii\filters\AccessControl;
- use common\models\LoginForm;
- use backend\controllers;
- use yii\data\ActiveDataProvider;
- use common\models\Banner;
- /**
- * RabbitLog Controller
- */
- class RabbitController extends Controller
- {
- 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.');
- }
- }
- }
|