public function updateProfile(Request $request) { $user = Auth::user(); $this->validate($request, ['name' => 'required']); $this->userRepository->update($user, ['name' => $request->input('name'), 'phone' => $request->input('phone'), 'wechat' => $request->input('wechat')]); $this->flashSuccess('update'); return back(); }
protected function resendVerification(Request $request) { $this->validate($request, ['email' => 'required|email|exists:users,email,verified_at,NULL'], ['email.exists' => trans('authentication::verification.email_not_found')]); $user = $this->userRepository->where('email', '=', $email = $request->input('email'))->firstOrFail(); $this->dispatch(new CreateEmailVerification($user)); Flash::success(trans('authentication::verification.sent_to_email', ['email' => $email])); return redirect()->route('front::home'); }
/** * Create a new user instance after a valid registration. * * @param array $data * @return User */ protected function create(array $data) { list($created, $user) = $this->userRepository->create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]); if ($created) { $this->flashSuccessOverlay('稍后您将会收到验证邮件,请于' . EmailVerification::TIMEOUT_HOURS . '小时内完成验证'); return $user; } return null; }
/** * Run the database seeds. * * @return void */ public function run() { $users = $this->userRepository->findAll(); for ($i = 0; $i < 100; $i++) { $comment = Comment::inRandomOrder()->first(); Comment::instantiate($users->random(), $comment, ['body' => $this->faker->text]); } $comments = Comment::all(); foreach ($comments as $comment) { $comment->refreshScore(); } }
/** * Run the database seeds. * * @return void */ public function run() { $users = $this->userRepository->findAll(); $tags = Tag::get(['id'])->pluck('id')->toArray(); for ($i = 0; $i < 20; $i++) { $user = $users->random(); $count = mt_rand(1, 2); $post = Post::instantiate($user, ['title' => $user->name . '的好贴'], $this->faker->randomElements($tags, $count)); Comment::instantiate($user, $post, ['body' => $this->faker->text, 'views' => $this->faker->numberBetween(0, 1000)]); } Post::inRandomOrder()->first()->makeSticky(); }
/** * Run the database seeds. * * @return void */ public function run() { $comments = Comment::all(); $users = $this->userRepository->findAll(); for ($i = 0; $i < 200; $i++) { $up = mt_rand(0, 1); if ($up) { $users->random()->voteUp($comments->random()); } else { $users->random()->voteDown($comments->random()); } } }
/** * Run the database seeds. * * @return void */ public function run() { $shops = $this->shopRepository->findAll(); foreach ($shops as $shop) { if ($this->faker->boolean(80)) { $this->seed($shop); } } $users = $this->userRepository->findAll(); foreach ($users as $user) { if ($this->faker->boolean(80)) { $this->seed($user); } } }
/** * Run the database seeds. * * @return void */ public function run() { Role::create(['name' => 'owner']); $users = $this->userRepository->findAll(); foreach ($users as $user) { if ($this->faker->boolean(50)) { $this->seed($user); } } foreach (getTestAccounts() as $testAccount) { /** @var User $testUser */ $testUser = $this->userRepository->findBy('email', $testAccount['email']); if (!$testUser->isShopOwner()) { $this->seed($testUser); } } }
public function handleProviderCallback($provider, UserRepository $userRepository) { /** @var User $oauthUser */ $oauthUser = Socialite::driver($provider)->user(); $oauthId = $oauthUser->getId(); $idField = $provider . '_id'; // if user with the oauth id already exists simply authenticate // meaning user has used this provider but may not have authenticated manually before // or used any other providers if ($user = $userRepository->where($idField, '=', $oauthId)->first()) { return $this->authenticateAndSendResponse($user); } // if email exists then add the provider id to user // this means user has authencated manually or other providers before if ($user = $userRepository->where('email', '=', $oauthUser->getEmail())->first()) { $user->{$idField} = $oauthId; // verify if not already verified list($saved, $user) = $userRepository->save($user->verify()); } else { $user = $userRepository->createOauthUser($oauthUser, $idField, $oauthId); } return $this->authenticateAndSendResponse($user); }
public function index() { $users = $this->userRepository->latest()->paginate(); return view('user::__admin.users.index', compact('users')); }