예제 #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 getAccept($username)
 {
     $user = User::where('username', $username)->first();
     if (!$user) {
         return redirect()->route('home')->with('info', 'That user could not be found.');
     }
     if (!Auth::user()->hasFriendRequestReceived($user)) {
         return redirect()->route('home');
     }
     Auth::user()->acceptFriendRequest($user);
     return redirect()->back()->with('info', 'Friend request accepted.');
     //return redirect()->route('profile.index', ['username' => $username])->with('info', 'Friend request accepted.');
     //dd($username);
 }
예제 #3
0
 public function getResults(Request $request)
 {
     //Search result
     $query = $request->input('query');
     //If no result turns up in the search, the user is redirected to the home page
     if (!$query) {
         return redirect()->route('home');
     }
     //Performs a raw DB query which compares the query to the first and last name of a user
     //or to the username.
     //There may be a better, faster and safer way to do this search
     $users = User::where(DB::raw("CONCAT(first_name, ' ', last_name)"), 'LIKE', "%{$query}%")->orWhere('username', 'LIKE', "%{$query}%")->get();
     //dd($users);
     return view('search.results')->with('users', $users);
 }
예제 #4
0
 public function postSignUp(Request $request)
 {
     $this->validate($request, ['email' => 'required|unique:users|email|max:255', 'username' => 'required|unique:users|alpha_dash|max:20', 'password' => 'required|min:6']);
     User::create(['email' => $request->input('email'), 'username' => $request->input('username'), 'password' => bcrypt($request->input('password'))]);
     return redirect()->route('home')->with('info', 'Your account has been created and you can now sign in.');
 }