當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。