本文整理汇总了PHP中Model\User::find方法的典型用法代码示例。如果您正苦于以下问题:PHP User::find方法的具体用法?PHP User::find怎么用?PHP User::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model\User
的用法示例。
在下文中一共展示了User::find方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createTeamAction
public function createTeamAction()
{
$array_id = array();
$coach = array('login' => $_POST['coach']);
$coach = Model\User::find($coach);
$chef = array('login' => $_POST['chef']);
$chef = Model\User::find($chef);
$array_id[] = $chef->getId();
$student1 = array('login' => $_POST['student1']);
$student1 = Model\User::find($student1);
$array_id[] = $student1->getId();
if ($_POST['student2']) {
$student2 = array('login' => $_POST['student2']);
$student2 = Model\User::find($student2);
$array_id[] = $student2->getId();
}
if ($_POST['student3']) {
$student3 = array('login' => $_POST['student3']);
$student3 = Model\User::find($student3);
$array_id[] = $student3->getId();
}
//On récupère le dernière ID group utilisé
$id_group = $this->getLastId();
//On relie les étudiants pour former le groupes
$this->insertNewGroup($coach, $array_id, $id_group);
$this->updateGroupId($id_group, $array_id);
$this->createProject($id_group, $coach->getId(), $_POST['nomprojet']);
$this->redirect('equipe');
}
示例2: indexAction
public function indexAction()
{
// init
$this->init();
// get users
$this->view->userArray = \Model\User::find();
// set main view
$this->view->setMainView('block-module-users/admin-index');
}
示例3: validate
protected function validate()
{
$this->fields[] = 'user_id';
// hack
$vals = array('mail' => $this->values['mail'], 'password' => $this->values['password']);
if ($user = Model\User::find($vals)) {
return $this->values['user_id'] = $user->getPk();
} else {
$this->errors['email'][] = 'Mauvais nom de compte / mot de passe';
}
}
示例4: findSavingsAccountObs
function findSavingsAccountObs($userId)
{
return Observable::just($userId)->skipWhile(function ($input) {
return empty($input);
})->map(function ($userId) {
return User::find($userId);
})->flatMap(function (User $user) {
return Observable::fromArray(Account::query('user_id', $user->getId()));
})->takeWhile(function (Account $account) {
return $account->getType() === 'SAVINGS';
});
}
示例5: homeAction
public function homeAction()
{
$meeting = array();
$vals = array('id' => $_SESSION['user_id']);
$user = Model\User::find($vals);
$vals = array('id_group' => $_GET['projet']);
$projet = Model\Projet::find($vals);
$id_group = $projet['id_group'];
$sql = "SELECT * FROM meeting WHERE id_group = {$id_group} ORDER BY updated_at";
$meeting = $this->db->query($sql);
$meeting = $meeting->fetchAll();
return array('user' => $user, 'projet' => $projet, 'meeting' => $meeting);
}
示例6: init
public function init($uid)
{
$user = Model\User::find($uid);
if ($user) {
$this->uid = $uid;
$this->nama = $user->nama;
$this->role = $user->role;
$grup = Model\Grup::where('nama', $user->role)->first();
if ($grup) {
$this->hakAkses = json_decode($grup->hak_akses, true);
}
}
}
示例7: helloMathis
public static function helloMathis($app)
{
$ajout = false;
$username = 'mathis';
$user = User::find($username);
// Si $user n'est pas set, c'est qu'il n'y a rien et on ajoute donc en base !
if (!isset($user)) {
$user = new User();
$user->name = $username;
$user->save();
$ajout = true;
}
$app->render('user.html.twig', array('ajout' => $ajout, 'autre' => 'ahah !', 'name' => $user->name));
}
示例8: login
function login()
{
$app = get_app();
$is_debug = get_config('debug');
//GET
if ($app->request()->isGet()) {
if (!$is_debug) {
$app->render('login.php');
} else {
$app->render('debug.php');
}
}
//POST
if ($app->request()->isPost()) {
/* if (empty($_SESSION['captcha']) || trim(strtolower($_REQUEST['captcha'])) != $_SESSION['captcha']) {
$app->flashNow('errors',array('验证码错误!'));
$app->render('login.php');
}
else{ */
$account = $app->request()->post('account');
$password = $app->request()->post('password');
$user = User::find('first', array('conditions' => array(' account = ? AND password = ?', $account, md5($password))));
if (!empty($user)) {
$_SESSION['is_logged'] = true;
$_SESSION['account'] = $user->account;
$_SESSION['username'] = $user->username;
$_SESSION['user_id'] = $user->id;
$_SESSION['role_id'] = $user->role_id;
$_SESSION['group_id'] = $user->group_id;
$_SESSION['team_id'] = $user->team_id;
redirect('/');
} else {
$app->flashNow('errors', array('错误的用户名或密码!'));
$app->render('login.php');
}
/* } */
}
}
示例9: scopeOnlyAllowEditor
public function scopeOnlyAllowEditor($query, $user_id = 0)
{
$user = $user_id ? Model\User::find($user_id) : sentinel()->getUser();
return $query->whereHas('categories', function ($query) use($user) {
return $query->whereIn($query->getModel()->getTable() . '.id', $user->editorcategory->pluck('id')->toArray());
});
}
示例10: index
function index()
{
$app = get_app();
$users = User::find('all', array('order' => 'id desc'));
render_with_layout('misc.php', 'Users/index.php', compact('users'));
}
示例11: scopeOnlyAllowEditor
public function scopeOnlyAllowEditor($query, $user_id = 0)
{
$user = $user_id ? Model\User::find($user_id) : sentinel()->getUser();
return $query->whereIn('id', $user->editorcategory->pluck('id')->toArray());
}
示例12: getLoginContext
public static function getLoginContext()
{
$config = array('token' => '_user_', 'path' => '/', 'sign_salt' => function ($context) {
do {
if (!isset($context['id']) || !$context['id']) {
break;
}
if (!($user = \Model\User::find($context['id']))) {
break;
}
// 以用户密码作为salt
return $user->passwd;
} while (false);
// 如果用户不存在,就用固定的随机字符串
return 'fdq0rj32jr0dsjfwf';
});
$handler = new \Lysine\CookieContextHandler($config);
$expire = (int) $handler->get('expire');
if ($expire && $expire < time()) {
$handler->clear();
}
return $handler;
}
示例13: homeAction
public function homeAction()
{
$vals = array('id' => $_SESSION['user_id']);
$user = Model\User::find($vals);
return array('user' => $user);
}
示例14: count
echo 'Completed', PHP_EOL;
}));
println('Example 3 - Just and Map');
\Rx\Observable::just(\Model\User::all())->map(function ($results) {
return count($results);
})->subscribe($stdoutObserver());
println('Example 4 - Get all accounts of type SAVING');
\Rx\Observable::fromArray(\Model\Account::all())->filter(function (Account $account) {
return $account->getType() === 'SAVINGS';
})->map(function (Account $savingsAccount) {
return $savingsAccount->getBalance();
})->subscribe($stdoutObserver());
println('Withdraw 1000 from Luis SAVINGS account');
$id = 1;
Observable::just($id)->map(function ($userId) {
return User::find($userId);
})->doOnNext(function (User $user) {
printf("Found user: %s \n", $user->getEmail());
})->flatMap(function (User $user) {
return Observable::fromArray(Account::query('user_id', $user->getId()));
})->takeWhile(function (Account $account) {
return $account->getType() === 'SAVINGS';
})->doOnNext(function (Account $account) {
printf("Found savings account. Current balance: %d \n", $account->getBalance());
})->map(function (Account $account) {
return $account->withdraw(1000)->save();
})->subscribe(new Observer\CallbackObserver(function ($account) {
printf("New account balance: %d \n", $account->getBalance());
}, function (Exception $ex) {
print 'Error: ' . $ex->getMessage();
}, function () {