Esempio n. 1
0
 public function actionEditSubmit()
 {
     $params = Yii::$app->request->post();
     $brandDto = new BrandDto();
     $brandDto->setScenario('admin-update');
     if ($brandDto->load(['BrandDto' => $params]) && $brandDto->validate()) {
         try {
             $this->brandService->save($brandDto);
             return $this->retMsg(200, '更新成功!', 'brand_index');
         } catch (Exception $e) {
             return $this->retMsg(300, '更新失败!', 'brand_index');
         }
     } else {
         return $this->retMsg(300, array_values($brandDto->getFirstErrors()));
     }
 }