示例#1
0
 public function actionAddBlog()
 {
     $model = new Blog();
     $image = new Image();
     $data = Yii::$app->request->post();
     $model->load($data, '');
     $image->img = UploadedFile::getInstancesByName("image");
     if ($image->validate() && $model->save()) {
         if (!empty($model->categorys)) {
             $model->setCategories();
         }
         if (!empty($image->img)) {
             $image->uploads($model, Image::BLOG_STATUS);
         }
         return $model;
     }
     return array_merge($model->getErrors(), $image->getErrors());
 }