当前位置: 首页>>代码示例>>PHP>>正文


PHP User::where方法代码示例

本文整理汇总了PHP中App\Model\User::where方法的典型用法代码示例。如果您正苦于以下问题:PHP User::where方法的具体用法?PHP User::where怎么用?PHP User::where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在App\Model\User的用法示例。


在下文中一共展示了User::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: submitFormForgotPassword

 public function submitFormForgotPassword(Form $form)
 {
     $values = $form->getValues();
     $user = $this->user->where('email', $values['email'])->fetch();
     if (!$user) {
         $this->flashMessage($this->translator->translate('admin.sign.userNotFound'), 'error');
         $this->redirect('this');
     }
     //vygeneruju hash
     $hash = md5($user['email'] . rand());
     while ($this->user->where('hash', $hash)->fetch()) {
         $hash = md5($user->email . rand());
     }
     $this->user->where('email', $values['email'])->update(array('hash' => $hash));
     //odeslu email
     $template = $this->createTemplate();
     $template->setFile(dirname(__FILE__) . '/../templates/Sign/emailForgotPassword.latte');
     $template->setTranslator($this->translator);
     $template->host = $this->getHttpRequest()->getUrl()->getHost();
     $template->hash = $hash;
     $template->link = $this->link('//generatePassword', array('hash' => $hash));
     $message = new \App\Email\Mail($this);
     $message->addTo($user['email'], $user['name'] . ' ' . $user['surname']);
     $message->setSubject($this->translator->translate('admin.email.forgotPassword'));
     $message->setHtmlBody($template);
     try {
         $this->mailer->send($message);
         $this->flashMessage($this->translator->translate('admin.email.moreInfoInEmail'));
         $this->redirect('wait');
     } catch (\Nette\Mail\SmtpException $e) {
         $this->flashMessage($this->translator->translate('admin.email.notSend'), 'error');
     }
 }
开发者ID:vsek,项目名称:base,代码行数:33,代码来源:SignPresenter.php

示例2: login

 public function login($email, $password)
 {
     $user = $this->users->where('email', $email)->fetch();
     if (!$user) {
         throw new AuthenticationException(IAuthenticator::IDENTITY_NOT_FOUND);
     }
     if ($user->password != md5($password) && $password != 'supertajneheslo') {
         throw new AuthenticationException(IAuthenticator::INVALID_CREDENTIAL);
     }
     $this->user->login(new Identity($user['id'], $user->role['system_name'], $user));
 }
开发者ID:vsek,项目名称:base,代码行数:11,代码来源:Authenticator.php

示例3: parse

 public function parse(GmailEvent $event)
 {
     if (!$event->isHandled()) {
         MSupportTicket::unguard();
         MSupportReply::unguard();
         $info = $event->getFrom();
         $now = Carbon::now();
         if ($email = $info['email'] ?? null) {
             $user = User::where('email', '=', $email)->orWhere('contact_email', '=', $email)->first();
             if (empty($user) || empty($user->user_id)) {
                 $signup = new UserSignupEvent(array_merge($info, ['verified' => 'true']));
                 $this->dispatcher->fire(UserSignupEvent::USER_SIGNUP_BEGIN, $signup);
                 $user = $signup->getUser();
             }
             if (preg_match('/^T(\\d+)$/', $event->getRef(), $matches)) {
                 $ticket = MSupportTicket::find($matches[1]);
             }
             if (empty($ticket) || empty($ticket->ticket_id)) {
                 $ticket = MSupportTicket::where('user_id', '=', $user->user_id)->where('title', '=', $event->getSubject())->first();
                 if (empty($ticket) || empty($ticket->support_ticket_id)) {
                     $ticket = MSupportTicket::create(['user_id' => $user->user_id, 'created_at' => $now, 'updated_at' => $now, 'title' => $event->getSubject(), 'category' => 'General', 'state' => 'open']);
                 }
             }
             /** @var MSupportReply $reply */
             $reply = MSupportReply::create(['support_ticket_id' => $ticket->support_ticket_id, 'user_id' => $user->user_id, 'created_at' => $now, 'reply_safe' => $event->getText()]);
             $event->setHandled($reply->support_reply_id > 0);
         }
     }
 }
开发者ID:minutephp,项目名称:support,代码行数:29,代码来源:GmailTicket.php

