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


PHP User::whereUsername方法代码示例

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


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

示例1: isUsernameExists

 /**
  * 检查用户名是否已被使用
  *
  * @param $username
  * @return bool
  */
 public static function isUsernameExists($username)
 {
     if (User::whereUsername($username)->exists()) {
         return true;
     }
     return false;
 }
开发者ID:lialosiu,项目名称:amaoto-core,代码行数:13,代码来源:UserManager.php

示例2: postLoginAD

 /**
  * Handle a login request to the application before passing it to AD.
  *
  * @param \Illuminate\Http\Request $request
  * @return \Illuminate\Http\Response
  */
 public function postLoginAD(Request $request)
 {
     if (!User::whereUsername($request->username)->count()) {
         return redirect()->back()->withInput($request->only('username', 'remember'))->withErrors(['username' => 'This account is not authorized.']);
     }
     return $this->login($request);
 }
开发者ID:Drehmini,项目名称:inventory,代码行数:13,代码来源:AuthController.php

示例3: update

 public function update(Request $request, $username)
 {
     $user = User::whereUsername($username)->firstOrFail();
     $user->card = $request->get('name');
     $user->save();
     return redirect("/cards/{$user->username}")->withInfo("Your card has been successfully modified.");
 }
开发者ID:bambangsusanto,项目名称:divkomapp,代码行数:7,代码来源:CardsController.php

示例4: boot

 /**
  * Define your route model bindings, pattern filters, etc.
  *
  * @param  \Illuminate\Routing\Router $router
  * @return void
  */
 public function boot(Router $router)
 {
     parent::boot($router);
     // Route model binding for username.
     $router->bind('username', function ($user) {
         return User::whereUsername($user)->firstOrFail();
     });
 }
开发者ID:jespersgaard,项目名称:larastart,代码行数:14,代码来源:RouteServiceProvider.php

示例5: it_adds_a_newly_registered_user_to_the_default_role_named_user

 /** @test */
 public function it_adds_a_newly_registered_user_to_the_default_role_named_user()
 {
     factory(Role::class)->create(['name' => 'user']);
     $this->post('register', ['username' => 'Foo', 'email' => 'foobar@example.org', 'password' => 'my_secret_password']);
     $user = User::whereUsername('Foo')->with('roles')->first();
     $this->assertCount(1, $user->roles);
     $this->assertTrue($user->hasRole('user'));
 }
开发者ID:guenthertheilen,项目名称:laravel-boilerplate,代码行数:9,代码来源:AuthControllerTest.php

