Example #1
0
 public function getSearchResults(Request $request)
 {
     $query = $request->input('query');
     if (!$query) {
         return redirect()->route('home');
     }
     $users = User::where(DB::raw("CONCAT(first_name, ' ', last_name)"), 'LIKE', "%{$query}%")->orWhere('username', 'LIKE', "%{$query}%")->get();
     return view('search.results')->with('users', $users);
 }
Example #2
0
 public function postDelete($username)
 {
     $user = User::where('username', $username)->first();
     if (!Auth::user()->isFriendsWith($user)) {
         return redirect()->back();
     }
     // Delete friend
     Auth::user()->deleteFriend($user);
     return redirect()->back()->with('info', 'Friend removed.');
 }
Example #3
0
 public function getProfile($username)
 {
     $user = User::where('username', $username)->first();
     if (!$user) {
         abort(404);
     }
     // If user isn't found a 404 page is returned
     $statuses = $user->statuses()->notReply()->get();
     return view('profile.index')->with('user', $user)->with('statuses', $statuses)->with('authUserIsFriend', Auth::user()->isFriendsWith($user));
 }
Example #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.');
 }