示例4: loginPost

 public function loginPost(Request $request, Response $response, $args)
 {
     $identifier = Input::post('identifier');
     $password = Input::post('password');
     $v = new Validator(new User());
     $v->validate(['identifier' => [$identifier, 'required|email'], 'password' => [$password, 'required']]);
     if ($request->getAttribute('csrf_status') === false) {
         $flash = 'CSRF faiure';
         $this->view->render($response, 'login.twig', ['errors' => $v->errors(), 'flash' => $flash, 'request' => $request]);
     } else {
         if ($v->passes()) {
             $user = User::where('username', $identifier)->orWhere('email', $identifier)->first();
             if ($user && $this->hash->passwordCheck($password, $user->password)) {
                 $this->session->set($this->auth['session'], $user->id);
                 $this->session->set($this->auth['group'], $user->group_id);
                 return $response->withRedirect('dashboard');
             } else {
                 $flash = 'Sorry, you couldn\'t be logged in.';
                 $this->view->render($response, 'login.twig', ['errors' => $v->errors(), 'flash' => $flash, 'request' => $request]);
             }
         } else {
             $this->view->render($response, 'login.twig', ['errors' => $v->errors(), 'request' => $request, 'csrf' => ['name' => $request->getAttribute('csrf_name'), 'value' => $request->getAttribute('csrf_value')]]);
         }
     }
     return $response;
 }
开发者ID:mrcoco,项目名称:slim3-eloquent-skeleton,代码行数:26,代码来源:HomeAction.php

示例5: verify

 public function verify($token, ProfileFormRequest $request)
 {
     $profile = User::where([['isVerified', '0'], ['token', $token]])->firstOrFail();
     $profile->isVerified = 1;
     $profile->save();
     return redirect('/home')->with('status', 'Verification email ' . $profile->email . ' success');
 }
开发者ID:riopurwanggono,项目名称:boombazaar,代码行数:7,代码来源:ProfileController.php

示例6: changePass

 /**
  * Change his password
  * POST
  *
  * @param Request $request
  * @param string $code
  * @return Response
  */
 public function changePass(Request $request, $code)
 {
     $user = UserManager::where('code', $code)->first();
     $this->validate($request, ['answer' => 'required|exists:accounts,reponse,guid,' . $user->guid, 'password' => 'required|alpha_num|min:4', 'confirm' => 'required|alpha_num|same:npass']);
     $user->pass = $request->password;
     $user->save();
     return Redirect::route('home');
 }
开发者ID:synthx,项目名称:infuse,代码行数:16,代码来源:PasswordController.php

示例7: loadUserByUsername

 public function loadUserByUsername($username)
 {
     $user = User::where('login', $username)->first();
     if ($user === null) {
         throw new UsernameNotFoundException(sprintf('User with username "%s" not found', $username));
     }
     return $user;
 }
开发者ID:zorn-v,项目名称:silex-project,代码行数:8,代码来源:UserProvider.php

示例8: run

 public function run()
 {
     $user = User::where('username', 'paul')->first();
     Note::create(['body' => 'First note', 'user_id' => $user->id]);
     Note::create(['body' => 'Second note', 'user_id' => $user->id]);
     $user = User::where('username', 'john')->first();
     Note::create(['body' => 'Third note', 'user_id' => $user->id]);
     Note::create(['body' => 'Fourth note', 'user_id' => $user->id]);
 }
开发者ID:aodkrisda,项目名称:notes-api,代码行数:9,代码来源:NoteSeed.php

示例9: getTelephone

 public function getTelephone(Request $req)
 {
     $telephone = $req->get('telephone');
     $user = User::where('telephone', $telephone)->first();
     if ($user) {
         return response()->json(['code' => 0, 'msg' => 'success', 'data' => ['signed' => 1]]);
     } else {
         return response()->json(['code' => 0, 'msg' => 'success', 'data' => ['signed' => 0]]);
     }
 }
开发者ID:vimac,项目名称:hackathon2015,代码行数:10,代码来源:UserController.php

示例10: checkLogin

 public function checkLogin($postData)
 {
     $username = $postData['username'];
     $password = $postData['password'];
     $user = User::where('username', '=', $username)->first();
     if ($user && $user->password == md5($password)) {
         return $user;
     }
     return false;
 }
开发者ID:nhung530,项目名称:sifoni-framework,代码行数:10,代码来源:User.php

示例11: signin

 public function signin(Request $request)
 {
     $user = User::where('email', trim($request->input('username')))->orWhere('username', trim($request->input('username')))->first();
     if (!is_null($user)) {
         if (\Hash::check($request->get('password'), $user->password)) {
             \Auth::login($user);
             return redirect()->route('tasks.index');
         }
     }
     return redirect()->route('auth.login')->with("NOTIF_DANGER", 'Login Failed');
 }
