当前位置: 首页>>代码示例>>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;未经允许,请勿转载。