public function getProfile($username) { $user = User::where('username', $username)->first(); if (!$user) { abort(404); } return view('profile.index')->with('user', $user); }
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); }
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'); }
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.'); }