Пример #1
0
 public function postSignup(Request $request)
 {
     //dd('signup');
     $this->validate($request, ['email' => 'required|unique:users|email|max:255', 'username' => 'required|unique:users|alpha_dash|max:20', 'password' => 'required|min:4']);
     //dd('posted okay');
     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!');
     // redirect to home page and flash a message
 }
Пример #2
0
 public function getAccept($username)
 {
     $user = User::where('username', $username)->first();
     if (!$user) {
         // check if the user can be found or not
         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()->route('profile.index', ['username' => $user->username])->with('info', 'Friend request accepted.');
 }
Пример #3
0
 public function getProfile($username)
 {
     //dd($username); print username
     $user = User::where('username', $username)->first();
     // check if exists
     if (!$user) {
         abort(404);
     }
     $statuses = $user->statuses()->notReply()->get();
     // pull all our statuses and we don't include reply
     //return view('profile.index');
     //return view('profile.index')->with('user', $user);
     return view('profile.index')->with('user', $user)->with('statuses', $statuses)->with('authUserIsFriend', Auth::user()->isFriendsWith($user));
 }
Пример #4
0
 public function getResults(Request $request)
 {
     $query = $request->input('query');
     // the hyperlink after we make a serach
     //dd($query); // if we search for 'Danny', http://mvc_social_network.dev:8000/search?query=Danny
     if (!$query) {
         // if query doesn't exists
         return redirect()->route('home');
     }
     $users = User::where(DB::raw("CONCAT(first_name, ' ', last_name)"), 'LIKE', "%{$query}%")->orWhere('username', 'LIKE', "%{$query}%")->get();
     //dd($users); // print the users details
     //return view('search.results');
     return view('search.results')->with('users', $users);
     // pass the users that we found into our view
 }