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


PHP User::findFirst方法代碼示例

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


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

示例1: indexReturnsAllFollowers

 public function indexReturnsAllFollowers(FunctionalTester $I)
 {
     $user = User::findFirst();
     $I->sendGet($this->endpoint . '/' . $user->id);
     $I->seeResponseCodeIs(200);
     $I->seeResponseIsJson();
     $I->assertEquals(count($user->getFollowers()), count(json_decode($I->grabResponse())->items));
     $I->seeResponseContainsJson($user->getFollowers()->toArray());
 }
開發者ID:soutoner,項目名稱:api-desconecta,代碼行數:9,代碼來源:IndexCest.php

示例2: deleteSuccessful

 public function deleteSuccessful(FunctionalTester $I)
 {
     $user = User::findFirst();
     // We send get
     $I->sendDELETE($this->endpoint . '/' . $user->id);
     $I->seeResponseCodeIs(200);
     $I->seeResponseIsJson();
     $I->dontSeeRecord('App\\Models\\User', $user);
 }
開發者ID:soutoner,項目名稱:api-desconecta,代碼行數:9,代碼來源:DeleteCest.php

示例3: updateReponseWithErrors

 public function updateReponseWithErrors(FunctionalTester $I)
 {
     $id = 1;
     $I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
     $I->sendPUT('/api/v1/users/' . $id, 'email=' . User::findFirst(2)->email);
     $I->seeResponseCodeIs(409);
     $I->seeResponseIsJson();
     $I->seeResponseContains('messages');
     $I->seeResponseContains('email');
     $I->assertGreaterThan(0, count(json_decode($I->grabResponse())->messages));
 }
開發者ID:soutoner,項目名稱:api-desconecta,代碼行數:11,代碼來源:BaseControllerCest.php

示例4: updateUnsuccessfulReturnErrors

 public function updateUnsuccessfulReturnErrors(FunctionalTester $I)
 {
     $id = 1;
     $original_name = User::findFirst($id)->name;
     $updated_param = ['name' => ''];
     $I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
     $I->sendPUT($this->endpoint . '/' . $id, 'name=' . $updated_param['name']);
     $I->seeResponseCodeIs(409);
     $I->seeResponseIsJson();
     $json_response = json_decode($I->grabResponse());
     $I->assertGreaterThan(0, count($json_response->messages));
     $I->assertEquals($original_name, User::findFirst($id)->name);
 }
開發者ID:soutoner,項目名稱:api-desconecta,代碼行數:13,代碼來源:UpdateCest.php

示例5: initialize

 public function initialize()
 {
     // Авторизация
     if ($this->session->has('login') || $this->cookies->has('login')) {
         if (!$this->session->has('user-name')) {
             $login = $this->session->has('login') ? $this->session->get('login') : $this->cookies->get('login');
             $user = User::findFirst(["name = '" . $login . "'"]);
             $this->session->set('user-name', $user->name);
             $this->session->set('user-id', $user->id);
         }
     } elseif ($this->router->getControllerName() != 'auth') {
         return $this->response->redirect('auth/login');
     }
     if ($this->request->isAjax()) {
         $this->view->disable();
         $this->_isJsonResponse = true;
         $this->response->setContentType('application/json', 'UTF-8');
     }
 }
開發者ID:aciden,項目名稱:generator,代碼行數:19,代碼來源:IndexController.php

示例6: loginAction

 public function loginAction()
 {
     if ($this->request->isPost()) {
         if ($this->security->checkToken()) {
             $login = $this->request->getPost('login');
             $password = $this->request->getPost('password');
             $remembe = $this->request->getPost('remembe');
             $user = User::findFirst(["name = '" . $login . "'"]);
             if (!empty($user) && $this->security->checkHash($password, $user->pass)) {
                 $this->session->set('login', $user->name);
                 if ($remembe == 'on') {
                     $this->cookies->set('login', $user->name, time() + 15 * 86400);
                 }
                 return $this->response->redirect('index');
             } else {
             }
         }
     }
 }
開發者ID:aciden,項目名稱:generator,代碼行數:19,代碼來源:AuthController.php

示例7: _before

 public function _before(FunctionalTester $I)
 {
     $this->relationship = ['user_id' => User::findFirst()->id, 'follower_id' => User::findFirst(["email = '" . UserSeeder::DbSeeds()[1]['email'] . "'"])->id];
     $I->haveRecord('App\\Models\\Relationships\\Follower', $this->relationship);
 }
開發者ID:soutoner,項目名稱:api-desconecta,代碼行數:5,代碼來源:DeleteCest.php

示例8: rrppIdMustBeUnique

 public function rrppIdMustBeUnique(FunctionalTester $I)
 {
     $this->model->rrpp_id = User::findFirst('rrpp_id IS NOT NULL')->rrpp_id;
     $I->assertFalse($this->model->save());
 }
開發者ID:soutoner,項目名稱:api-desconecta,代碼行數:5,代碼來源:UserCest.php


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