Пример #1
0
 public function getResults(Request $request)
 {
     $requests = Auth::user()->friendRequest();
     $query = $request->input('query');
     if (!$query) {
         return redirect()->route('home');
     }
     $users = User::where(DB::raw("CONCAT(first_name, ' ' ,last_name)"), 'LIKE', "%{$query}%")->orWhere('email', 'LIKE', "{$query}")->orWhere('phone', 'LIKE', "{$query}")->get();
     return view('search.results')->with('users', $users)->with('requests', $requests);
 }
Пример #2
0
 public function postSignup(Request $request)
 {
     $validator = Validator::make($request->all(), ['email' => 'required|unique:users|email|max:255', 'password' => 'required|min:6|confirmed', 'gender' => ['required', 'in:male,female'], 'first_name' => 'required', 'last_name' => 'required']);
     if ($validator->fails()) {
         // dd(redirect()->back()->withInput()->withErrors($validator));
         return redirect()->back()->withInput()->withErrors($validator);
     }
     User::create(['email' => $request->input('email'), 'first_name' => $request->input('first_name'), 'last_name' => $request->input('last_name'), 'gender' => $request->input('gender'), 'password' => bcrypt($request->input('password'))]);
     return redirect()->route('home')->with('info', 'You are successfully registered you can now login by your email');
 }
Пример #3
0
 public function getProfile($id)
 {
     $user = User::where('id', $id)->first();
     $requests = Auth::user()->friendRequest();
     if (!$user) {
         abort(404);
     }
     $posts = Posts::notReply()->where('user_id', $id)->orderBy('created_at', 'desc')->paginate(10);
     $posts_pub = Posts::notReply()->where('user_id', $id)->where('isPublic', true)->orderBy('created_at', 'desc')->paginate(10);
     /*
              * $posts_pub= Posts::notReply()->where('user_id',$id)->orWhere(function($query){
                 $query->where('isPublic',true);})->orderBy('created_at', 'desc')
                 ->paginate(10);
              * */
     //dd($posts);
     return view('profile.index')->with('user', $user)->with('posts', $posts)->with('requests', $requests)->with('posts_pub', $posts_pub)->with('authUserIsFriend', Auth::user()->isFriendWith($user));
 }
Пример #4
0
 public function getDelete($id)
 {
     $user = User::where('id', $id)->first();
     Auth::user()->deleteFriend($user);
     return redirect()->back();
 }