コード例 #1
0
 public function getProfile($username)
 {
     $user = User::where('username', $username)->first();
     if (!$user) {
         abort(404);
     }
     return view('profile.index')->with('user', $user);
 }
コード例 #2
0
 public function getResults(Request $request)
 {
     $query = $request->input('query');
     if (!$query) {
         return redirect()->route('home');
     }
     $users = User::where('username', 'LIKE', "%{$query}%")->get();
     return view('search.results')->with('users', $users);
 }
コード例 #3
0
 public function getAccept($username)
 {
     $user = User::where('username', $username)->first();
     // @todo refactor this redudant code into a method to check user.
     if (!$user) {
         return redirect()->route('home')->with('info', 'User could not be found.');
     }
     if (!Auth::user()->hasReceivedFriendRequest($user)) {
         return redirect()->route('home');
     }
     Auth::user()->acceptFriend($user);
     return redirect()->route('profile.index', ['username' => $user->username])->with('info', 'Friend request accepted');
 }
コード例 #4
0
 public function postSignup(Request $request)
 {
     $this->validate($request, ['username' => 'required|unique:users|alpha_dash|max:20', 'email' => 'required|unique:users|email|max:255', 'password' => 'required|min:8']);
     User::create(['username' => $request->input('username'), 'email' => $request->input('email'), 'password' => bcrypt($request->input('password'))]);
     return redirect()->route('home')->with('info', 'Your Account has been created and you can login now.');
 }