当前位置: 首页>>代码示例>>PHP>>正文


PHP User::where方法代码示例

本文整理汇总了PHP中app\models\User::where方法的典型用法代码示例。如果您正苦于以下问题:PHP User::where方法的具体用法?PHP User::where怎么用?PHP User::where使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\models\User的用法示例。


在下文中一共展示了User::where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: loginHandle

 public function loginHandle($request, $response, $next)
 {
     // $data = $request->post('sdf');
     $email = $request->getParam('email');
     $email = strtolower($email);
     $passwd = $request->getParam('passwd');
     $rememberMe = $request->getParam('remember_me');
     // Handle Login
     $user = User::where('email', '=', $email)->first();
     if ($user == null) {
         $rs['code'] = '0';
         $rs['msg'] = "401 邮箱或者密码错误";
         return $response->getBody()->write(json_encode($rs));
     }
     if ($user->pass != Hash::passwordHash($passwd)) {
         $rs['code'] = '0';
         $rs['msg'] = "402 邮箱或者密码错误";
         return $response->getBody()->write(json_encode($rs));
     }
     $time = time() + 3600;
     Auth::login($user->id, $time);
     $rs['code'] = '1';
     $rs['ok'] = '1';
     $rs['msg'] = "欢迎回来";
     return $response->getBody()->write(json_encode($rs));
 }
开发者ID:nymc,项目名称:ss-panel,代码行数:26,代码来源:AuthController.php

示例2: findOrCreateUser

 /**
  * Find or create a user.
  *
  * @param  \Laravel\Socialite\One\User|\Laravel\Socialite\Two\User  $user
  * @param  string                                                   $provider
  *
  * @return \Arcanesoft\Contracts\Auth\Models\User
  */
 private function findOrCreateUser($user, $provider)
 {
     if ($authUser = User::where('social_provider_id', $user->id)->first()) {
         return $authUser;
     }
     return User::create(['name' => $user->name, 'email' => $user->email, 'social_provider' => $provider, 'social_provider_id' => $user->id]);
 }
开发者ID:arcanesoft,项目名称:auth,代码行数:15,代码来源:SocialAuthController.php

示例3: handle

 public function handle(UserDetailsQuery $query)
 {
     if (!is_null($query->username)) {
         return User::where('username', '=', $query->username)->first();
     }
     return User::find($query->userId);
 }
开发者ID:slice-beans,项目名称:cqs-framework,代码行数:7,代码来源:UserDetailsQueryHandler.php

示例4: getAuthList

 public function getAuthList($uid)
 {
     $user = User::where('id', $uid)->first();
     $user_role = $user->role()->first();
     $role_id = $user_role->pivot->role_id;
     $role = AuthRole::where('id', $role_id)->first();
     $role_privilege = $role->privilege()->select('type', 'ref_id', 'priv_id')->get();
     $pre_menu_arr = [];
     $pre_func_arr = [];
     array_map(function ($n) use(&$pre_menu_arr, &$pre_func_arr) {
         if ($n['type'] == 1) {
             $pre_menu_arr[] = $n['ref_id'];
         } elseif ($n['type'] == 2) {
             $pre_func_arr[] = $n['ref_id'];
         }
     }, $role_privilege->toArray());
     $menu_priv = AuthPrivilegeMenu::whereIn('id', $pre_menu_arr)->get()->toArray();
     $func_priv = AuthPrivilegeFunc::whereIn('id', $pre_func_arr)->get()->toArray();
     $level_arr = [];
     foreach ($menu_priv as $k => $v) {
         $level_arr[$v['level']][$v['id']] = $v;
     }
     krsort($level_arr);
     $this->beMenuTree($level_arr, count($level_arr));
     //$level_arr[1]表示从level为1的开始
     return ['menu_list' => $level_arr[1], 'func_list' => $func_priv];
 }
开发者ID:wordenfan,项目名称:lottory,代码行数:27,代码来源:AuthManager.php

