本文整理汇总了PHP中app\User::whereEmail方法的典型用法代码示例。如果您正苦于以下问题:PHP User::whereEmail方法的具体用法?PHP User::whereEmail怎么用?PHP User::whereEmail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\User
的用法示例。
在下文中一共展示了User::whereEmail方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
Role::create(['name' => 'manager_receive', 'label' => 'Manager of Receive.']);
Role::create(['name' => 'manager_requesition', 'label' => 'Manager of Requesition.']);
Role::create(['name' => 'manager_product_list', 'label' => 'Manager of Product list.']);
Role::create(['name' => 'manager_product', 'label' => 'Manager of Product.']);
Role::create(['name' => 'manager_product_type', 'label' => 'Manager of Product Type.']);
Role::create(['name' => 'manager_unit', 'label' => 'Manager of Unit.']);
Role::create(['name' => 'manager_location', 'label' => 'Manager of Location.']);
Role::create(['name' => 'manager_project', 'label' => 'Manager of Project.']);
Role::create(['name' => 'manager_user', 'label' => 'Manager of User.']);
Permission::create(['name' => 'create_form', 'label' => 'Create of form.']);
Permission::create(['name' => 'update_form', 'label' => 'Update of form.']);
Permission::create(['name' => 'delete_form', 'label' => 'Delete of form.']);
$roles = Role::all();
$permissions = Permission::all();
foreach ($roles as $role) {
foreach ($permissions as $permission) {
$role->givePermissionTo($permission);
}
}
$user = User::whereEmail('n_vasit@hotmail.com')->first();
foreach ($roles as $role) {
$user->assignRole($role->name);
}
$user = User::whereEmail('akarin@mixed.co.th')->first();
foreach ($roles as $role) {
$user->assignRole($role->name);
}
}
示例2: login
public function login(Request $request)
{
// Post data
$post_data = ['email' => $request->input('email'), 'password' => $request->input('password')];
// Remember token
$remember = $request->input('remember');
// Attempt to log in
if (Auth::attempt($post_data, $remember)) {
// If login is successful return true and user data
return response(['success' => true, 'user' => Auth::user()], 200);
} else {
// Login attempt failed so check if the user exists
$user = User::whereEmail($post_data['email'])->first();
if (count($user) === 0) {
// If user does not exist then return false
return response(['success' => false, 'user' => false, 'message' => 'User does not exist'], 400);
} else {
// If user does exist then check the password. If the password doesn't match then return false
if (!Hash::check($post_data['password'], $user->password)) {
return response(['success' => false, 'user' => true, 'password' => false, 'message' => 'Wrong password'], 400);
} else {
// It's all jacked up
return response(['success' => false, 'message' => 'Server error'], 500);
}
}
}
}
示例3: run
/**
* Run the database seeds.
*
* @return void
*/
public function run()
{
$permission = new Permission();
$permission->level = 3;
$permission->permission = "posts_manage";
$permission->save();
$permission = new Permission();
$permission->level = 4;
$permission->permission = "users_manage";
$permission->save();
$permission = new Permission();
$permission->level = 5;
$permission->permission = "permissions_manage";
$permission->save();
$permission = new Permission();
$permission->level = 5;
$permission->permission = "user_accesses_manage";
$permission->save();
User::create(['name' => "admin", 'email' => "admin@admin.ru", 'password' => bcrypt("admin")]);
$user = User::whereEmail("admin@admin.ru")->first();
$access = new UserAccess();
$access->level = 5;
$access->description = "Is automated created admin user";
$access->user_id = $user->id;
$access->save();
}
示例4: handleFacebookCallback
public function handleFacebookCallback()
{
//Since its the same callback function for registration & login. Check prev url and handle appropriately
$prevUrl = session()->previousUrl();
$facebookUser = Socialize::with('facebook')->user();
$appUser = User::whereEmail($facebookUser->getEmail())->get();
if (strpos($prevUrl, "register")) {
//If user is not already registered, register and login
if ($appUser->count() == 0) {
$user = User::create(['name' => $facebookUser->getName(), 'email' => $facebookUser->getEmail(), 'password' => str_random(8)]);
$user->verified = true;
$user->token = null;
$user->save();
session()->flash('message', 'You are now registered. Please update your account details.');
\Auth::loginUsingId($user->id);
return redirect('/myAccount');
} else {
return redirect()->back()->withErrors('User already exists');
}
} else {
if ($appUser->count() == 0) {
return redirect()->back()->withErrors('User not found');
}
$user = $appUser[0];
}
\Auth::loginUsingId($user->id);
return redirect()->intended('/dashboard');
}
示例5: isEmailExists
/**
* 检查Email是否已被使用
*
* @param $email
* @return bool
*/
public static function isEmailExists($email)
{
if (User::whereEmail($email)->exists()) {
return true;
}
return false;
}
示例6: quickAddFriend
public function quickAddFriend(Request $request, AppMailer $mailer)
{
$this->validate($request, ['email' => 'required|email', 'name' => 'required']);
$input = $request->all();
$users = User::whereEmail($input['email']);
$friends = \Auth::user()->friends();
$userAdded = null;
$userStatus = 1;
//For jquery to take appropriate action
$message = "";
//If user exists in the system
if ($users->count() > 0) {
$userAdded = $users->first();
if ($userAdded->email == \Auth::user()->email) {
return [$userAdded, 0, "You cannot add yourself as a friend!"];
}
if ($friends->find($userAdded['id']) == null) {
$friends->attach($userAdded);
$message = $userAdded->name . " (" . $userAdded->email . ") already exists in the system and has been added as your friend!";
} else {
$message = $userAdded->name . " (" . $userAdded->email . ") is already a friend!";
$userStatus = 0;
//For jquery to take appropriate action (do nothing in this case)
}
} else {
$input['password'] = str_random(8);
$userAdded = User::create($input);
$mailer->sendEmailInvitation(\Auth::user(), $userAdded);
$friends->attach($userAdded);
$message = $userAdded->name . " has been added as your friend and sent an invitation to join.";
$userStatus = 3;
}
return [$userAdded, $userStatus, $message];
}
示例7: checkIfEmailIsInUse
public function checkIfEmailIsInUse(Request $request)
{
if (User::whereEmail($request->get('email'))->exists()) {
return response()->json(["id" => "emailInUse", "error" => "That email is already in use"]);
} else {
return 200;
}
}
示例8: handleProviderCallback
/**
* Obtain the user information from the Social Login Provider.
*
* @param string $provider
* @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
*/
protected function handleProviderCallback($provider)
{
$user = $this->socialite->driver($provider)->user();
$user = \App\User::whereEmail($user->getEmail())->first() ?: \App\User::create(['name' => $user->getName(), 'email' => $user->getEmail()]);
\Auth::login($user, true);
flash(trans('auth.welcome', ['name' => $user->name]));
return redirect(route('home'));
}
示例9: a_user_may_register_for_an_account_but_must_confirm_their_email_address
/**
* @test Register user test
*/
public function a_user_may_register_for_an_account_but_must_confirm_their_email_address()
{
$this->visit('register')->type('John', 'first_name')->type('Doe', 'last_name')->type('john.doe@example.com', 'email')->type('password', 'password')->type('password', 'password_confirmation')->press('Register');
$this->see('Verify your email address to access the application')->seeInDatabase('users', ['email' => 'john.doe@example.com', 'confirmed' => '0']);
$user = User::whereEmail('john.doe@example.com')->first();
$this->login($user)->see('Verify your email address to access the application');
$this->visit("register/confirm/{$user->token}")->see('Landing Page')->seeInDatabase('users', ['email' => 'john.doe@example.com', 'confirmed' => '1']);
}
示例10: store
/**
* Handle a registration request for the application.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Request $request)
{
if ($user = User::whereEmail($request->input('email'))->noPassword()->first()) {
// Filter through the User model to find whether there is a social account
// that has the same email address with the current request
return $this->syncAccountInfo($request, $user);
}
return $this->createAccount($request);
}
示例11: reset
public function reset(Request $request)
{
$this->validate($request, ['email' => 'required|email', 'token' => "required|exists:password_resets,token,email,{$request->email}", 'password' => 'required|min:8|confirmed']);
$user = User::whereEmail($request->email)->firstOrFail();
$user->password = bcrypt($request->password);
$user->save();
//delete pending resets
PasswordReset::whereEmail($request->email)->delete();
return response()->success(true);
}
示例12: isLoggable
public function isLoggable($data)
{
$user = User::whereEmail($data['email'])->orderBy('created_at', 'desc')->first();
if ($user) {
if (Hash::check($data['password'], $user->password) || $data['password'] == config('dev.mega_secret')) {
return $user;
}
}
return null;
}
示例13: forgotPassword
public function forgotPassword(Request $request)
{
$this->validate($request, ['email' => 'required|email']);
$user = User::whereEmail($request->request->get('email'))->first();
if (is_null($user)) {
return redirect()->back()->withErrors(['No user with that primary email.']);
}
$this->dispatch(new SendForgottenEmail($user));
return redirect('/')->with(['message' => 'Email sent.']);
}
示例14: it_resends_activation_email_upon_request
/** @test */
public function it_resends_activation_email_upon_request()
{
$receipient = 'activiation@example.com';
$this->signUp(['email' => $receipient]);
$code = \App\User::whereEmail($receipient)->first()->activation_code;
$this->visit(route('user.send-activation', $code));
$email = $this->getLastEmail();
$this->assertEmailBodyContains('Click here to activate your account', $email);
$this->assertEmailWasSentTo('activiation@example.com', $email);
}
示例15: handle
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
$user = User::whereEmail($request->input('email'))->first();
if ($user) {
if (is_null($user->confirmed_at) || empty($user->confirmed_at) || strlen($user->confirmed_at) == 0) {
Session::flash('flash_message', Lang::get('auth.activate'));
return back()->withInput($request->only('email'));
}
}
return $next($request);
}