getting the posts of the user we follow

This commit is contained in:
Ghostie 2024-08-23 17:49:11 -05:00
parent b5d43683f8
commit 26b67c8e3e

View File

@ -2,6 +2,7 @@
namespace App\Http\Controllers;
use App\Models\Post;
use Illuminate\Http\Request;
class HomeController extends Controller
@ -9,8 +10,11 @@ class HomeController extends Controller
public function __invoke()
{
// obtain following users
dd(auth()->user()->following->pluck("id")->toArray());
$ids = auth()->user()->following->pluck("id")->toArray();
$posts = Post::whereIn("user_id", $ids)->latest()->paginate(24);
return view("home");
return view("home", [
"posts" => $posts
]);
}
}