本文整理汇总了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;
}
示例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);
}
示例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.");
}
示例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();
});
}
示例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'));
}
示例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);
}
示例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;
}
}
示例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);
}
}
}
示例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.');
}
}
示例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');
}
示例11: getProfile
public function getProfile($username)
{
$user = User::whereUsername($username)->firstOrFail();
//dd($user->profile->toArray());
return View('pages.main.profile')->with('user', $user);
}
示例12: findUsernameBy
/**
* [findUsernameBy description]
* @param [type] $username [description]
* @return [type] [description]
*/
public function findUsernameBy($username)
{
return User::whereUsername($username)->first();
}
示例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}");
}
示例14: start
public function start(Request $request)
{
$with = User::whereUsername($request->with)->orWhere('email', $request->with)->firstOrFail();
return redirect()->route('messages.show', $with->username);
}
示例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;
}