示例6: start

 /**
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function start(Request $request)
 {
     $with = User::whereUsername($request->with)->orWhere('email', $request->with)->first();
     if (is_null($with)) {
         abort(404, "User not found");
     }
     return redirect()->route('messages.show', $with->username);
 }
开发者ID:kinnngg,项目名称:knightofsorrow,代码行数:12,代码来源:MailController.php

示例7: checkIfUsernameIsInUse

 public function checkIfUsernameIsInUse(Request $request)
 {
     if (User::whereUsername($request->username)->exists()) {
         return response()->json(["id" => "usernameInUse", "error" => "That username is already in use"]);
     } else {
         return 200;
     }
 }
开发者ID:locosoft1986,项目名称:react-laravel-reddit,代码行数:8,代码来源:APIController.php

示例8: run

 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $fixtures = [['username' => 'Admin', 'roles' => ['admin', 'user']], ['username' => 'User', 'roles' => ['user']]];
     foreach ($fixtures as $fixture) {
         $user = User::whereUsername($fixture['username'])->firstOrFail();
         foreach ($fixture['roles'] as $role) {
             $user->addRole($role);
         }
     }
 }
开发者ID:guenthertheilen,项目名称:laravel-boilerplate,代码行数:15,代码来源:RoleUserTableSeeder.php

示例9: postResetPassword

 public function postResetPassword(Request $request)
 {
     // reset the users password and log them in.
     $rules = ['password' => 'required|between:3,25', 'password_confirmation' => 'required|same:password'];
     $this->validate($request, $rules);
     // get change and save the users password.
     try {
         // if this fails, user does not exist.
         $user = User::whereUsername($request->input('username'))->firstOrFail();
         $user->password = Hash::make($request->input('password'));
         $user->save();
         Auth::login($user);
         return redirect('/home');
     } catch (ModelNotFoundException $e) {
         return Redirect::back()->withErrors('There was a problem with your password reset.');
     }
 }
开发者ID:ebrimamaubeh,项目名称:utg_bantaba,代码行数:17,代码来源:MyPasswordController.php

示例10: store

 /**
  * Store a newly created resource in storage.
  *
  * @param QuestionsRequest|Request $request
  * @return \Illuminate\Http\Response
  */
 public function store(QuestionsRequest $request)
 {
     $askingTo = null;
     // Find the User whom this Quesion will be asked to if any
     if ($request->has('asking_to')) {
         $askingTo = $request->asking_to;
         // Strip @ if any from beginning of string.
         $askingTo = trim($askingTo);
         $askingTo = ltrim($askingTo, '@');
         $askingTo = User::whereUsername($askingTo)->orWhere('email', $askingTo)->firstOrFail();
         $askingTo = $askingTo->id;
     }
     $slug = slug_for_url($request->question);
     $request->user()->questions()->create(['question' => $request->question, 'public' => $request->public, 'for_user_id' => $askingTo, 'slug' => $slug]);
     $request->user()->xp = $request->user()->xp + 10;
     $request->user()->save();
     return back()->withNotification('Success! Your question is awaiting approval by a Moderator.')->withType('success');
 }
开发者ID:kinnngg-lenz,项目名称:csacerc,代码行数:24,代码来源:QuestionsController.php

示例11: getProfile

 public function getProfile($username)
 {
     $user = User::whereUsername($username)->firstOrFail();
     //dd($user->profile->toArray());
     return View('pages.main.profile')->with('user', $user);
 }
开发者ID:paihz,项目名称:instaX-project,代码行数:6,代码来源:ProfileController.php

示例12: findUsernameBy

 /**
  * [findUsernameBy description]
  * @param  [type] $username [description]
  * @return [type]           [description]
  */
 public function findUsernameBy($username)
 {
     return User::whereUsername($username)->first();
 }
开发者ID:Core-Tech-Labs,项目名称:LAZ,代码行数:9,代码来源:UsersOrigin.php

示例13: theUserWithTheUsernameShouldHaveTheRole

 /**
  * @Then the user with the username :arg1 should have the role :arg2
  */
 public function theUserWithTheUsernameShouldHaveTheRole($arg1, $arg2)
 {
     $user = User::whereUsername($arg1)->firstOrFail();
     PHPUnit::assertTrue($user->hasRole($arg2), "The user with the username {$arg1} does not have the role {$arg2}");
 }
开发者ID:guenthertheilen,项目名称:laravel-boilerplate,代码行数:8,代码来源:FeatureContext.php

示例14: start

 public function start(Request $request)
 {
     $with = User::whereUsername($request->with)->orWhere('email', $request->with)->firstOrFail();
     return redirect()->route('messages.show', $with->username);
 }
开发者ID:kinnngg-lenz,项目名称:csacerc,代码行数:5,代码来源:MessagesController.php

示例15: checkUniqueUsername

 /**
  * @param     $name
  * @param int $i
  *
  * @return mixed
  */
 protected function checkUniqueUsername($name, $i = 0)
 {
     if (User::whereUsername($name)->first()) {
         !$i ? $nr = $i : ($nr = '');
         $i++;
         $this->checkUniqueUsername($name . $nr, $i);
     }
     return $name;
 }
开发者ID:Dimimo,项目名称:Booklet,代码行数:15,代码来源:AuthController.php


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