本文整理汇总了PHP中app\models\Users::findByUsername方法的典型用法代码示例。如果您正苦于以下问题:PHP Users::findByUsername方法的具体用法?PHP Users::findByUsername怎么用?PHP Users::findByUsername使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Users
的用法示例。
在下文中一共展示了Users::findByUsername方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getUser
/**
* Finds user by [[username]]
*
* @return User|null
*/
public function getUser()
{
if ($this->_user === false) {
$this->_user = Users::findByUsername($this->username);
}
return $this->_user;
}
示例2: getUser
/**
* Finds user by [[username]]
*
* @return User|null
*/
protected function getUser()
{
if ($this->_user === null) {
$this->_user = Users::findByUsername($this->username);
}
return $this->_user;
}
示例3: actionAuthenticate
public function actionAuthenticate()
{
$request = Yii::$app->request;
$username = $request->post('username');
$user = Users::findByUsername($username);
// Just create the user if not found
if (!$user) {
$user = new Users();
$user->username = $username;
$user->save();
}
echo json_encode(['auth' => $user->getId() ? true : false, 'id' => $user->id, 'username' => $user->username]);
}
示例4: actionGetScore
public function actionGetScore()
{
$request = Yii::$app->request;
$username = $request->post('username');
$testId = $request->post('testId');
$user = Users::findByUsername($username);
$test = Test::findOne($testId);
if (!$user || !$test) {
return ['success' => false, 'message' => 'Eiher the user or test was not found'];
}
return ['success' => true, 'score' => $test->score];
}
示例5: getBaseUrl
});
Uploads::applyFilter('save', function ($self, $params, $chain) {
if ($params['data']) {
$params['entity']->set($params['data']);
$params['data'] = array();
}
if (!$params['entity']->id) {
$params['entity']->created = date('Y-m-d H:i:s');
}
return $chain->next($self, $params, $chain);
});
use lithium\util\Validator;
Validator::add('usernameTaken', function ($value) {
$success = false;
if (strlen($value) != 0) {
$success = count(Users::findByUsername($value)) == 0 ? false : true;
}
return !$success;
});
use lithium\core\Libraries;
Libraries::add('upload', array('path' => LITHIUM_APP_PATH . '/libraries/_source/upload/'));
Libraries::add('captcha', array('path' => LITHIUM_APP_PATH . '/libraries/_source/captcha/', 'webroot' => LITHIUM_APP_PATH . '/libraries/_source/captcha/', "bootstrap" => "securimage.php"));
define('_INSTALL', file_exists($_SERVER['DOCUMENT_ROOT'] . "/install") ? '1' : '0');
function getBaseUrl()
{
$protocol = isset($_SERVER["HTTPS"]) && $_SERVER['HTTPS'] != "off" ? "https" : "http";
return $protocol . "://" . $_SERVER['HTTP_HOST'];
}
use lithium\core\Environment;
Environment::is(function ($request) {
return in_array($request->env('SERVER_ADDR'), array('::1', '127.0.0.1')) ? 'development' : 'production';