示例5: run

 public function run()
 {
     $adminEmail = Config::get('madison.seeder.admin_email');
     $admin = new Role();
     $admin->name = 'Admin';
     $admin->save();
     $independent_sponsor = new Role();
     $independent_sponsor->name = 'Independent Sponsor';
     $independent_sponsor->save();
     $permIds = array();
     foreach ($this->adminPermissions as $permClass => $data) {
         $perm = new Permission();
         foreach ($data as $key => $val) {
             $perm->{$key} = $val;
         }
         $perm->save();
         $permIds[] = $perm->id;
     }
     $admin->perms()->sync($permIds);
     $user = User::where('email', '=', $adminEmail)->first();
     $user->attachRole($admin);
     $createDocPerm = new Permission();
     $createDocPerm->name = "independent_sponsor_create_doc";
     $createDocPerm->display_name = "Independent Sponsoring";
     $createDocPerm->save();
     $independent_sponsor->perms()->sync(array($createDocPerm->id));
 }
开发者ID:DCgov,项目名称:dc-madison,代码行数:27,代码来源:RbacSeeder.php

示例6: testRegister

 public function testRegister()
 {
     $this->visit('/register')->type('test', 'username')->type('test@test.com', 'email')->type('123456', 'password')->type('123456', 'repassword')->press('Submit')->seePageIs('/progress');
     $user = User::where("email", "=", "test@test.com")->first();
     $this->assertNotNull($user);
     $user->delete();
 }
开发者ID:Thitiwut,项目名称:money-flow,代码行数:7,代码来源:HomeControllerTest.php

示例7: postShowLoginPage

 /**
  * the login data post process here
  * @return [type] [description]
  */
 public function postShowLoginPage()
 {
     check_token($_POST['_token']);
     $okay = true;
     $email = $_POST['email'];
     $password = $_POST['password'];
     // Look up the user
     $user = User::where('active', 1)->where('email', $email)->first();
     if ($user != null) {
         // validate credentials
         if (!password_verify($password, $user->password)) {
             $okay = false;
         }
     } else {
         $okay = false;
     }
     if ($okay) {
         // if valid, log them
         $this->session->login($user);
         header('Location: /');
         exit;
     } else {
         // if not valid redirect to the login page
         Session::flash('errors', ['Invalid Login']);
         echo $this->blade->render('login');
     }
 }
开发者ID:marious,项目名称:modern,代码行数:31,代码来源:AuthenticationController.php

示例8: handle

 public function handle()
 {
     /** @var User[] $users */
     $time = time();
     $users = User::where('accessTokens.expires', '<=', $time)->orWhere('refreshTokens.expires', '<=', $time)->orWhere('tokens.reset_password.expired', '<=', $time)->orWhere('tokens.verify_email.expired', '<=', $time)->get();
     $filter = function ($item) use($time) {
         return $item->expires >= $time;
     };
     foreach ($users as $user) {
         $filteredAccessTokens = $user->accessTokens()->reject($filter);
         if ($filteredAccessTokens->count() > 0) {
             $user->accessTokens()->dissociate($filteredAccessTokens);
         }
         $filteredRefreshTokens = $user->refreshTokens()->reject($filter);
         if ($filteredRefreshTokens->count() > 0) {
             $user->refreshTokens()->dissociate($filteredRefreshTokens);
         }
         if ($user->getResetPasswordToken()['expired'] < $time) {
             $user->removeResetPasswordToken();
         }
         if ($user->getVerifyEmailToken()['expired'] < $time) {
             $user->removeVerifyEmailToken();
         }
         $user->save();
     }
 }
开发者ID:Nebo15,项目名称:gandalf.api,代码行数:26,代码来源:DeleteExpiredTokens.php

