public function beforeSave($insert) { if ($insert) { $this->setAttribute('create_time', \common\helpers\DateHelper::now()); $this->setAttribute('status', self::CREDIT_STATUS_OK); } }
public function beforeSave($insert) { if ($insert) { $this->setAttribute('create_time', \common\helpers\DateHelper::now()); } return parent::beforeSave($insert); }
/** * 重载插入数据操作 * @param bool $insert */ protected function _beforeSave($insert) { parent::_beforeSave($insert); //插入前添加默认属性 if ($insert === true) { $this->setAttribute('create_time', \common\helpers\DateHelper::now()); $this->setAttribute('status', self::COMMENT_STATUS_OK); } }
/** * 重载beforeSave新加功能 * @param bool $insert */ private function _beforeSave($insert) { //插入 if ($insert) { $this->setAttribute('create_time', \common\helpers\DateHelper::now()); $this->setAttribute('status', 0); } $this->setAttribute('update_time', \common\helpers\DateHelper::now()); }
public function beforeSave($insert) { if ($insert) { $this->setAttribute('create_time', \common\helpers\DateHelper::now()); $this->setAttribute('user_type', self::USER_TYPE_COMMON); } $this->setAttribute('modify_time', \common\helpers\DateHelper::now()); return parent::beforeSave($insert); }
/** * 重载插入数据操作 * @param bool $insert */ protected function _beforeSave($insert) { parent::_beforeSave($insert); //插入前添加默认属性 if ($insert === true) { $this->setAttribute('create_time', \common\helpers\DateHelper::now()); $this->setAttribute('act_status', self::ACT_STATUS_DRAFT); //设置_id } }
public function sign($user_id) { if (!is_numeric($user_id)) { return ErrorConstant::PARAM_ERROR; } //检查用户当天是否已经签到 $_sign = SignModel::findOne(['user_id' => $user_id, 'create_time' => ['$gte' => \common\helpers\DateHelper::startDate(), '$lte' => \common\helpers\DateHelper::endDate()]]); if ($_sign !== null) { return ErrorConstant::USER_IS_SIGNED; } //签到 $_sign = new SignModel(); $_sign->user_id = $user_id; if ($_sign->insert()) { $this->OnAfterSign(); return true; } return ErrorConstant::USER_SIGN_FAILED; }
/** * 解除好友关系 * @param $user_id * @param $friend_id * @return int */ public function releaseFriend($user_id, $friend_id) { if (!is_numeric($user_id) || !is_numeric($friend_id)) { return ErrorConstant::PARAM_ERROR; } if (UserModel::findOne($friend_id === null)) { return ErrorConstant::USER_NOT_EXISTS; } //判断是已经是好友关系 $_relation = FriendModel::isFriend($user_id, $friend_id); if ($_relation === false) { return ErrorConstant::FRIEND_NOT_EXISTS; } switch ($_relation->status) { case FriendModel::RELATION_STATUS_IN_HAND: return ErrorConstant::FRIEND_IN_HAND; default: break; } $_relation->status = FriendModel::RELATION_STATUS_RELEASE; $_relation->release_time = \common\helpers\DateHelper::now(); $_relation->deleted = FriendModel::IS_DELETED; if ($_relation->update() === false) { return ErrorConstant::RELEASE_FRIEND_FAILED; } $this->triggerFriendEvent(self::AFTER_RELEASE_FRIEND, $user_id, $friend_id); return true; }