50], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'name' => 'Name', 'desc' => 'Desc', 'is_delete' => 'Is Delete', 'created_at' => 'Created At', 'updated_at' => 'Updated At', 'deleted_at' => 'Deleted At', 'status' => 'Status', ]; } public function edit() { if (!$this->validate()) { return $this->getModelError(); } if ($this->model->isNewRecord) { $this->model->is_delete = 0; $this->model->deleted_at = 0; $this->model->created_at = time(); $exists = BallCart::find()->where(['ball_number' => $this->ball_number,'is_delete' => 0])->exists(); if($exists){ return $this->apiReturnError('球车编号已存在'); } } if(!empty($this->model) && $this->model->ball_number != $this->ball_number){ $exists = BallCart::find()->where(['ball_number' => $this->ball_number,'is_delete' => 0])->exists(); if($exists){ return $this->apiReturnError('球车编号已存在'); } } $this->model->updated_at = time(); $this->model->name = $this->name; $this->model->money = $this->money; $this->model->cover_pic = $this->cover_pic; $this->model->ball_number = $this->ball_number; $this->model->store_id = $this->store_id; $this->model->mark_id = $this->mark_id; $this->model->content = $this->content; if ($this->desc) { $this->model->desc = $this->desc; } if ($this->status) { $this->model->status = $this->status; } if (!$this->model->save()) { return $this->getModelError($this->model); } return $this->apiReturnSuccess('保存成功'); } }