/**
  * Show the form for editing the specified resource.
  *
  * @param int $id
  *
  * @return \Illuminate\Http\Response
  */
 public function edit(Request $request)
 {
     $input = $request->except('_token', 'url');
     if (User::where('username', '=', $request->get('username'))->exists()) {
         $input = $request->except('username', '_token', 'url');
         User::find(Auth::user()->id)->updateProfile($input);
         Alert::warning('Oops', 'Username Already Exists');
         return Redirect::back();
     }
     User::find(Auth::user()->id)->updateProfile($input);
     Alert::success('Good', 'You have successfully updated your profile');
     return redirect('/dashboard');
 }
示例#2
0
 /**
  * checks if user exists then creates new if user does not exist.
  */
 private function findOrCreateUser($theUser, $provider)
 {
     $authUser = User::where('uid', $theUser->id)->first();
     $username = isset($theUser->user['first_name']) ? $theUser->user['first_name'] : $theUser->nickname;
     if ($authUser) {
         return $authUser;
     }
     if (User::where('username', $theUser->nickname)->first()) {
         $user = factory(User::class)->make(['username' => $username, 'email' => $theUser->email, 'provider' => $provider, 'uid' => $theUser->id, 'avatar_url' => $theUser->avatar]);
     }
     return User::create(['username' => $username, 'email' => $theUser->email, 'provider' => $provider, 'uid' => $theUser->id, 'avatar_url' => $theUser->avatar]);
 }