本文整理汇总了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());
}
示例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);
}
示例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));
}
示例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);
}
示例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');
}
}
示例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 {
}
}
}
}
示例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);
}
示例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());
}