本文整理匯總了PHP中models\User::where方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::where方法的具體用法?PHP User::where怎麽用?PHP User::where使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models\User
的用法示例。
在下文中一共展示了User::where方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: store
/**
* Store a newly created resource in storage.
*
* @return Response
*/
public function store()
{
$input = Input::all();
$conversation = Conversation::create(['subject' => $input['subject']]);
$message = Message::create(['conversation_id' => $conversation->id, 'user_id' => Auth::user()->id, 'body' => $input['message']]);
$sender = Participant::create(['conversation_id' => $conversation->id, 'user_id' => Auth::user()->id]);
if ($this->input->has('recipient')) {
$recipient = User::where('email', $input['recipient'])->first();
Participant::create(['conversation_id' => $conversation->id, 'user_id' => $recipient->id]);
}
return Redirect::route('conversations.index');
}
示例2: showProfile
public function showProfile($user)
{
$u = User::where('pseudo', '=', $user)->first();
if (is_null($u)) {
App::abort(404);
}
if (Auth::user() == $u) {
$editable = true;
} else {
$editable = false;
}
$expData = ExperienceManager::getExpInfo($u);
return view('user.showProfile', ['user' => $u, 'streamer' => $u->isStreamer(), 'editable' => $editable, 'level' => $expData['level'], 'progression' => $expData['progression']]);
}
示例3: login
public static function login($username, $password)
{
$error = ['user' => FALSE, 'password' => FALSE];
$logged = FALSE;
$cookie = ['username' => '', 'email' => ''];
try {
$user = User::where('username', $username)->firstOrFail();
} catch (Exception $e) {
$error["user"] = TRUE;
echo "username not found";
return $error;
}
$password = hash('sha256', $password . $user->salt);
if ($password == $user->password) {
$logged = TRUE;
$cookie['username'] = $username;
$cookie['email'] = $user->email;
$_SESSION['user'] = $cookie;
} else {
$error['password'] = TRUE;
echo "password doesn't match";
return $error;
}
}
示例4: checkLogin
public function checkLogin()
{
if (empty($_SESSION)) {
session_start();
}
empty($_SESSION['old']) ?: ($_SESSION['old'] = []);
empty($_SESSION['error']) ?: ($_SESSION['error'] = []);
$rules = ['email' => FILTER_VALIDATE_EMAIL, 'password' => FILTER_SANITIZE_STRING];
$sanitize = filter_input_array(INPUT_POST, $rules);
$error = false;
if (!$sanitize['email']) {
$_SESSION['error']['email'] = 'your email is invalid';
$error = true;
}
if (!$sanitize['password']) {
$_SESSION['error']['password'] = 'you must given your password';
$error = true;
}
if ($error) {
$_SESSION['flashMessage'] = 'there was a problem';
$this->redirect(url('login'));
}
$user = new User();
if ($u = $user->where('email', '=', $sanitize['email'])->get()->fetch()) {
if (password_verify($sanitize['password'], $u->password)) {
session_regenerate_id(true);
$_SESSION['secu'] = $sanitize['email'];
$this->redirect(url('dashboard'));
}
}
}
示例5: getUserByEmail
/**
* Gets a user by the given E-Mail address
*
* @param String $email
* @return Users the user with the given email
*/
public static function getUserByEmail($email)
{
return User::where("email", "=", $email)->first();
}