We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RT。图省事直接加了 if(isset($data[static::$formName]) && empty($data[static::$formName])) { if(!$this->owner->isNewRecord) { $this->beforeDelete(); } } 如果规范,是否加个if嵌套?
The text was updated successfully, but these errors were encountered:
恩。
public function afterSave() { if (\Yii::$app->request->isConsoleRequest ) { return; } $data = \Yii::$app->request->post($this->owner->formName()); if(isset($data[static::$formName])) { if(!$this->owner->isNewRecord) { $this->beforeDelete(); } if (!empty($data[static::$formName])) { $tags = $data[static::$formName]; foreach ($tags as $tag) { $tagModel = Tag::findOne(['name' => $tag]); if (empty($tagModel)) { $tagModel = new Tag(); $tagModel->name = $tag; $tagModel->save(); } $articleTag = new ArticleTag(); $articleTag->article_id = $this->owner->id; $articleTag->tag_id = $tagModel->id; $articleTag->save(); } Tag::updateAllCounters(['article' => 1], ['name' => $tags]); } } }
Sorry, something went wrong.
No branches or pull requests
RT。图省事直接加了
if(isset($data[static::$formName]) && empty($data[static::$formName])) {
if(!$this->owner->isNewRecord) {
$this->beforeDelete();
}
}
如果规范,是否加个if嵌套?
The text was updated successfully, but these errors were encountered: