예제 #1
0
 public function actionIndex()
 {
     $model = new AgMcate();
     //填充添加类别
     $model->status = 1;
     //填充单选值1默认选中
     //分页读取类别数据
     $cate = AgMcate::find();
     $pagination = new Pagination(['defaultPageSize' => 10, 'totalCount' => $cate->count()]);
     $cate = $cate->orderBy('id ASC')->offset($pagination->offset)->limit($pagination->limit)->all();
     return $this->render('index', ['model' => $model, 'cate' => $cate, 'pagination' => $pagination]);
 }
예제 #2
0
 public function actionMerchadd()
 {
     $mcate = AgMcate::find()->all();
     //行业类别数据填充
     //添加商家
     $model = new AgMerch();
     if ($model->load(Yii::$app->request->post())) {
         $model->setPassword($_POST['AgMerch']['password_hash']);
         $model->generateAuthKey();
         if ($model->save()) {
             Yii::$app->getSession()->setFlash('info', '添加成功!');
             return $this->redirect(['index']);
         }
     }
     return $this->render('merchadd', ['mcate' => $mcate, 'model' => $model]);
 }