本文整理匯總了PHP中models\User::find方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::find方法的具體用法?PHP User::find怎麽用?PHP User::find使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models\User
的用法示例。
在下文中一共展示了User::find方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: actionEdit_status
public function actionEdit_status()
{
$user = new User();
$user->find()->where(['id' => $_POST['userID']])->one();
$user->status = $_POST['status'];
$user->save();
}
示例2: getAvatar
/**
* Override the get_avatar by default from WP
*/
protected static function getAvatar()
{
/*
* We will get the avatar from our models
*/
add_filter('get_avatar', function ($avatar = '', $id_or_email, $size = User::AVATAR_SIZE_DEFAULT, $default = '', $alt = '') {
if (is_numeric($id_or_email)) {
$user_id = (int) $id_or_email;
} elseif (is_string($id_or_email) && ($user = get_user_by('email', $id_or_email))) {
$user_id = $user->ID;
} elseif (is_object($id_or_email) && !empty($id_or_email->user_id)) {
$user_id = (int) $id_or_email->user_id;
}
$user = User::find($user_id);
if (!$user) {
return Utils::getUrlAvatarDefault($size);
}
if (!Utils::isValidStr($alt)) {
$alt = $user->getDisplayName() . ' avatar';
}
$img = '<img alt="' . esc_attr($alt) . '" src="' . $user->getAvatar($size) . '" ';
$img .= 'class="avatar photo" height="' . $size . '" width="' . $size . '">';
return $img;
}, 10, 5);
}
示例3: postUserSettings
public function postUserSettings()
{
$error = false;
if (Request::has('user_id')) {
$user_id = (int) Auth::user()->user_id;
$input_id = (int) Request::input('user_id');
if (Request::input('roles') === null) {
$roles = [];
} else {
$roles = Request::input('roles');
}
if ($user_id === $input_id && !in_array(env('ROLE_ADMIN'), $roles, false)) {
$roles[] = env('ROLE_ADMIN');
$error = true;
}
$editUser = User::find(Request::input('user_id'));
$editUser->roles()->sync($roles);
$editUser->save();
$this->streamingUser->update();
}
if ($error) {
return redirect()->back()->with('error', 'Vous ne pouvez pas enlever le droit admin de votre compte!');
}
return redirect()->back();
}
示例4: getCurrentUser
/**
* Return the instance of the current user, or null if they're not logged
*
* @return User
*/
public static function getCurrentUser()
{
$user = wp_get_current_user();
if ($user->ID) {
return User::find($user->ID);
}
return null;
}
示例5: getUser
/**
* Get the author of the comment
*
* @return User
*/
public function getUser()
{
// In case the user is a non registered User we need the default values from one User object
if (!$this->user_id) {
return new AppUser();
}
return AppUser::find($this->user_id);
}
示例6: actionReg
public function actionReg()
{
$vk_id = $this->app->cookie->get('vk_id');
$user = new User();
$user->find()->where(['vk_id' => $vk_id])->one();
$user->status = $_GET['status'] == 1 ? 2 : 1;
$user->save();
$this->app->parser->render('profile', ['user' => $user]);
}
示例7: getAuthor
/**
* author.php
*/
public function getAuthor()
{
$author = get_queried_object();
$user = User::find($author->ID);
if (!$user) {
return $this->getError();
}
$args = ['user' => $user];
return $this->renderPage('user', $args);
}
示例8: getAuthor
/**
* author.php
*/
public function getAuthor()
{
$author = get_queried_object();
$user = User::find($author->ID);
if (!$user) {
return $this->get404();
}
$args = ['postsWhereKey' => Ajax::AUTHOR, 'postsWhereValue' => $user->ID, 'user' => $user];
return $this->renderPage('base/author', $args);
}
示例9: start
public function start()
{
if ($this->user) {
return $this->app->parser->renderW('main_menu', ['user' => $this->user], false);
} else {
$user = new User();
$user->find()->where(['vk_id' => Cookie::get('vk_id')])->one();
return $this->app->parser->renderW('main_menu', ['user' => $user], false);
}
}
示例10: actionMy
public function actionMy()
{
$vk_id = Cookie::get('vk_id');
$user = new User();
$user->find()->where(['vk_id' => $vk_id])->one();
$user->status = $_GET['status'] == 1 ? 2 : 1;
$user->save();
$region = new GeobaseRegion();
$city = new GeobaseCity();
$regionAll = $region->find()->orderBy('name', 'ASC')->all();
$this->app->parser->render('profile', ['user' => $user, 'regionAll' => $regionAll]);
}
示例11: actionReg
public function actionReg()
{
$vk_id = Cookie::get('vk_id');
$user = new User();
$user->find()->where(['vk_id' => $vk_id])->one();
$user->status = $_GET['status'] == 1 ? 2 : 1;
$user->save();
Header::redirect('/vk2/profile/my', true, 302);
/*$this->app->parser->render('profile',
[
'user' =>$user,
]);*/
}
示例12: getRenderLanguage
/**
*
* @param string $user_ID
*/
public function getRenderLanguage($user_ID = false)
{
if (!$user_ID) {
global $user_ID;
}
$user = User::find($user_ID);
// Format the list
$userLang = $user->getLang();
foreach (I18n::getAllLangAvailable() as $t) {
$languages[] = ['value' => $t, 'text' => I18n::transu('lang_' . $t), 'selected' => $userLang == $t];
}
$args = ['user' => $user, 'KEY_LANGUAGE' => User::KEY_LANGUAGE, 'languages' => $languages];
return $this->render('backend/user/_lang', $args);
}
示例13: modelAction
/**
* @param int $currentPage
* @param int $limit
*/
public function modelAction($currentPage = 10, $limit = 10)
{
$startMemoryUsage = memory_get_peak_usage();
$startTime = microtime(true);
$currentPage = max(1, (int) $currentPage);
$limit = max(1, (int) $limit);
$users = \Models\User::find();
$paginator = new \Phalcon\Paginator\Adapter\Model(["data" => $users, "limit" => $limit, "page" => $currentPage]);
$paginator->getPaginate();
$finishTime = microtime(true);
$finishMemoryUsage = memory_get_peak_usage();
echo "Memory peak usage: ";
echo $finishMemoryUsage - $startMemoryUsage . "\n";
echo "Time: ";
echo $finishTime - $startTime . "\n";
}
示例14: authenticate
/**
* Authenticats the user
* @param Request Object - contains email and password
*
* @return Nothing
*/
public function authenticate(Application $app, Request $request)
{
$email = $request->get('email');
$password = $app->escape($request->get('password'));
if ($email && $password) {
$user = new User($app);
$user_info = $user->find('user', array('email' => $email, 'password' => md5($password)));
if ($user_info) {
$app['session']->set('user', array('id' => $user_info[0]));
return $app->redirect($request->getBaseUrl() . '/message/tweets');
} else {
return $app->render('index.php.twig', array('error_message' => "Invalid Credentials. Please try again!"));
}
} else {
return $app->render('index.php.twig', array('error_message' => "Valid Email and password are required!"));
}
}
示例15: runUpdate
protected function runUpdate()
{
$user = User::find(1);
Auth::login($user);
$fakeNow = Carbon::createFromFormat('Y-m-d H:i:s', '2015-01-01 01:00:00');
Carbon::setTestNow($fakeNow);
$user->name = "Shifra";
$user->save();
$user = $user->fresh();
$fakeNow = Carbon::createFromFormat('Y-m-d H:i:s', '2015-01-02 00:00:00');
Carbon::setTestNow($fakeNow);
$user->email = 'edited@gmail.com';
$user->save();
return $user;
}