/** * @inheritDoc */ public function beforeSave($insert) { //新增且sort_no未输入则自动生成 if ($insert && $this->pbc_tnam && $this->pbc_cnam && !$this->sort_no) { $query = self::find()->where(['pbc_tnam' => $this->pbc_tnam, 'pbc_cnam' => $this->pbc_cnam])->max('sort_no'); $this->sort_no = $query ? ++$query : 1; } return parent::beforeSave($insert); }
public function beforeSave($insert) { if (parent::beforeSave($insert)) { if (!$insert && $this->image != $this->oldAttributes['image'] && $this->oldAttributes['image']) { @unlink(Yii::getAlias('@webroot') . $this->oldAttributes['image']); } return true; } else { return false; } }
public function beforeSave($insert) { if (parent::beforeSave($insert)) { if (!$this->settings || !is_array($this->settings)) { $this->settings = self::getDefaultSettings($this->name); } $this->settings = json_encode($this->settings); return true; } else { return false; } }
public function beforeSave($insert) { if (parent::beforeSave($insert)) { $settings = Yii::$app->getModule('populac')->activeModules['article']->settings; $this->short = StringHelper::truncate($settings['enableShort'] ? $this->short : strip_tags($this->text), $settings['shortMaxLength']); if (!$insert && $this->image != $this->oldAttributes['image'] && $this->oldAttributes['image']) { @unlink(Yii::getAlias('@webroot') . $this->oldAttributes['image']); } return true; } else { return false; } }
public function beforeSave($insert) { if (parent::beforeSave($insert)) { if ($insert) { $this->ip = Yii::$app->request->userIP; $this->time = time(); $this->new = 1; $this->status = Yii::$app->getModule('populac')->activeModules['guestbook']->settings['preModerate'] ? self::STATUS_OFF : self::STATUS_ON; } return true; } else { return false; } }