/** * Lists all GoodsType models. * @return mixed */ public function actionIndex() { if (!$this->is_access('goodstype/index')) { Yii::$app->session->setFlash('error', $this->errorInfo); return $this->redirect($this->redirectUrl); } $dataProvider = new ActiveDataProvider(['query' => GoodsType::find()]); Yii::$app->view->params['meta_title'] = '商品类型'; return $this->render('index', ['dataProvider' => $dataProvider]); }
public function actionGoodsadd() { //获取商品类型及其属性 $type = GoodsType::find()->all(); //获取商品分类信息 $category = new GoodsCategory(); $cate = $category->list_cate(); //获取商品品牌信息 $brand = GoodsBrand::find()->all(); $model = new Goods(); return $this->render('goodsadd', ['type' => $type, 'cate' => $cate, 'brand' => $brand, 'model' => $model]); }
public function actionAttredit() { if (Yii::$app->request->get('id')) { $type = GoodsType::find()->all(); //商品类型数据填充 $id = Yii::$app->request->get('id'); $type_id = Yii::$app->request->get('type_id'); //商品类型id $model = Attribute::findOne($id); return $this->render('attredit', ['id' => $id, 'type_id' => $type_id, 'model' => $model, 'type' => $type]); } elseif (Yii::$app->request->post('id')) { $id = Yii::$app->request->post('id'); $model = Attribute::findOne($id); if ($model === null) { Yii::$app->getSession()->setFlash("info", '编辑失败'); return $this->redirect(['attrlist', 'type_id' => $model->type_id]); } if ($model->load(Yii::$app->request->post())) { if ($model->save()) { Yii::$app->getSession()->setFlash('info', '编辑成功!'); return $this->redirect(['attrlist', 'type_id' => $model->type_id]); } } } }