public function actionCreate() { $id = intval(Yii::$app->request->getBodyParam('id')); $date = trim(Yii::$app->request->getBodyParam('date')); $locationId = intval(Yii::$app->request->getBodyParam('location_id')); $areaId = intval(Yii::$app->request->getBodyParam('area_id')); $remark = trim(Yii::$app->request->getBodyParam('remark')); if ($date == '') { $this->ajax_return(false, '日期不能为空!'); } if ($locationId < 0) { $this->ajax_return(false, '地点不正确!'); } if ($areaId < 0) { $this->ajax_return(false, '属地不正确!'); } if ($id != 0) { $model = MaggieBox::findOne($id); if ($model == null) { $this->ajax_return(false, '找不到相应的数据'); } } else { $model = new MaggieBox(); } $model->date = $date; $model->location_id = $locationId; $model->area_id = $areaId; $model->remark = $remark; $pics = $this->__upload('pics'); if (!empty($pics)) { $model->pics = implode(',', $pics); } if ($model->save()) { $this->ajax_return(true, '操作成功!'); } else { $this->ajax_return(false, '操作失败!'); } }