function save() { parent::save(); $cache = Project::getDatabaseManager()->getCache(); if ($cache !== null) { } }
public function save(array $options = []) { if (isset($this->password) && strcmp($this->getOriginal('password'), $this->password) !== 0) { $this->password = self::makePass($this->password); } parent::save($options); }
/** * Extending save method to add author before save * * @return void * @author Gat **/ public function save(array $options = array()) { // Add author if not set if (!isset($this->author_id)) { $this->author_id = Auth::user()->id; } parent::save($options); }
/** * Extending save method to add encoder before save * * @return void * @author Gat **/ public function save(array $options = array()) { // Add encoder if not set if (!isset($this->secretary_id)) { $this->secretary_id = Auth::user()->id; } parent::save($options); }
function save() { // Убираем текстовые поля unset($this->_data['country'], $this->_data['state'], $this->_data['city']); // ---------------------- $result = parent::save(); return $result; }
function save() { parent::save(); $cache = Project::getDatabaseManager()->getCache(); if ($cache !== null) { $cache->delete($this->getCachePrefix('_list_user_type_' . $this->user_type_id)); $cache->delete($this->getCachePrefix('_list_controller_user_type_' . $this->user_type_id)); $cache->delete($this->getCachePrefix('_list_controller_action_user_type_' . $this->user_type_id . $this->controller_id . $this->action_id)); } }
/** * 重写save方法,修改角色权限信息 * @param mixed|string $requestData * @return bool */ public function save($requestData) { //修改角色信息 $rst = parent::save(); if ($rst === false) { return false; } //修改角色权限信息 $rst = $this->handleRolePermission($requestData['id'], $requestData['permission_ids']); if ($rst === false) { return false; } return $rst; }
/** * Perform actions after new user has been stored * @param BaseModel $user User that has just been stored */ public function onStore($user) { // Make the first user SuperAdmin if (count(User::all()) == 1 && !$user->hasRole('Super Admin')) { $user->roles()->attach(Role::where('name', '=', 'Super Admin')->firstOrFail()); Log::debug(e($user->username) . ': Assigning "Super Admin" role as first user to log in', [$user->api_key]); } // Generate an API key if the user does not have one if (empty($user->api_key)) { $user->api_key = md5(str_random(32)); $user->save(); Log::debug(e($user->username) . ': Generating API key', [$user->api_key]); } }
/** * @return mixed */ public function save() { $id = parent::save(); $cashAccounts = Table_Cashaccounts::getInstance(); $select = $cashAccounts->select()->where('resident_id = ?', $id); $rows = $cashAccounts->fetchAll($select); if ($rows->count() > 0) { // found needs update $rows->current()->save(); } else { // not found // means new resitend -> create an cash account $cashAccounts->createRow(array('resident_id' => $id))->save(); } return $id; }
public function save($postData) { //保存文章信息 $result = parent::save(); if ($result === false) { return fasle; } //保存文章内容 >> 删除原有,在添加 $articleContent = M('ArticleContent'); $id = $postData['id']; //删除 $rst = $articleContent->where('article_id=' . $id)->delete(); if ($rst === false) { $this->error = '删除文章内容失败'; return false; } //添加 $rst = $articleContent->add(array('article_id' => $id, 'content' => $postData['content'])); if ($rst === false) { $this->error = '添加文章内容失败'; return false; } return $result; }
public function changeStatus($id, $status = -1) { //开启事物 $this->startTrans(); $goods_data = array('status' => $status, 'id' => array('in', $id)); $goods_intro_data = array('status' => $status, 'goods_id' => array('in', $id)); if ($status == -1) { $data['name'] = array('exp', "CONCAT(name,'_del')"); } //删除goods表数据 $rst = parent::save($goods_data); if ($rst === false) { $this->rollback(); $this->error = '删除商品失败!'; return false; } //删除goods_intro表数据 $model = M('GoodsIntro'); $result = $model->save($goods_intro_data); if ($result === false) { $this->rollback(); $this->error = '删除描述失败!'; return false; } //删除goods_member_price表信息 $model = D('GoodsMemberPrice'); //先删除id对应的数据 $result = $model->where("goods_id={$id}")->delete(); if ($result === false) { $this->rollback(); $this->error = '删除分级价格失败!'; return false; } $this->commit(); return $rst; }
/** * Save the model. * * @param array $options * @return mixed */ public function save(array $options = []) { \Cache::forever(self::getCacheKey($this->localizable_id, $this->region_code), json_encode($this->localizations)); parent::save($options); }
/** * 修改密码 * @param $requestData * @return bool */ public function updatePassword($requestData) { //验证就密码是否正确 $userinfo = login(); $row = $this->field('password,salt')->where(array('id' => $userinfo['id']))->find(); if (myMd5($requestData['old_password'], $row['salt']) != $row['password']) { $this->error = '密码错误'; return false; } //修改密码 $data = array('id' => $userinfo['id'], 'password' => myMd5($requestData['password'], $row['salt'])); return parent::save($data); }
/** * 重写修改 * @param mixed|string $postData * @return bool */ public function save($postData) { // dump($postData);exit; $this->startTrans(); $id = $postData['id']; //1> 修改到goods表中 $this->handleStatus(); $result = parent::save(); if ($result === false) { $this->rollback(); return false; } //2> 修改到goods_intro表中 $result1 = $this->handleIntro($id, $postData['intro']); if ($result1 === false) { return fasle; } //3> 修改到goods_member_price表中 $result1 = $this->handleMemberPrice($id, $postData['memberPrices']); if ($result1 === false) { return fasle; } //4> 处理商品相册 if (isset($postData['goods_gallerys'])) { $result1 = $this->handleGallery($id, $postData['goods_gallerys']); if ($result1 === false) { return fasle; } } //>5处理相关文章 if (isset($postData['article_ids'])) { $result1 = $this->handleArticle($id, $postData['article_ids']); if ($result1 === false) { return fasle; } } //6> 修改到goods_attribute表中 $result1 = $this->updateAttribute($id, $postData['attribute']); if ($result1 === false) { return fasle; } $this->commit(); return $result; }
public function save() { $errors = []; // Validation if (!self::isEmailValid($this->email)) { $errors[] = 'Email is Invalid'; } if (isset($this->password) && !self::isPasswordValid($this->password)) { $errors[] = 'Password is Invalid'; } $this->setStripeData($this->stripe_data); // convert to JSON $this->addErrors($errors); // add any errors // Add Secret Fields to Field List if (isset($this->password)) { $this->modelFields[] = 'password'; } // Hash the Password (encrypt) if (isset($this->password)) { $this->password = self::hashPassword($this->password); } // Validation Outcome? return count($errors) ? false : parent::save(); }
public function save() { $sql = "UPDATE questions_cat " . "SET `sortfield` = `sortfield`+1 " . "WHERE `sortfield` >= ?d"; Project::getDatabase()->query($sql, $this->sortfield); parent::save(); }
/** * Update "current" translation object * @param BaseModel $translate */ public function updateTranslation($translate) { foreach ($this->translateAttributes as $attr) { $translate->{$attr} = $this->owner->{$attr}; } $translate->save(false); }