示例#1
0
 public function getAccept($username)
 {
     if (Auth::user()->username == $username) {
         return redirect()->route('home');
     }
     $user = User::where('username', $username)->first();
     if (!$user) {
         return redirect()->route('home');
     }
     if (!Auth::user()->hasFriendRequestReceived($user)) {
         return redirect()->route('home');
     }
     Auth::user()->acceptFriendRequest($user);
     return redirect()->route('profile.index', ['username' => $user->username])->with('success', 'Friend request accepted.');
 }
示例#2
0
 public function getProfile($username)
 {
     $validator = Validator::make(['username' => $username], ['username' => 'required|alpha_dash']);
     if ($validator->fails()) {
         abort(404);
     }
     $user = User::where('username', $username)->first();
     if (!$user) {
         abort(404);
     }
     $statuses = $user->statuses()->notReply()->orderBy('created_at', 'desc')->get();
     $authUserIsFriend = false;
     if (Auth::check()) {
         if (Auth::user()->id === $user->id) {
             //using it to reply
             $authUserIsFriend = true;
         } else {
             $authUserIsFriend = Auth::user()->isFriendsWith($user);
         }
     }
     return view('profile.index')->with('user', $user)->with('statuses', $statuses)->with('authUserIsFriend', $authUserIsFriend);
 }
示例#3
0
 public function postPasswordReset(Request $request)
 {
     $this->validate($request, ['email' => 'required|email|max:255', 'identifier' => 'required', 'password' => 'required|min:6|confirmed', 'password_confirmation' => 'required|min:6']);
     $identifier = $request->input('identifier');
     $user = User::where('email', $request->input('email'))->where('active', false)->first();
     if (!$user || !Hash::check($identifier, $user->recover_hash)) {
         return redirect()->route('home');
     }
     $user->update(['password' => Hash::make($request->input('password')), 'recover_hash' => null]);
     notify()->flash('Success', 'success', ['text' => 'Your password has been reset and you can now sign in.']);
     return redirect()->route('auth.signin');
 }