本文整理汇总了PHP中App\Model\User类的典型用法代码示例。如果您正苦于以下问题:PHP User类的具体用法?PHP User怎么用?PHP User使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了User类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: discover
/**
* {@inheritDoc}
*/
public function discover(User $user)
{
$client = clone $this->client;
$client->setDefaultOption('headers/Authorization', 'token ' . $user->getProviderAccessToken('github'));
$request = $client->get('/user/orgs');
$response = $request->send();
$data = $response->json();
$orgRequests = [$client->get('/user/repos')];
foreach ($data as $org) {
$this->logger->debug(sprintf('adding "' . $org['repos_url'] . '" for crawl'));
$orgRequests[] = $client->get($org['repos_url']);
}
$orgResponses = $client->send($orgRequests);
$composerRequests = [];
foreach ($orgResponses as $orgResponse) {
$this->fetchRepos($orgResponse);
if ($orgResponse->hasHeader('link')) {
$link = $orgResponse->getHeader('link');
if (preg_match('/.* <(.+?)\\?page=(\\d+)>; rel="last"$/', $link, $matches)) {
$pagesRequests = [];
for ($i = 2; $i <= $matches[2]; $i++) {
$this->logger->debug(sprintf('adding "' . ($matches[1] . '?page=' . $i) . '" for crawl'));
$pagesRequests[] = $client->get($matches[1] . '?page=' . $i);
}
$pagesResponses = $client->send($pagesRequests);
foreach ($pagesResponses as $pagesResponse) {
$this->fetchRepos($pagesResponse);
}
}
}
}
return $this->getImportableProjects();
}
示例2: new_user
/**
* @inheritdoc
*/
public function new_user($access_token, $return_url, $display_mode)
{
$config = 'default';
$data = $this->provider->request("https://api.vk.com/method/users.get?" . "user_id={$this->user_id}" . "&fields=" . implode(',', $this->pixie->config->get("auth.{$config}.login.vkontakte.permissions", array())) . "&v={$this->pixie->config->get("auth.{$config}.login.vkontakte.api_version", 5.2)}" . "&access_token=" . $access_token);
$data = json_decode($data);
$data = current($data->response);
//Save the new user
$model = new User($this->pixie);
$user = $model->saveOAuthUser('vk' . $data->id, $data->id, 'vkontakte');
$user->first_name = $data->first_name;
$user->last_name = $data->last_name;
$user->save();
//Get the 'pixie' role
/*
$role=$this->pixie->orm->get('role')
->where('name','pixie')
->find();
//Add the 'pixie' role to the user
$fairy->add('roles',$role);
*/
//Finally set the user inside the provider
$this->provider->set_user($user, $access_token);
//And redirect him back.
$this->return_to_url($display_mode, $return_url);
}
示例3: new_user
public function new_user($access_token, $return_url, $display_mode)
{
//Facebook provider allows use to request
//URLs with CURL, but you can use any other way of
//fetching a URL here.
$data = $this->provider->getTwitterUser($access_token);
$data = json_decode($data);
//Save the new user
$model = new User($this->pixie);
$user = $model->saveOAuthUser('tw' . $data->id, $data->id, 'twitter');
$nameParts = preg_split('/\\s+/', $data->name, -1, PREG_SPLIT_NO_EMPTY);
$user->first_name = $nameParts[0];
$user->last_name = $nameParts[1];
$user->save();
//Get the 'pixie' role
/*
$role=$this->pixie->orm->get('role')
->where('name','pixie')
->find();
//Add the 'pixie' role to the user
$fairy->add('roles',$role);
*/
//Finally set the user inside the provider
$this->provider->set_user($user, $access_token);
//And redirect him back.
$this->return_to_url($display_mode, $return_url);
}
示例4: emailReminder
/**
* @testdox Requesting a password reminder adds an item to the Mail Queue.
* @test
*/
public function emailReminder()
{
$user = new User(['username' => 'test']);
$user->save();
$user->sendPasswordReminder();
$this->assertEquals(1, QueuedEmail::count());
}
示例5: upExtDate
private function upExtDate(\App\Model\User $user)
{
if (\Input::file('avatar')) {
$user->avatar()->delete();
\App\Model\File::create(['file' => \Input::file('avatar'), 'type' => 'avatar', 'name' => $user->id]);
}
}
示例6: send
public function send($id, UserMessage $userMessage, User $user)
{
$curUserId = $this->current_user->id;
$userPage = $user->find($id);
$userMsg = $userMessage->where('user_id', '=', $curUserId)->where('user_send_id', '=', $id)->with('user')->with('userSend')->get();
return view('pages.messages.send', compact('userPage', 'userMsg'));
}
示例7: new_user
/**
* @inheritdoc
*/
public function new_user($access_token, $return_url, $display_mode)
{
$data = $this->provider->request("https://www.googleapis.com/plus/v1/people/me?access_token=" . $access_token);
$data = json_decode($data, true);
//Save the new user
$model = new User($this->pixie);
$user = $model->saveOAuthUser('gl' . $data['id'], $data['id'], 'google');
if (is_array($data['emails']) && count($data['emails'])) {
$user->email = $data['emails'][0]['value'];
}
if (is_array($data['name'])) {
$user->first_name = $data['name']['givenName'];
$user->last_name = $data['name']['familyName'];
}
$user->save();
//Get the 'pixie' role
/*
$role=$this->pixie->orm->get('role')
->where('name','pixie')
->find();
//Add the 'pixie' role to the user
$fairy->add('roles',$role);
*/
//Finally set the user inside the provider
$this->provider->set_user($user, $access_token);
//And redirect him back.
$this->return_to_url($display_mode, $return_url);
}
示例8: index
public function index()
{
$this->setTitle("Home");
$user = new User();
$this->view->id = $user->getUsers();
$this->render("index", "layout");
}
示例9: create
/**
* Create and save a new user.
*
* @param array
*/
public function create()
{
// Validate input
$params = array('username' => $this->app->request->post('username'), 'email_address' => $this->app->request->post('email_address'), 'password_hash' => Password::hash($this->app->request->post('password')));
$user = new User($params);
$user->save();
$this->app->redirectTo('home');
}
示例10: save
public function save()
{
$di = $this->getDi();
$em = $di['doctrine']();
$user = new User();
$user->setEntityManager($em);
$user->update();
header('Location: /users');
}
示例11: startup
public function startup()
{
parent::startup();
$this->basePath = $this->template->basePath;
$this->publicPath = $this->basePath . '/www';
$this->user = parent::getUser();
$this->activeMenuItem = 'Homepage';
if ($this->user->isLoggedIn()) {
$this->user->startup();
}
}
示例12: userData
public function userData($userData, $userId)
{
$user = User::find($userId);
//Check if user exist
if (!$user) {
$user = new User();
}
$user->name = $userData['name'];
$user->email = $userData['email'];
$user->password = Hash::make($userData['password']);
$user->save();
return $user;
}
示例13: user
public function user(User $user)
{
$status = $user['status'];
if ($status == userEnum::STATUS_OK) {
$tpl = $user->level == \App\Enum\User::LEVEL_1 ? 'vip' : 'svip';
$user->load(array('gallery' => function ($query) {
return $query->where('status', \App\Enum\User::GALLERY_OK);
}));
return $this->view($tpl)->with('user', $user);
} else {
return \Redirect::back()->with('status', '该会员尚未通过审核');
}
}
示例14: getlist
public function getlist(User $User, Bar $bar)
{
if (!isset($input['email'])) {
return response('請輸入帳號', '403');
} elseif (!isset($input['passwd'])) {
return response('請輸入密碼', '403');
}
if ($User->CheckMember($input['email'], $input['passwd'])) {
$baridlist = $bar->GetList($User->GetUserId);
$baridlist->status = "success";
return response()->json($baridlist);
}
}
示例15: createBetaSignup
/**
* @param User $user
*
* @return BetaSignup
*/
private function createBetaSignup(User $user)
{
$em = $this->get('doctrine')->getManager();
$repo = $em->getRepository('Model:BetaSignup');
if (null === ($beta = $repo->findOneByEmail($user->getEmail()))) {
$beta = new BetaSignup();
$beta->setBetaKey(md5(uniqid()));
$beta->setEmail($user->getEmail());
$beta->setTries($user->getWaitingList());
$beta->setStatus(BetaSignup::STATUS_DEFAULT);
$em->persist($beta);
}
return $beta;
}