public static function find($referenceId) { $transaction = new self(array('reference_id' => $referenceId)); $transaction->refresh(); return $transaction; }
/** * Generate new token for user * * @param integer $userId * @param integer $expiredSeconds * @return boolean|common\models\UserToken */ public static function createForUser(IdentityInterface $user, $seconds = 0, $remember = false, $verifyIP = false) { $seconds = intval($seconds); if (!$seconds) { $seconds = self::EXPIRE_DEFAULT_SECONDS; } $userToken = new self(['scenario' => self::SCENARIO_CREATE_FOR_USER]); $userToken->token = Yii::$app->getSecurity()->generateRandomString(); $userToken->expired_at = new Expression('DATE_ADD(NOW(), INTERVAL ' . $seconds . ' SECOND)'); $userToken->frozen_expire = !$remember; $userToken->verify_ip = (bool) $verifyIP; $userToken->updateClientInfo(); if ($userToken->save()) { $userToken->link('user', $user); $userToken->refresh(); return $userToken; } else { return false; } }
public static function find($token) { $paymentMethod = new self(array('payment_method_token' => $token)); $paymentMethod->refresh(); return $paymentMethod; }
public static function create($baseurl) { $obj = new self(); if (preg_match('/^(http[s]?:\\/\\/.*?)[\\/]?$/', $baseurl, $matches) == 0) { throw new RepositoryUnreachableOrInvalid(); } $obj->baseurl = $matches[1]; $obj->refresh(True); $tx = new Transaction(); try { global $db_con; qdb("INSERT INTO `ratatoeskr_repositories` () VALUES ()"); $obj->id = $db_con->lastInsertId(); $obj->save(); $tx->commit(); } catch (Exception $e) { $tx->rollback(); throw $e; } return $obj; }