示例9: store

 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $data = Input::all();
     $username = $data['username'];
     $password = $data['password'];
     $rules = array('username' => 'required', 'password' => 'required');
     //เช็คค่าว่าง
     $validator = Validator::make($data, $rules);
     if ($validator->fails()) {
         Session::flash('error', error_login);
         return Redirect::to('login');
     } else {
         $model = User::where('username', '=', e($username))->where('activated', '=', '1')->first();
         if (!empty($model)) {
             if (Hash::check($password, $model->password)) {
                 Session::regenerate();
                 Session::put('username', $model->username);
                 Session::put('fullname', $model->fullname);
                 Session::put('uid', $model->id);
                 Session::put('level', $model->level);
                 Session::put('dep', $model->id_dep);
                 Session::put('fingerprint', md5($_SERVER['HTTP_USER_AGENT'] . $_SERVER['REMOTE_ADDR']));
                 return Redirect::intended('/');
             } else {
                 Session::flash('error', error_login);
                 return Redirect::to('login');
             }
         } else {
             Session::flash('error', error_login);
             return Redirect::to('login');
         }
     }
 }
开发者ID:themesanasang,项目名称:nth_supplier,代码行数:38,代码来源:LoginController.php

示例10: store

 /**
  * Store a newly created ShareUser in storage.
  * POST /shareUsers
  *
  * @param Request $request
  *
  * @return Response
  */
 public function store(Request $request)
 {
     if (sizeof(ShareUser::$rules) > 0) {
         $validator = $this->validateRequestOrFail($request, ShareUser::$rules);
         if ($validator) {
             return $validator;
         }
     }
     $input = $request->all();
     $user = User::where('id', $input['user_id'])->first();
     if ($user) {
         $shared_with_other_account = User::where('phoneNo', $user->phoneNo)->lists('id');
         if (count($shared_with_other_account) > 0) {
             $alreadyShared = ShareUser::where('share_objectId', $input['share_objectId'])->wherein('user_id', $shared_with_other_account)->get();
             if (count($alreadyShared) > 0) {
                 return response()->json("The share object id has already been taken.", 403);
             }
         }
         $shareUsers = $this->shareUserRepository->create($input);
         $shared_user = User::where('objectId', $shareUsers->share_objectId)->first();
         if ($shared_user) {
             $shared_user->points += 10;
             $shared_user->update();
             $user->shared = true;
             $user->update();
             $role = Role::where('userId', $user->objectId)->first();
             if ($role) {
                 $user['role'] = $role->name;
             } else {
                 $user['role'] = 'User';
             }
         }
         return $this->sendResponse($user->toArray(), "ShareUser saved successfully");
     }
 }
开发者ID:SawMaineK,项目名称:iwomenapp,代码行数:43,代码来源:ShareUserAPIController.php

示例11: postLoginWrapper

 public function postLoginWrapper(Request $request)
 {
     $userId = Auth::check() ? Auth::user()->id : null;
     $user = User::where('email', '=', $request->input('email'))->first();
     if ($user && $user->failed_logins >= 3) {
         Session::flash('error', trans('texts.invalid_credentials'));
         return redirect()->to('login');
     }
     $response = self::postLogin($request);
     if (Auth::check()) {
         Event::fire(new UserLoggedIn());
         $users = false;
         // we're linking a new account
         if ($userId && Auth::user()->id != $userId) {
             $users = $this->accountRepo->associateAccounts($userId, Auth::user()->id);
             Session::flash('warning', trans('texts.associated_accounts'));
             // check if other accounts are linked
         } else {
             $users = $this->accountRepo->loadAccounts(Auth::user()->id);
         }
         Session::put(SESSION_USER_ACCOUNTS, $users);
         if ($request->create_token) {
             if (!env(API_SECRET) || $request->api_secret !== env(API_SECRET)) {
                 return 'Invalid secret';
             }
             return $this->accountRepo->createToken($request->token_name);
         }
     } elseif ($user) {
         $user->failed_logins = $user->failed_logins + 1;
         $user->save();
     }
     return $response;
 }
开发者ID:jirislam,项目名称:invoice-ninja,代码行数:33,代码来源:AuthController.php