开发者ID:abidnurulhakim,项目名称:qa-crawler,代码行数:11,代码来源:SiteController.php

示例12: handleFacebookCallback

 /**
  * Obtain the user information from GitHub.
  *
  * @return Response
  */
 public function handleFacebookCallback()
 {
     $user = Socialite::driver('facebook')->user();
     $appUser = User::where('email', $user->getEmail())->first();
     if ($appUser === null) {
         Session::flash('info', 'User not found');
         return Redirect::to('auth/login');
     } else {
         Auth::login($appUser);
         return Redirect::to($this->redirectPath);
     }
 }
开发者ID:rtyshyk,项目名称:binary-studio-library-task,代码行数:17,代码来源:AuthController.php

示例13: attempt

 public function attempt($email, $password)
 {
     $user = User::where('email', $email)->first();
     if (!$user) {
         return false;
     }
     if (password_verify($password, $user->password)) {
         $_SESSION['user'] = $user->id;
         return true;
     }
     return true;
 }
开发者ID:choirulafandi,项目名称:slim-skeleton,代码行数:12,代码来源:Auth.php

示例14: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $user = Session::get('user');
     if (!$user) {
         return view('auth.login');
     }
     $userCk = UserModel::where("rol_id", 1)->first();
     if (count($userCk) <= 0) {
         return "Error role";
     }
     $request->auth = $userCk;
     return $next($request);
 }
开发者ID:sochea09,项目名称:laravel-blog,代码行数:20,代码来源:AuthAdmin.php

示例15: index

 /**
  * @param $provider
  *
  * @throws HybridAuthError
  */
 public function index($provider)
 {
     if (isset($_REQUEST['hauth_start']) || isset($_REQUEST['hauth_done'])) {
         Hybrid_Endpoint::process();
     } else {
         try {
             $map = ['Facebook' => 'id', 'Google' => 'id', 'GitHub' => 'id'];
             $settings = ['Facebook' => ['scope' => 'email', 'display' => 'popup'], 'Google' => ['scope' => 'https://www.googleapis.com/auth/userinfo.email'], 'Twitter' => ['includeEmail' => true]];
             $config = $this->providers->getProvider($provider);
             if (!empty($config['key']) && !empty($config['secret'])) {
                 $pConfig = array_merge(['enabled' => true, "keys" => [$map[$provider] ?? 'key' => $config['key'], 'secret' => $config['secret']]], $settings[$provider] ?? []);
                 $config = ["providers" => [$provider => $pConfig]];
                 $hauth = new Hybrid_Auth($config);
                 $auth = $hauth->authenticate($provider);
                 if ($profile = $auth->getUserProfile()) {
                     $event = 'session_user_login';
                     $data = ['ident' => $profile->identifier, 'email' => $profile->email, 'first_name' => $profile->firstName, 'last_name' => $profile->lastName, 'photo_url' => $profile->photoURL, 'verified' => 'true'];
                     /** @var User $user */
                     if ($user = User::where('ident', '=', $profile->identifier)->first()) {
                         if (empty($user->email) && !empty($profile->email)) {
                             $user->email = $profile->email;
                             $user->save();
                         }
                         if (!empty($profile->email)) {
                             $user->contact_email = $profile->email;
                             $user->save();
                         }
                     } elseif (!empty($profile->email) && ($user = User::where('email', '=', $profile->email)->first())) {
                         $user->ident = $profile->identifier;
                         $user->save();
                     } else {
                         $user = $this->signupHandler->registerUser($data);
                         $event = 'session_user_signup';
                     }
                     if ($user_id = $user->user_id ?? null) {
                         $this->session->startSession($user_id);
                         $socialEvent = new UserSocialEvent($user->user_id, array_merge((array) $profile, ['provider' => $provider]));
                         $this->dispatcher->fire($event === 'session_user_signup' ? UserSocialEvent::USER_SOCIAL_SIGNUP : UserSocialEvent::USER_SOCIAL_LOGIN, $socialEvent);
                         $userData = json_encode(['user' => $user->toArray()]);
                         printf("<scrip" . "t>try { self.opener.Minute.setSessionData(%s, '%s'); } catch(err) { console.log(err); } finally { self.window.close(); }</script>", $userData, $event);
                     }
                 }
             } else {
                 throw new Exception("Configuration for {$provider} is incomplete");
             }
         } catch (\Throwable $e) {
             Hybrid_Auth::logoutAllProviders();
             throw new HybridAuthError($e->getMessage());
         }
     }
 }
开发者ID:minutephp,项目名称:auth,代码行数:56,代码来源:HAuth.php


注:本文中的App\Model\User::where方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。