user()) { $posts = Post::wherehas("status", function ($query) { $query->where("name", "!=", "Pending") ->orWhere("user_id", "=", auth()->id()); })->get(); return view('index')->with("posts", $posts); } $posts = Post::wherehas("status", function ($query) { $query->where("name", "!=", "Pending"); })->get(); // $posts = Post::all(); return view('index')->with("posts", $posts); } public function adminIndex(Request $request) { $posts = Post::all(); if($request->get("type") != null) { $posts = Post::wherehas("status", function ($query) { $query->where("name", "=", "Pending"); })->get(); } return view('admin.posts')->with("posts", $posts); } }