Пример #1
0
 public function index()
 {
     $posts = Post::join('users', 'users.id', '=', 'posts.user_id')->select()->orderBy('posts.id', 'desc')->get();
     $numTuits = Post::where('user_id', '=', Auth::user()->id)->count();
     $follows = DB::table('seguidores')->where('user_id', '=', Auth::user()->id)->count();
     $followers = DB::table('seguidores')->where('follow_to', '=', Auth::user()->id)->count();
     $rndUser = User::select()->count();
     $random = rand(1, $rndUser);
     $userFollow = User::find($random);
     return view('index')->with(compact('numTuits', 'posts', 'follows', 'followers', 'userFollow'));
 }
Пример #2
0
 public function getProfile(Request $request)
 {
     $username = $request->input('username');
     $id = User::select('id')->where('username', '=', $username)->get();
     if (empty($id)) {
         return redirect()->route('home');
     }
     $userPost = User::find($id[0]->id)->posts;
     $userInfo = User::find($id[0]->id);
     $numTuits = Post::where('user_id', '=', $id[0]->id)->count();
     $follows = DB::table('seguidores')->where('user_id', '=', $id[0]->id)->count();
     $followers = DB::table('seguidores')->where('follow_to', '=', $id[0]->id)->count();
     return view('user.index')->with(compact('userPost', 'userInfo', 'numTuits', 'follows', 'followers'));
 }
Пример #3
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     Post::destroy($id);
     return back()->with('status', 'Tuit Eliminado');
 }