當前位置: 首頁>>代碼示例>>PHP>>正文


PHP User::findFirst方法代碼示例

本文整理匯總了PHP中App\Model\User::findFirst方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::findFirst方法的具體用法?PHP User::findFirst怎麽用?PHP User::findFirst使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在App\Model\User的用法示例。


在下文中一共展示了User::findFirst方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getDetailsForIdentity

 protected function getDetailsForIdentity($identity)
 {
     if (array_key_exists($identity, $this->detailsCache)) {
         return $this->detailsCache[$identity];
     }
     $details = User::findFirst((int) $identity);
     $this->detailsCache[$identity] = $details;
     return $details;
 }
開發者ID:redound,項目名稱:phalcon-rest-boilerplate,代碼行數:9,代碼來源:Service.php

示例2: authenticate

 public function authenticate()
 {
     $username = $this->request->getUsername();
     $password = $this->request->getPassword();
     $session = $this->authManager->loginWithUsernamePassword(\App\Auth\UsernameAccountType::NAME, $username, $password);
     $transformer = new \App\Transformers\UserTransformer();
     $transformer->setModelClass('App\\Model\\User');
     $user = $this->createItemResponse(\App\Model\User::findFirst($session->getIdentity()), $transformer);
     $response = ['token' => $session->getToken(), 'expires' => $session->getExpirationTime(), 'user' => $user];
     return $this->createArrayResponse($response, 'data');
 }
開發者ID:redound,項目名稱:phalcon-rest-boilerplate,代碼行數:11,代碼來源:UserController.php

示例3: login

 public function login($data)
 {
     /** @var \Phalcon\Security $security */
     $security = Di::getDefault()->get(Services::SECURITY);
     $email = $data[Manager::LOGIN_DATA_EMAIL];
     $password = $data[Manager::LOGIN_DATA_PASSWORD];
     /** @var \App\Model\User $user */
     $user = \App\Model\User::findFirst(['conditions' => 'email = :email:', 'bind' => ['email' => $email]]);
     if (!$user) {
         return null;
     }
     if (!$security->checkHash($password, $user->password)) {
         return null;
     }
     return (string) $user->id;
 }
開發者ID:redound,項目名稱:phalcon-rest-boilerplate,代碼行數:16,代碼來源:EmailAccountType.php


注:本文中的App\Model\User::findFirst方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。