示例12: login

 protected function login($instance)
 {
     if ($instance->getEmail()) {
         $user = User::where('email', $instance->getEmail());
     } else {
         return view('site.login', ['msg' => 'The email address you used is not public. please try another login method']);
     }
     if ($user->exists()) {
         $user = $user->first();
         $updateUser = User::where('id', $user->id)->update(['image' => $instance->getAvatar()]);
         if (Auth::loginUsingId($user->id)) {
             return true;
         }
     } else {
         $pwd = explode('@', $instance->getEmail());
         $pwd = Hash::make($pwd[0] . uniqid());
         $newUser = new User();
         $newUser->name = $instance->getName();
         $newUser->email = $instance->getEmail();
         $newUser->image = $instance->getAvatar();
         $newUser->password = $pwd;
         $newUser->status = 0;
         $newUser->role = 'user';
         if ($newUser->save()) {
             Event::fire(new NewUserEvent($newUser));
             if (Auth::loginUsingId($newUser->id)) {
                 return true;
             }
         }
     }
 }
开发者ID:nahid,项目名称:nahid.co,代码行数:31,代码来源:LoginController.php

示例13: boot

 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     Validator::extend('hashed', function ($attribute, $value, $parameters) {
         // If we're already logged in
         if (Auth::check()) {
             $user = Auth::user();
         } else {
             // Otherwise, try to get the username from form input
             $user = User::where('name', Input::get('name'))->get();
             if (!$user->count()) {
                 return false;
             }
             $user = $user[0];
         }
         if (Hash::check($value, $user->password)) {
             return true;
         }
         return false;
     });
     Validator::extend('time', function ($attribute, $value, $parameters) {
         $value = trim($value);
         // Check against 12 hour time (with AM/PM) or 24 hour time
         $twelve = date_parse_from_format('h:i a', $value);
         $twentyfour = date_parse_from_format('H:i', $value);
         if ($twelve['error_count'] === 0 || $twentyfour['error_count'] === 0) {
             return true;
         }
         return false;
     });
 }
开发者ID:playatech,项目名称:laravel-voldb,代码行数:35,代码来源:AppServiceProvider.php

示例14: ingnoreId

 /**
  * @return \Illuminate\Routing\Route|null|string
  */
 public function ingnoreId()
 {
     $id = $this->route('user');
     $name = $this->input('name');
     $email = $this->input('email');
     return User::where(compact('id', 'name', 'email'))->exists() ? $id : '';
 }
开发者ID:echiteri,项目名称:iBLIS,代码行数:10,代码来源:UserRequest.php

示例15: show

 public function show($id)
 {
     if (is_numeric($id)) {
         $user = User::find($id);
     } else {
         $user = User::where('username', $id)->orWhere('username_clean', $id)->first();
     }
     if ($user === null || !$user->hasProfile()) {
         abort(404);
     }
     if ($user->userPage !== null) {
         $userPage = ['html' => $user->userPage->bodyHTML, 'raw' => $user->userPage->bodyRaw];
     } else {
         $userPage = ['html' => '', 'raw' => ''];
     }
     $allStats = [];
     foreach ($user->statisticsAll() as $mode => $stats) {
         $allStats[$mode] = fractal_item_array($stats, new UserStatisticsTransformer());
     }
     $recentAchievements = fractal_collection_array($user->achievements()->with('achievement')->orderBy('date', 'desc')->limit(8)->get(), new UserAchievementTransformer());
     $recentActivities = fractal_collection_array($user->events()->recent()->get(), new EventTransformer());
     $recentlyReceivedKudosu = fractal_collection_array($user->receivedKudosu()->withPost()->with('post', 'post.topic', 'giver')->orderBy('exchange_id', 'desc')->limit(15)->get(), new KudosuHistoryTransformer());
     $userArray = fractal_item_array($user, new UserTransformer());
     return view('users.show', compact('user', 'mode', 'allStats', 'userPage', 'userArray', 'recentAchievements', 'recentActivities', 'recentlyReceivedKudosu'));
 }
开发者ID:echojc,项目名称:osu-web,代码行数:25,代码来源:UsersController.php


注:本文中的app\models\User::where方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。